Hello,
This used to work before I upgrade from version 3.4.0 to version 4.1.1
Not sure why it is failing on the juniper device:
#Use the redispatch method (to switch the Netmiko class to a Juniper)
redispatch(net_connect, device_type='juniper_junos')
net_connect.send_command('cli', expect_string=r'>')
output = net_connect.send_command('show configuration | display set')
if f'vcsr-{domain}' in output:
print(f'Found vcsr-{domain}')
print(f'>>> Deleting vcsr-{domain} instance')
net_connect.send_config_set(f'delete virtual-machines instance vcsr-{domain}',\
exit_config_mode = False)
output = net_connect.commit(and_quit=True)
if 'commit complete' in output:
print(output)
print(Fore.LIGHTGREEN_EX + 'Success!')
else:
print(Fore.RED + f'Could not delete vcsr-{domain} instance')
net_connect.disconnect()
quit()
else:
print(f'No vcsr-{domain} instance running')
net_connect.send_command('exit', expect_string=r'#')
Output:
Checking if any vnf are running: vcsr-a
Traceback (most recent call last):
File "./CSR1000V_License_Stage.py", line 1467, in
check_vnf_running()
File "./CSR1000V_License_Stage.py", line 275, in check_vnf_running
redispatch(net_connect, device_type='juniper_junos')
File "/usr/local/lib/python3.8/site-packages/netmiko/ssh_dispatcher.py", line 449, in redispatch
obj._try_session_preparation()
File "/usr/local/lib/python3.8/site-packages/netmiko/base_connection.py", line 879, in _try_session_preparation
self.session_preparation()
File "/usr/local/lib/python3.8/site-packages/netmiko/juniper/juniper.py", line 20, in session_preparation
self._test_channel_read(pattern=pattern)
File "/usr/local/lib/python3.8/site-packages/netmiko/base_connection.py", line 1119, in _test_channel_read
return self.read_until_pattern(pattern=pattern, read_timeout=20)
File "/usr/local/lib/python3.8/site-packages/netmiko/base_connection.py", line 651, in read_until_pattern
raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout:
Pattern not detected: '[%>$#]' in output.
Things you might try to fix this:
- 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.
- Increase the read_timeout to a larger value.
You can also look at the Netmiko session_log or debug log for more information.
Log file shows this:
DEBUG:netmiko:read_channel: root@ptr53-jdm:#
DEBUG:netmiko:Pattern found: ([$#]) Last login: Tue Jul 19 00:36:24 2022 from fd:192:168:53::250
root@ptr53-jdm:#
DEBUG:netmiko:read_channel:
DEBUG:netmiko:Clear buffer detects data in the channel
DEBUG:netmiko:read_channel:
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
root@ptr53-jdm:#
DEBUG:netmiko:Pattern found: ([$#])
root@ptr53-jdm:#
DEBUG:netmiko:read_channel:
DEBUG:netmiko:Clear buffer detects data in the channel
DEBUG:netmiko:read_channel:
DEBUG:netmiko:[find_prompt()]: prompt is root@ptr53-jdm:#
DEBUG:netmiko:read_channel:
DEBUG:netmiko:write_channel: b'\n'
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
root@ptr53-jdm:#
DEBUG:netmiko:Pattern found: ([$#])
root@ptr53-jdm:#
DEBUG:netmiko:read_channel:
DEBUG:netmiko:Clear buffer detects data in the channel
DEBUG:netmiko:read_channel:
DEBUG:netmiko:[find_prompt()]: prompt is root@ptr53-jdm:#
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
DEBUG:netmiko:read_channel:
...
.....
.......
..........
I also tried commenting this line, but same issue:
#net_connect.send_command('cli', expect_string=r'>')
Hello,
This used to work before I upgrade from version 3.4.0 to version 4.1.1
Not sure why it is failing on the juniper device:
Output:
Log file shows this:
I also tried commenting this line, but same issue:
#net_connect.send_command('cli', expect_string=r'>')