cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
231
Views
10
Helpful
2
Replies
JanKrupa45054
Beginner

Bypass pyats bringing device to "config" state

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
Beginner

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
bigevilbeard
Cisco Employee

@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.

JanKrupa45054
Beginner

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

Content for Community-Ad

This widget could not be displayed.