Some minor tweaks to fix stuff

This commit is contained in:
Joshua Boniface 2018-06-06 00:44:43 -04:00
parent dacce87175
commit f2ec143544
2 changed files with 13 additions and 4 deletions

5
pvc.py
View File

@ -467,6 +467,11 @@ def search(dom_name, dom_uuid, long_output):
dom_name = pvcf.searchClusterByUUID(zk, dom_uuid)
information = pvcf.getInformationFromXML(zk, dom_uuid, long_output)
if information == None:
click.echo('Could not find a domain matching that name or UUID.')
return
click.echo(information)
pvcf.stopZKConnection(zk)

12
pvcf.py
View File

@ -67,10 +67,14 @@ def stopZKConnection(zk):
#
def getInformationFromXML(zk, uuid, long_output):
# Obtain the contents of the XML from Zookeeper
xml = zk.get('/domains/%s/xml' % uuid)[0].decode('ascii')
dstate = zk.get('/domains/%s/state' % uuid)[0].decode('ascii')
dhypervisor = zk.get('/domains/%s/hypervisor' % uuid)[0].decode('ascii')
dlasthypervisor = zk.get('/domains/%s/lasthypervisor' % uuid)[0].decode('ascii')
try:
xml = zk.get('/domains/%s/xml' % uuid)[0].decode('ascii')
dstate = zk.get('/domains/%s/state' % uuid)[0].decode('ascii')
dhypervisor = zk.get('/domains/%s/hypervisor' % uuid)[0].decode('ascii')
dlasthypervisor = zk.get('/domains/%s/lasthypervisor' % uuid)[0].decode('ascii')
except:
return None
if dlasthypervisor == '':
dlasthypervisor = 'N/A'