-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetInfo.py
30 lines (25 loc) · 982 Bytes
/
getInfo.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
import requests
import json
import ConfigParser
def getMachines():
config = ConfigParser.ConfigParser()
config.read('/etc/daaas-vmm-admin-page/config.ini')
session = requests.Session()
try:
response = session.get(config.get('VMMConfig','url')+ "machines", headers={'VMM-User':config.get('VMMConfig', 'user'), 'VMM-Password': config.get('VMMConfig','password')})
except:
return []
machines = json.loads(response.text)
return machines
def getMachineTypes():
config = ConfigParser.ConfigParser()
config.read('/etc/daaas-vmm-admin-page/config.ini')
session = requests.Session()
try:
response = session.get(config.get('VMMConfig','url')+ "machinetypes", headers={'VMM-User':config.get('VMMConfig', 'user'), 'VMM-Password': config.get('VMMConfig','password')})
except:
return []
machinetypes = json.loads(response.text)
return machinetypes
if __name__ == '__main__':
print(getMachineInfo())