-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspirent_system_info.py
executable file
·33 lines (25 loc) · 1.11 KB
/
spirent_system_info.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
#!/usr/bin/env python3
import logging
import argparse
import json
from stc_session import StcSession
from stc_config import StcConfig
log = logging.getLogger(__name__)
if __name__ == '__main__':
ap = argparse.ArgumentParser(description='Show Sprient system info.')
ap.add_argument('-l', '--loglevel', choices=['all', 'debug', 'info', 'error', 'critical'],
dest='loglevel', default='info')
args = ap.parse_args()
logging.basicConfig(level=args.loglevel.upper())
config = StcConfig()
with StcSession(config, state=None, keep_open=False) as ss:
data = ss.stc.system_info()
print('System Info: {}'.format(json.dumps(data, indent=4, sort_keys=True)))
data = ss.stc.server_info()
print('Server info: {}'.format(json.dumps(data, indent=4, sort_keys=True)))
data = ss.stc.chassis_info(config.data[StcSession.config_key]['chassis_addr'])
print('Chassis info: {}'.format(json.dumps(data, indent=4, sort_keys=True)))
print("Existing sessions:")
for session in ss.stc.sessions():
print('\t{}'.format(session))
exit(0)