Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ec5ce90d9a
|
|
@ -5,8 +5,8 @@ from VM import VM
|
||||||
from Storage import Storage
|
from Storage import Storage
|
||||||
|
|
||||||
USERNAME = "zabbix@pve"
|
USERNAME = "zabbix@pve"
|
||||||
PASSWORD = "zabbix"
|
PASSWORD = "KbCurGdt82NTgBye"
|
||||||
HOST = "172.16.3.11:8006"
|
HOST = "localhost:8006"
|
||||||
|
|
||||||
conn = PVEApi(HOST, USERNAME, PASSWORD)
|
conn = PVEApi(HOST, USERNAME, PASSWORD)
|
||||||
nodelist = conn.get_node_list()
|
nodelist = conn.get_node_list()
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,10 @@ class PVEApi(object):
|
||||||
vmlist = list()
|
vmlist = list()
|
||||||
for node in nodelist:
|
for node in nodelist:
|
||||||
url = self.url + '/nodes/' + node.name + '/qemu'
|
url = self.url + '/nodes/' + node.name + '/qemu'
|
||||||
|
try:
|
||||||
response = json.load(urllib2.urlopen(self.get_request(url), context=ssl._create_unverified_context()))
|
response = json.load(urllib2.urlopen(self.get_request(url), context=ssl._create_unverified_context()))
|
||||||
|
except Exception as e:
|
||||||
|
pass
|
||||||
resources = response['data']
|
resources = response['data']
|
||||||
for machine in resources:
|
for machine in resources:
|
||||||
name = machine[u'name']
|
name = machine[u'name']
|
||||||
|
|
@ -175,7 +178,10 @@ class PVEApi(object):
|
||||||
active = storage[u'active']
|
active = storage[u'active']
|
||||||
enabled = storage[u'enabled']
|
enabled = storage[u'enabled']
|
||||||
avail = storage[u'avail']
|
avail = storage[u'avail']
|
||||||
|
try:
|
||||||
used_fraction = storage[u'used_fraction']
|
used_fraction = storage[u'used_fraction']
|
||||||
|
except KeyError:
|
||||||
|
used_fraction = "Error getting value"
|
||||||
stor = Storage(node, name, total, used, active, enabled, avail, used_fraction)
|
stor = Storage(node, name, total, used, active, enabled, avail, used_fraction)
|
||||||
storagelist.append(stor)
|
storagelist.append(stor)
|
||||||
return storagelist
|
return storagelist
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue