From 4a5770cff6d92f2698eaaf5b6cd04c0121c24512 Mon Sep 17 00:00:00 2001 From: vanzhiganov Date: Wed, 12 Oct 2016 11:00:04 +0300 Subject: [PATCH] fix --- SWSCloudNode/compute/qemu/stats.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/SWSCloudNode/compute/qemu/stats.py b/SWSCloudNode/compute/qemu/stats.py index 8fdf0c6..307aa09 100644 --- a/SWSCloudNode/compute/qemu/stats.py +++ b/SWSCloudNode/compute/qemu/stats.py @@ -14,14 +14,14 @@ class QemuStats(object): def __del__(self): self.conn.close() - def network(self, dom): + def network(self, dom_name): results = dict( read_bytes=0, read_packets=0, read_errors=0, read_drops=0, write_bytes=0, write_packets=0, write_errors=0, write_drops=0) - dom = self.conn.lookupByName(dom) + dom = self.conn.lookupByName(dom_name) # dom = conn.lookupByID(5) - if dom == None: + if not dom: return results tree = ElementTree.fromstring(dom.XMLDesc()) @@ -39,17 +39,17 @@ class QemuStats(object): return results - def cpu(self, dom): + def cpu(self, dom_name): # http://libvirt.org/docs/libvirt-appdev-guide-python/en-US/html/libvirt_application_development_guide_using_python-Guest_Domains-Monitoring-vCPU.html results = dict(cpu_time=0, system_time=0, user_time=0) - if self.conn == None: + if not self.conn: print('Failed to open connection to qemu:///system', file=sys.stderr) return results # dom = conn.lookupByID(5) - dom = self.conn.lookupByName(dom) - if dom == None: - print('Failed to find the domain '+domName, file=sys.stderr) + dom = self.conn.lookupByName(dom_name) + if not dom: + print('Failed to find the domain '+dom_name, file=sys.stderr) return results stats = dom.getCPUStats(True) @@ -60,20 +60,20 @@ class QemuStats(object): return results - def memory(self, dom): + def memory(self, dom_name): # http://libvirt.org/docs/libvirt-appdev-guide-python/en-US/html/libvirt_application_development_guide_using_python-Guest_Domains-Monitoring-Memory.html results = dict() - if self.conn == None: + if not self.conn: print('Failed to open connection to qemu:///system', file=sys.stderr) return results # dom = conn.lookupByID(5) - dom = self.conn.lookupByName(dom) - if dom == None: - print('Failed to find the domain '+domName, file=sys.stderr) + dom = self.conn.lookupByName(dom_name) + if not dom: + print('Failed to find the domain '+dom_name, file=sys.stderr) return results - stats = dom.memoryStats() + stats = dom.memoryStats() # print('memory used:') for name in stats: results[name] = stats[name]