Answers for "netmiko add timeout with command"

0

netmiko add timeout with command

from netmiko import ConnectHandler
import time


start_time = time.time()

cisco = {
     'device_type': 'cisco_ios',
     'host': '10.196.1.73',
     'username': 'ansible',
     'password': 'XXX',
}

print("init connection")
ssh_conn = ConnectHandler(**cisco)
print("{} seconds".format(time.time() - start_time))

print("running command")
try:
    ssh_conn.send_command_expect(
        "archive download-sw flash1:c2960x-universalk9-tar.152-4.E6.tar",
        expect_string="All software images installed",
        delay_factor=200,
    )
except OSError:
    print("blam")
finally:
    print("{} seconds".format(time.time() - start_time))
Posted by: Guest on July-31-2021

Python Answers by Framework

Browse Popular Code Answers by Language