Move instance counter into its own pollster
There's no need to emit a counter in a specific pollster doing something else like CPU polling. Change-Id: If2adc861be4fec3b414d9688cf36219f6a7b04e8 Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
07a90a2290
commit
8ae8584f99
@ -79,6 +79,16 @@ def make_vnic_counter(instance, name, type, volume, vnic_data):
|
||||
)
|
||||
|
||||
|
||||
class InstancePollster(plugin.ComputePollster):
|
||||
|
||||
def get_counters(self, manager, instance):
|
||||
yield make_counter_from_instance(instance,
|
||||
name='instance',
|
||||
type=counter.TYPE_CUMULATIVE,
|
||||
volume=1,
|
||||
)
|
||||
|
||||
|
||||
class DiskIOPollster(plugin.ComputePollster):
|
||||
|
||||
LOG = log.getLogger(__name__ + '.diskio')
|
||||
@ -150,11 +160,6 @@ class CPUPollster(plugin.ComputePollster):
|
||||
type=counter.TYPE_CUMULATIVE,
|
||||
volume=cpu_info['cpu_time'],
|
||||
)
|
||||
yield make_counter_from_instance(instance,
|
||||
name='instance',
|
||||
type=counter.TYPE_CUMULATIVE,
|
||||
volume=1,
|
||||
)
|
||||
except Exception as err:
|
||||
self.LOG.error('could not get CPU time for %s: %s',
|
||||
instance.uuid, err)
|
||||
|
1
setup.py
1
setup.py
@ -65,6 +65,7 @@ setuptools.setup(
|
||||
libvirt_diskio = ceilometer.compute.libvirt:DiskIOPollster
|
||||
libvirt_cpu = ceilometer.compute.libvirt:CPUPollster
|
||||
libvirt_net = ceilometer.compute.libvirt:NetPollster
|
||||
libvirt_instance = ceilometer.compute.libvirt:InstancePollster
|
||||
|
||||
[ceilometer.poll.central]
|
||||
network_floatingip = ceilometer.network.floatingip:FloatingIPPollster
|
||||
|
@ -41,6 +41,23 @@ import mox
|
||||
import re
|
||||
|
||||
|
||||
class TestInstancePollster(unittest.TestCase):
|
||||
|
||||
@skip.skip_if(libvirt_missing, 'Test requires libvirt')
|
||||
def setUp(self):
|
||||
self.manager = manager.AgentManager()
|
||||
self.pollster = libvirt.InstancePollster()
|
||||
super(TestInstancePollster, self).setUp()
|
||||
self.instance = mock.MagicMock()
|
||||
self.instance.name = 'instance-00000001'
|
||||
self.instance.id = 1
|
||||
flags.FLAGS.compute_driver = 'libvirt.LibvirtDriver'
|
||||
flags.FLAGS.connection_type = 'libvirt'
|
||||
|
||||
def test_get_counter(self):
|
||||
list(self.pollster.get_counters(self.manager, self.instance))
|
||||
|
||||
|
||||
class TestDiskIOPollster(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user