Monday, November 25, 2019

Python and Netmiko

Hi all,

I am using Python to automate switch firmware upgrades and have run into an issue almost immediately. I am new to python, see my script below. It actually works very well, logs in, copies, firmware, reboots. The issue I get stuck with is line 7. It waits there and times out with a"Search pattern never detected in send_command_expect:". I basically want it to skip looking for the search pattern and go straight to the next line after it has input "y". Because the switch reboots it'll never come back and match any "search pattern". How would I go about doing that?

Thanks

  1. from netmiko import ConnectHandler
  2. from time import sleep
  3. device = ConnectHandler(device_type="hp_procurve",ip="192.168.101.3", username="manager", password="1234")
  4. output = device.send_command("copy tftp flash 192.168.101.80 YA_16_04_0016.swi primary", expect_string=r"Continue [y/n]?")
  5. output = device.send_command("y", delay_factor=2)
  6. output = device.send_command("boot system flash primary", expect_string=r"Continue [y/n]?")
  7. output = device.send_command("y")
  8. device.disconnect()


No comments:

Post a Comment