-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
Code:
def try_command(device, command_abstract,parse=True):
"""
This method attempts commands in NetMiko
"""
device_info=device['netmikoDevice']
command=commands[command_abstract][device_info['device_type']][str(device['version'])]
with ConnectHandler(**device_info) as net_connect:
net_connect.enable()
hostname = net_connect.find_prompt().strip('#<>[]')
output = net_connect.send_command(command, use_textfsm=parse, read_timeout=180)
return hostname, output
commands={'summary':{
'cisco_wlc':{'8':'show ap summary'},
'cisco_xe':{'17':'show ap summary'}
},
'inventory':{
'cisco_wlc':{'8':'show ap inventory all'},
'cisco_xe':{'17':'show ap config general | include AP Serial Number|AP Name '}
},
'bss-table':{
'cisco_xe':{'17':'show ap wlan summary'}
},
'uptime':{
'cisco_wlc':{'8':'show ap uptime'},
'cisco_xe':{'17':'show ap uptime'}
},
'neighbors':{
'cisco_wlc':{'8':'show ap cdp neighbors all'},
'cisco_xe':{'17':'show ap cdp neighbors'}
}
}
controller, invTxt = try_command(wlc[cont],'inventory')
Error:
Traceback (most recent call last):
File "cisco-inventory.py", line 206, in <module>
controller, invTxt = try_command(wlc[cont],'inventory')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "cisco-inventory.py", line 116, in try_command
with ConnectHandler(**device_info) as net_connect:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Lib\site-packages\netmiko\ssh_dispatcher.py", line 410, in ConnectHandler
return ConnectionClass(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Lib\site-packages\netmiko\base_connection.py", line 493, in __init__
self._open()
File "Lib\site-packages\netmiko\base_connection.py", line 499, in _open
self._try_session_preparation()
File "Lib\site-packages\netmiko\base_connection.py", line 993, in _try_session_preparation
self.session_preparation()
File "Lib\site-packages\netmiko\cisco\cisco_ios.py", line 19, in session_preparation
self.set_terminal_width(command=cmd, pattern=cmd)
File "Lib\site-packages\netmiko\base_connection.py", line 1360, in set_terminal_width
output = self.read_until_pattern(pattern=pattern)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "Lib\site-packages\netmiko\base_connection.py", line 751, in read_until_pattern
raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout:
Pattern not detected: 'terminal width 511' in output.
Things you might try to fix this:
1. Adjust the regex pattern to better identify the terminating string. Note, in
many situations the pattern is automatically based on the network device's prompt.
2. Increase the read_timeout to a larger value.
You can also look at the Netmiko session_log or debug log for more information.