-
Notifications
You must be signed in to change notification settings - Fork 0
/
list_locked.py
executable file
·30 lines (27 loc) · 1.06 KB
/
list_locked.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
#!/usr/bin/python3
import xmlrpc.client
import sys
from socket import getfqdn
import pdb
MANAGER_USER = "infobot"
MANAGER_PASS = "infobot321"
MANAGER_URL = "http://susemanager.suselab.localdomain/rpc/api"
def main():
hostname = getfqdn()
session_key = None
with xmlrpc.client.ServerProxy(MANAGER_URL) as proxy:
try:
session_key = proxy.auth.login(MANAGER_USER, MANAGER_PASS)
systems = proxy.system.listSystems(session_key)
print(f"system_id,system_name,hostname,ip_address,locked")
for s in systems:
details = proxy.system.getDetails(session_key, s['id'])
network = proxy.system.getNetwork(session_key, s['id'])
# print(details)
# print(network)
print(f"{s['id']},{s['name']},{network['hostname']},{network['ip']},{'True' if details['lock_status'] else 'False'}")
if (session_key) is not None:
proxy.auth.logout(session_key)
except ConnectionRefusedError as e:
print(f'Connection error: {e}')
main()