netmiko add timeout with command

Solutions on MaxInterview for netmiko add timeout with command by the best coders in the world

showing results for - "netmiko add timeout with command"
Leon
02 Apr 2018
1from netmiko import ConnectHandler
2import time
3
4
5start_time = time.time()
6
7cisco = {
8     'device_type': 'cisco_ios',
9     'host': '10.196.1.73',
10     'username': 'ansible',
11     'password': 'XXX',
12}
13
14print("init connection")
15ssh_conn = ConnectHandler(**cisco)
16print("{} seconds".format(time.time() - start_time))
17
18print("running command")
19try:
20    ssh_conn.send_command_expect(
21        "archive download-sw flash1:c2960x-universalk9-tar.152-4.E6.tar",
22        expect_string="All software images installed",
23        delay_factor=200,
24    )
25except OSError:
26    print("blam")
27finally:
28    print("{} seconds".format(time.time() - start_time))