Napalm:OSError:在send_command_expect中从未检测到搜索模式


有人能帮忙吗?当我试图用凝固汽油弹测试一个简单的代码时,我遇到了一个错误。我在GNS3上使用了cisco。我还添加了可选参数(delay_factor(,但它得到了相同的错误。
from napalm import get_network_driver
driver = get_network_driver("ios")
others = {
"secret" : "cisco",
"dest_file_system" : "nvram:",
'delay_factor': 5
}
device = driver(hostname="192.168.124.148", username="cisco", password="cisco", optional_args=others)
device.open()
device.load_merge_candidate(filename="candidate")
compare = device.compare_config()
print(compare)
device.commit_config()
device.close()
Traceback (most recent call last):
File "c.py", line 16, in <module>
device.commit_config()
File "/Users/zakky.muhammad/Downloads/tmp/Env/lib/python3.8/site-packages/napalm/ios/ios.py", line 555, in commit_config
output += self.device.save_config()
File "/Users/zakky.muhammad/Downloads/tmp/Env/lib/python3.8/site-packages/netmiko/cisco/cisco_ios.py", line 37, in save_config
return super(CiscoIosBase, self).save_config(
File "/Users/zakky.muhammad/Downloads/tmp/Env/lib/python3.8/site-packages/netmiko/cisco_base_connection.py", line 224, in save_config
output = self.send_command(command_string=cmd)
File "/Users/zakky.muhammad/Downloads/tmp/Env/lib/python3.8/site-packages/netmiko/base_connection.py", line 1335, in send_command
raise IOError(
OSError: Search pattern never detected in send_command_expect: R#

您可以使用我在下面分享的代码。

from napalm import get_network_driver
driver = get_network_driver('eos')
device = driver('ip_address', 'username', 'password')
device.open()
device.load_replace_candidate(filename='device.conf')
print (device.compare_config())
if len(device.compare_config()) > 0:
choice = input("nWould you like to Replace the Configuration file? [yN]: ")
if choice == 'y':
print('Committing ...')
device.commit_config()
choice = input("nWould you like to Rollback to previous config? [yN]: ") 
if choice == 'y':
print('Rollback config is in progress ...')
device.rollback()  
else:
print('Discarding ...')
device.discard_config()
else:
print ('No difference')
device.close()
print('Done.')

相关内容

  • 没有找到相关文章

最新更新