-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy pathget_devices.py
44 lines (38 loc) · 1.34 KB
/
get_devices.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
#!/usr/bin/env python
##############################################################
# written by Markus Nikulski
# 07. Mar. 2022
##############################################################
import XIQ
import logging
logging.basicConfig( level=logging.INFO, format='%(asctime)s %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s')
##############################################################
xiqUser = 'xxxxxxxx'
xiqPasswd = 'xxxxxxxx'
log = logging.getLogger()
session = XIQ.API(xiqUser, xiqPasswd)
runCLI = True
##############################################################
if session.error:
log.error("login failed: %s" % session.message)
exit(1)
else:
log.debug("login passed")
##############################################################
devices = {}
if session.call('GET', 'devices'):
for device in session.data['data']:
print(" %5s %s %s %-15s %s (%s) %s" % (
device['connected'],
device['device_admin_state'],
device['serial_number'],
device['ip_address'],
device['hostname'],
device['device_function'],
device['network_policy_name'],
)
)
else:
log.warning("unable to pull device list: %s" % session.message)
print()