forked from Midway91/HactoberFest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReload_device.py
30 lines (29 loc) · 1.3 KB
/
Reload_device.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
def my_reload_device(testbed, device):
'''This function reloads the device
call: my_reload_device(testbed, device)
'''
password = testbed.servers.tftp.password
uut_username = testbed.tacacs['username']
uut_password = testbed.passwords['tacacs']
response = Dialog([
[r'.*Warning: There is already a file existing with this name. Do you want to overwrite \(y/n\)\?\[n\] '
, lambda spawn: spawn.sendline('y'), None, True, False],
[r'.Warning: There is already a file existing with this name. Do you want to.'
, lambda spawn: spawn.sendline('y'), None, True, False],
[r'.*login\:', lambda spawn: spawn.sendline(uut_username), None,
True, False],
[r'Password\:', lambda spawn: spawn.sendline(uut_password),
None, True, False],
[r'.*\s+\(y/n\)\?\s+\[n\]', lambda spawn: spawn.sendline('y'),
None, True, False],
[r'Do you wish to proceed anyway\?\s+\(y/n\)\s+\[n\]',
lambda spawn: spawn.sendline('y'), None, True, False],
])
try:
device.execute("reload", reply = response, timeout = 1200)
except Exception:
log.error(traceback.format_exc())
self.errored('error executing command reload')
time.sleep(360)
disconnect_connect_device(device)
return 1