Napalm: OSError: Search pattern never detected in send_command_expect

1k views Asked by At

can anyone help? I got an error when I was trying to test a simple code with napalm. I used cisco on GNS3. I also added optional arguments (delay_factor), but it got the same error.

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\#
1

There are 1 answers

0
Baris Sonmez On

You can use the code that I have shared below.

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.')