diff options
author | Jenkins <jenkins@review.openstack.org> | 2013-01-12 00:09:36 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2013-01-12 00:09:36 +0000 |
commit | b828391d524fb352e147f5924f7db3ebafcb00f0 (patch) | |
tree | cb57e57d7c1ed8ec4012df879e69520ddb1a3a96 | |
parent | 7e3a9f8fd4dafbda012d8b9a4527a2fe65c5d352 (diff) | |
parent | e710897a50f4daac6337e9db114e8a73bf025dda (diff) | |
download | nova-b828391d524fb352e147f5924f7db3ebafcb00f0.tar.gz nova-b828391d524fb352e147f5924f7db3ebafcb00f0.tar.xz nova-b828391d524fb352e147f5924f7db3ebafcb00f0.zip |
Merge "Skip domains on libvirt errors in get_vcpu_used()"
-rw-r--r-- | nova/virt/libvirt/driver.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index caf76908c..83d2c96bd 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -2050,15 +2050,26 @@ class LibvirtDriver(driver.ComputeDriver): """ total = 0 - for dom_id in self.list_instance_ids(): - 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]) + 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]) + except libvirt.libvirtError as err: + if err.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN: + LOG.debug(_("List of domains returned by libVirt: %s") + % dom_ids) + LOG.warn(_("libVirt can't find a domain with id: %s") + % dom_id) + continue + raise # NOTE(gtt116): give change to do other task. greenthread.sleep(0) return total |