-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathque_script_prompt_pass
77 lines (68 loc) · 2.56 KB
/
que_script_prompt_pass
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import paramiko
import time
# Prompt user for credentials
print("Enter credentials for router login:")
username = input("Username: ")
password = input("Password: ")
print("")
print(" People Internet (ISP) - Queue Script ")
print("")
print(" 0 : Unlimited ")
print(" 1 : Peak ")
print(" 2 : Off-Peak ")
print(" 3 : Off-Peak-50-Percent ")
print(" 4 : BONUS ")
print(" 5 : DOUBLE_OFF-PEAK ")
print("")
# Define the routers with only IP and port
routers = [
{'hostname': '192.168.80.2', 'port': '22'},
{'hostname': '192.168.80.6', 'port': '22'},
{'hostname': '192.168.80.10', 'port': '22'},
{'hostname': '192.168.80.14', 'port': '22'},
{'hostname': '192.168.80.22', 'port': '22'},
{'hostname': '192.168.100.9', 'port': '22'},
{'hostname': '192.168.100.14', 'port': '22'},
{'hostname': '192.168.100.15', 'port': '22'},
{'hostname': '192.168.100.17', 'port': '22'},
{'hostname': '192.168.100.21', 'port': '22'},
{'hostname': '192.168.100.22', 'port': '22'},
{'hostname': '192.168.100.24', 'port': '22'},
{'hostname': '192.168.100.25', 'port': '22'},
{'hostname': '192.168.100.26', 'port': '22'},
{'hostname': '192.168.100.27', 'port': '22'},
{'hostname': '192.168.100.28', 'port': '22'},
{'hostname': '192.168.100.29', 'port': '22'},
{'hostname': '192.168.100.35', 'port': '22'},
{'hostname': '192.168.100.31', 'port': '22'},
{'hostname': '192.168.100.34', 'port': '22'},
{'hostname': '192.168.100.11', 'port': '22'},
{'hostname': '192.168.100.12', 'port': '22'},
{'hostname': '192.168.100.37', 'port': '22'},
{'hostname': '192.168.100.36', 'port': '22'},
{'hostname': '192.168.100.38', 'port': '22'},
{'hostname': '192.168.100.39', 'port': '22'},
]
script_id = input("Enter Script Value: ")
# Initialize SSH client
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# Iterate through routers and execute commands
for router in routers:
try:
print(f'\nConnecting to {router["hostname"]}...')
client.connect(
hostname=router['hostname'],
port=int(router['port']),
username=username,
password=password
)
print(f'Connected to {router["hostname"]}')
stdin, stdout, stderr = client.exec_command(f'system script run {script_id}')
for line in stdout:
print(line.strip('\n'))
except Exception as e:
print(f"Failed to connect to {router['hostname']}: {e}")
finally:
client.close()
print("\nAll tasks completed.")