Commit 9fab213b authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review

Merge "Ignoring cpu measurement when instance's state is SHUTOFF."

parents 30fc36db ae2673cd
......@@ -20,7 +20,7 @@ import ceilometer
from ceilometer.compute import pollsters
from ceilometer.compute.pollsters import util
from ceilometer.compute.virt import inspector as virt_inspector
from ceilometer.i18n import _
from ceilometer.i18n import _, _LW
from ceilometer import sample
LOG = log.getLogger(__name__)
......@@ -48,6 +48,11 @@ class CPUPollster(pollsters.BaseComputePollster):
except virt_inspector.InstanceNotFoundException as err:
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
'pollster': self.__class__.__name__, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('Obtaining CPU time is not implemented for %s',
......@@ -110,7 +110,7 @@ class LibvirtInspector(virt_inspector.Inspector):
raise virt_inspector.InstanceNotFoundException(msg)
def inspect_cpus(self, instance):
domain = self._lookup_by_uuid(instance)
domain = self._get_domain_not_shut_off_or_raise(instance)
dom_info =
return virt_inspector.CPUStats(number=dom_info[3], time=dom_info[4])
......@@ -60,6 +60,17 @@ class TestLibvirtInspection(base.BaseTestCase):
self.assertEqual(2, cpu_info.number)
self.assertEqual(999999, cpu_info.time)
def test_inspect_cpus_with_domain_shutoff(self):
connection = self.inspector.connection
with mock.patch.object(connection, 'lookupByUUIDString',
with mock.patch.object(self.domain, 'info',
return_value=(5, 0, 0,
2, 999999)):
def test_inspect_vnics(self):
dom_xml = """
<domain type='kvm'>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment