summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Short <chuck.short@canonical.com>2013-02-04 13:36:50 -0600
committerChuck Short <chuck.short@canonical.com>2013-02-04 13:38:05 -0600
commitccd252d383be74ce33eadb019ac1a7958ae2824d (patch)
treef6903ccbdb6a9358436a8d78907a77c5cb57d609
parent47bbf12a6c9705e5abca29a1d44b753c8506505d (diff)
lxc: virDomainGetVcpus is not supported by driver
virDomainGetVcpus is not supported by the libvirt lxc driver, so it results in a nasty traceback. Trap the error and return the number of vcpus. Fixes LP: #1106960 Change-Id: I4e81dedad74ce3c58fcdf3ee064dfa0b9aa9a755 Signed-off-by: Chuck Short <chuck.short@canonical.com>
-rw-r--r--nova/virt/libvirt/driver.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index bd2f51e69..20f5f0902 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -2198,18 +2198,15 @@ class LibvirtDriver(driver.ComputeDriver):
"""
total = 0
+ if CONF.libvirt_type == 'lxc':
+ return total + 1
+
dom_ids = self.list_instance_ids()
for dom_id in dom_ids:
try:
dom = self._conn.lookupByID(dom_id)
vcpus = dom.vcpus()
- if vcpus is None:
- # dom.vcpus is not implemented for lxc, but returning 0 for
- # a used count is hardly useful for something measuring
- # usage
- total += 1
- else:
- total += len(vcpus[1])
+ total += len(vcpus[1])
except libvirt.libvirtError as err:
if err.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
LOG.debug(_("List of domains returned by libVirt: %s")