Backslash added in hostname leading to 'pattern not detected'
See original GitHub issueI’m trying to execute a list of commands on devices from a specific inventory by using Nornir. It seems I’m facing an issue at Netmiko level. For some reasons backslash are added to the hostname of some IOS devices (not all) leading to below error:
Traceback (most recent call last):
File "/home/administrator/venv_nornir/lib/python3.8/site-packages/nornir/core/task.py", line 99, in start
r = self.task(self, **self.params)
File "/home/administrator/venv_nornir/lib/python3.8/site-packages/nornir_napalm/plugins/tasks/napalm_cli.py", line 20, in napalm_cli
result = device.cli(commands)
File "/home/administrator/venv_nornir/lib/python3.8/site-packages/napalm/ios/ios.py", line 2372, in cli
output = self._send_command(command)
File "/home/administrator/venv_nornir/lib/python3.8/site-packages/napalm/ios/ios.py", line 205, in _send_command
output = self.device.send_command(command)
File "/home/administrator/venv_nornir/lib/python3.8/site-packages/netmiko/utilities.py", line 600, in wrapper_decorator
return func(self, *args, **kwargs)
File "/home/administrator/venv_nornir/lib/python3.8/site-packages/netmiko/base_connection.py", line 1694, in send_command
raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout:
Pattern not detected: 'CPE\\-XXX\\-YYYYYY\\-ZZZZZZZZ>' in output.
Things you might try to fix this:
1. Explicitly set your pattern using the expect_string argument.
2. Increase the read_timeout to a larger value.
For exemple, device hostname ‘CPE-XXX-YYYYYY-ZZZZZZZZ>’ is converted according ReadTimeout error to: ‘CPE\-XXX\-YYYYYY\-ZZZZZZZZ>’.
To share more details you can find below inventory connection_options settings:
"provider": {
"name": "provider",
"connection_options": {
"napalm": {
"extras": {
"optional_args": {
"force_no_enable": true,
"ssh_config_file": "~/.ssh/config"
}
},
"hostname": null,
"port": null,
"username": null,
"password": null,
"platform": null
},
"netmiko": {
"extras": {
"fast_cli": false,
"global_delay_factor": 2
},
"hostname": null,
"port": null,
"username": null,
"password": null,
"platform": null
}
}
The tricky point is the issue doesn’t appear for all devices even if they are using the same plateform (ios) and same OS version. Moreover, I’m not 100% sure the issue is coming from the hostname.
I’m reaching devices through IP and I can not set the pattern cause I don’t know before to connect to devices the configured hostname.
Could you please help me to solve this issue?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Ok I don’t have any idea of the reason of the issue but for some reason we rebooted the devices and my script is working as expected now.
Okay, FWIW I pretty much never use napalm_cli.
In this case, I would probably say you should just straight Netmiko (i.e. you are just adding a layer of indirection to get at the Netmiko driver). So if it comes up again, I will probably ask if you can reproduce the issue directly using Netmiko.