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
This commit is contained in:
parent
a4f693b892
commit
0b3fa781b8
@ -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'),
|
||||
|
Loading…
Reference in New Issue
Block a user