-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_activationkey.py
executable file
·32 lines (30 loc) · 1.01 KB
/
check_activationkey.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
#!/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():
session_key = None
args = sys.argv[1:]
if len(args) != 1:
print(f'Usage: {sys.argv[0]} <key to search>')
exit(1)
else:
search = sys.argv[1]
try:
with xmlrpc.client.ServerProxy(MANAGER_URL) as proxy:
session_key = proxy.auth.login(MANAGER_USER, MANAGER_PASS)
akeys=proxy.activationkey.listActivationKeys(session_key)
for k in akeys:
if k['key'] == search:
print("key found: " + search)
return 0
print("key does not exist: " + search)
if (session_key) is not None:
proxy.auth.logout(session_key)
except ConnectionRefusedError as e:
print(f'Connection error: {e}')
main()