Remove unnecessary try/except blocks from VM reads
The zkhandler read() function takes care of ensuring there is a None value returned if these fail, so these aren't required. Makes the code a fair bit more readable here.
This commit is contained in:
parent
f0fd3d3f0e
commit
e44f3d623e
|
@ -319,22 +319,10 @@ def getInformationFromXML(zkhandler, uuid):
|
||||||
domain_lastnode = zkhandler.read(('domain.last_node', uuid))
|
domain_lastnode = zkhandler.read(('domain.last_node', uuid))
|
||||||
domain_failedreason = zkhandler.read(('domain.failed_reason', uuid))
|
domain_failedreason = zkhandler.read(('domain.failed_reason', uuid))
|
||||||
|
|
||||||
try:
|
domain_node_limit = zkhandler.read(('domain.meta.node_limit', uuid))
|
||||||
domain_node_limit = zkhandler.read(('domain.meta.node_limit', uuid))
|
domain_node_selector = zkhandler.read(('domain.meta.node_selector', uuid))
|
||||||
except Exception:
|
domain_node_autostart = zkhandler.read(('domain.meta.autostart', uuid))
|
||||||
domain_node_limit = None
|
domain_migration_method = zkhandler.read(('domain.meta.migrate_method', uuid))
|
||||||
try:
|
|
||||||
domain_node_selector = zkhandler.read(('domain.meta.node_selector', uuid))
|
|
||||||
except Exception:
|
|
||||||
domain_node_selector = None
|
|
||||||
try:
|
|
||||||
domain_node_autostart = zkhandler.read(('domain.meta.autostart', uuid))
|
|
||||||
except Exception:
|
|
||||||
domain_node_autostart = None
|
|
||||||
try:
|
|
||||||
domain_migration_method = zkhandler.read(('domain.meta.migrate_method', uuid))
|
|
||||||
except Exception:
|
|
||||||
domain_migration_method = None
|
|
||||||
|
|
||||||
if not domain_node_limit:
|
if not domain_node_limit:
|
||||||
domain_node_limit = None
|
domain_node_limit = None
|
||||||
|
@ -344,23 +332,19 @@ def getInformationFromXML(zkhandler, uuid):
|
||||||
if not domain_node_autostart:
|
if not domain_node_autostart:
|
||||||
domain_node_autostart = None
|
domain_node_autostart = None
|
||||||
|
|
||||||
try:
|
domain_profile = zkhandler.read(('domain.profile', uuid))
|
||||||
domain_profile = zkhandler.read(('domain.profile', uuid))
|
|
||||||
except Exception:
|
|
||||||
domain_profile = None
|
|
||||||
|
|
||||||
try:
|
domain_vnc = zkhandler.read(('domain.console.vnc', uuid))
|
||||||
domain_vnc = zkhandler.read(('domain.console.vnc', uuid))
|
if domain_vnc:
|
||||||
domain_vnc_listen, domain_vnc_port = domain_vnc.split(':')
|
domain_vnc_listen, domain_vnc_port = domain_vnc.split(':')
|
||||||
except Exception:
|
else:
|
||||||
domain_vnc_listen = 'None'
|
domain_vnc_listen = 'None'
|
||||||
domain_vnc_port = 'None'
|
domain_vnc_port = 'None'
|
||||||
|
|
||||||
parsed_xml = getDomainXML(zkhandler, uuid)
|
parsed_xml = getDomainXML(zkhandler, uuid)
|
||||||
|
|
||||||
try:
|
stats_data = loads(zkhandler.read(('domain.stats', uuid)))
|
||||||
stats_data = loads(zkhandler.read(('domain.stats', uuid)))
|
if stats_data is None:
|
||||||
except Exception:
|
|
||||||
stats_data = {}
|
stats_data = {}
|
||||||
|
|
||||||
domain_uuid, domain_name, domain_description, domain_memory, domain_vcpu, domain_vcputopo = getDomainMainDetails(parsed_xml)
|
domain_uuid, domain_name, domain_description, domain_memory, domain_vcpu, domain_vcputopo = getDomainMainDetails(parsed_xml)
|
||||||
|
|
Loading…
Reference in New Issue