cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2755
Views
15
Helpful
2
Replies

Bypass pyats bringing device to "config" state

JanKrupa45054
Level 1
Level 1

Hello,

I would like to use pyAts as a tool to read configuration from devices. I do not need to enter `config state` mode and I don't even have the rights to do that.

 

When I run my example code

from genie.testbed import load
from pprint import pprint

tb = load('testbed.yaml')
dev = tb.devices['R115']
dev.connect()

I end up with the error:

config term
   ^
% Invalid input detected at '^' marker.
unicon.core.errors.TimeoutError: timeout occurred:
              timeout value: 10
              last_command: 'config term\r'
             pattern: ['^(.*)\\(.*(con|cfg|ipsec-profile|ca-trustpoint|gkm-local-server)\\S*\\)#\\s?$', '^.*--\\s?[Mm]ore\\s?--.*$']
             buffer:"config term\r\nconfig term\r\n   ^\r\n% Invalid input detected at '^' marker.\r\n\r\nR115#"

unicon.core.errors.SubCommandFailure: (StateMachineError('Failed while bringing device to "config" state'), "config term\r\nconfig term\r\n   ^\r\n% Invalid input detected at '^' marker.\r\n\r\nR115#")

When the connect() command is executed, the following commands are executed

config term
device(config)#no logging console
device(config)#line console
device(config)#exec-timeout 0
device(config)#terminal width 511
device(config)#end
device#

Is there any way, to bypass these commands? (entering config state mode)

 

Thank you.

1 Accepted Solution

Accepted Solutions

JanKrupa45054
Level 1
Level 1

Thanks to Antoine Orsoni


The connection below solves the problem

device.connect(init_exec_commands=[],
               init_config_commands=[],
               log_stdout=False)

View solution in original post

2 Replies 2

@JanKrupa45054 if you do not get the reply here, head over to the pyATS Webex room here --> https://eurl.io/#r18UzrQVr

 

You can email our external customer mailer at pyats-support-ext@cisco.com. The development team is in EST time zone,
and will usually respond within a day - we will provide best-effort support for your question.

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

JanKrupa45054
Level 1
Level 1

Thanks to Antoine Orsoni


The connection below solves the problem

device.connect(init_exec_commands=[],
               init_config_commands=[],
               log_stdout=False)