From 0b3fa781b82246b5410f5e3520c0d9e50ef2bc1f Mon Sep 17 00:00:00 2001 From: Shuangtai Tian Date: Thu, 13 Mar 2014 14:30:14 +0800 Subject: [PATCH] Use the list when get information from libvirt If the libvirt adds new elements to the domain info struct or others, when use the new libvirt, there will be a valueError (too many values to unpack). When we get information from libvirt, we should use the original variable format. This change is for compatibility with upcoming versions of libvirt which change this signature. Change-Id: I885a48b730acd618e7cefc93cee3d69226575b7c Closes-Bug: #1291805 --- ceilometer/compute/virt/libvirt/inspector.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/ceilometer/compute/virt/libvirt/inspector.py b/ceilometer/compute/virt/libvirt/inspector.py index 95821c29..c7465c10 100644 --- a/ceilometer/compute/virt/libvirt/inspector.py +++ b/ceilometer/compute/virt/libvirt/inspector.py @@ -107,12 +107,12 @@ class LibvirtInspector(virt_inspector.Inspector): def inspect_cpus(self, instance_name): domain = self._lookup_by_name(instance_name) - (__, __, __, num_cpu, cpu_time) = domain.info() - return virt_inspector.CPUStats(number=num_cpu, time=cpu_time) + dom_info = domain.info() + return virt_inspector.CPUStats(number=dom_info[3], time=dom_info[4]) def inspect_vnics(self, instance_name): domain = self._lookup_by_name(instance_name) - (state, __, __, __, __) = domain.info() + state = domain.info()[0] if state == libvirt.VIR_DOMAIN_SHUTOFF: LOG.warn(_('Failed to inspect vnics of %(instance_name)s, ' 'domain is in state of SHUTOFF'), @@ -138,17 +138,16 @@ class LibvirtInspector(virt_inspector.Inspector): for p in iface.findall('filterref/parameter')) interface = virt_inspector.Interface(name=name, mac=mac_address, fref=fref, parameters=params) - rx_bytes, rx_packets, __, __, \ - tx_bytes, tx_packets, __, __ = domain.interfaceStats(name) - stats = virt_inspector.InterfaceStats(rx_bytes=rx_bytes, - rx_packets=rx_packets, - tx_bytes=tx_bytes, - tx_packets=tx_packets) + dom_stats = domain.interfaceStats(name) + stats = virt_inspector.InterfaceStats(rx_bytes=dom_stats[0], + rx_packets=dom_stats[1], + tx_bytes=dom_stats[4], + tx_packets=dom_stats[5]) yield (interface, stats) def inspect_disks(self, instance_name): domain = self._lookup_by_name(instance_name) - (state, __, __, __, __) = domain.info() + state = domain.info()[0] if state == libvirt.VIR_DOMAIN_SHUTOFF: LOG.warn(_('Failed to inspect disks of %(instance_name)s, ' 'domain is in state of SHUTOFF'),