-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathap-change.py
70 lines (54 loc) · 2.25 KB
/
ap-change.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
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
from vss_python_api import ApiDeclarations
from getpass import getpass
import time
import sys, getopt
def get_uuid_list(vss_api_instance):
uuid_list = list()
all_devices = vss_api_instance.get_all_devices()[1]
for device in all_devices:
uuid_list.append(device['Uuid'])
return uuid_list
def success(tclv_send, tclv_type, url):
if tclv_send != 200:
print("Sending the TCLV command ID {0} to server URL {1} FAILED, please check the parameters-----".format(tclv_type, url))
else:
print("Command was successful")
def device_tclv(url, key, secret, ap_name, password):
# TCLV commands
ssid_set = 65
psk_set = 67
flash_save = {'Type': 53, 'Value': ''}
reboot = {'Type': 91, 'Value': '0'}
# VSS declaration
vss_api_instance = ApiDeclarations(url, key, secret)
uuid_list = get_uuid_list(vss_api_instance)
# Sending TCLV commands
for uuid in uuid_list:
# Change SSID TCLV
print("----Sending the TCLV command ID {0} to server URL {1}-----".format(ssid_set, url))
tclv_send = vss_api_instance.update_device_config(uuid, ssid_set, ap_name)
success(tclv_send, ssid_set, url)
# Change password TCLV
print("----Sending the TCLV command ID {0} to server URL {1}-----".format(psk_set, url))
tclv_send = vss_api_instance.update_device_config(uuid, psk_set, password)
success(tclv_send, psk_set, url)
# Flash save TCLV
print("----Sending the TCLV command ID {0} to server URL {1}-----".format(flash_save['Type'], url))
tclv_send = vss_api_instance.update_device_config(uuid, flash_save['Type'], flash_save['Value'])
success(tclv_send, flash_save['Type'], url)
# Reboot TCLV
print("----Sending the TCLV command ID {0} to server URL {1}-----".format(reboot['Type'], url))
tclv_send = vss_api_instance.update_device_config(uuid, reboot['Type'], reboot['Value'])
success(tclv_send, reboot['Type'], url)
def main(argv):
url = input("Enter the IP/URL of the server: ").strip()
key = input("Enter the API key: ").strip()
secret = input("Enter the API secret: ").strip()
ap_name = input("Enter the SSID: ").strip()
password = getpass()
try:
device_tclv(url, key, secret, ap_name, password)
except:
print("Something went wrong, re-check if the URL, Api key, and Api secret are correct")
if __name__ == '__main__':
main(sys.argv[1:])