- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoftware_version.py
More file actions
Latest commit
68 lines (33 loc) · 1.62 KB
/
Copy pathsoftware_version.py
File metadata and controls
68 lines (33 loc) · 1.62 KB
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
#Simple Python Script using GET request to get Software Versions of Devices(vEdges) using an API Call, we use json module to get data in a
#list format, and filter the required data
importjson
importrequests
fromrequests.authimportHTTPBasicAuth
fromrequests.packages.urllib3.exceptionsimportInsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
s=requests.session()
IP=raw_input('Enter the IP: ')
username=raw_input('Enter the username: ')
password=raw_input('Enter the password: ')
uri='https://'+IP+':8443/dataservice/device'
response=s.get(uri, auth=HTTPBasicAuth(username, password), verify=False)
response_data=response.json()
foriinresponse_data['data']:
ifi['personality'] =='vedge'andi['reachability'] =='reachable':
printi['version'],i['local-system-ip'],i['host-name']
#Python Script for POST request , this example is for rediscovering devices, the rsponse will just print the status code for the
#request
importjson
importrequests
fromrequests.authimportHTTPBasicAuth
fromrequests.packages.urllib3.exceptionsimportInsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
s=requests.session()
IP=raw_input('Enter the IP: ')
username=raw_input('Enter the username: ')
password=raw_input('Enter the password: ')
uri='https://'+IP+':8443/dataservice/device/action/rediscover'
payload= {'devices':[{'deviceId': "xx", 'deviceIP': "x.x.x.x"}]}
payload=json.dumps(payload)
response=s.post(uri, auth=HTTPBasicAuth(username, password), data=payload, verify=False)
printresponse