From ccd252d383be74ce33eadb019ac1a7958ae2824d Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Mon, 4 Feb 2013 13:36:50 -0600 Subject: 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 --- nova/virt/libvirt/driver.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'nova') 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") -- cgit