Include instance state in metadata

Instance state is missing from the resource
metadata. This fix includes the status of
an instance in resource/samples so its part
of the resource metadata.

Change-Id: I76edf1c3dabeb0d591d010d4b1771cdba6b95d36
Implements: blueprint ceilometer-instance-state-measurement
This commit is contained in:
Pradeep Kilambi 2014-03-31 15:21:46 -07:00
parent 1403028127
commit e587980bf5
4 changed files with 4 additions and 0 deletions

View File

@ -44,6 +44,7 @@ def _get_metadata_from_object(instance):
'instance_type': (instance.flavor['id'] if instance.flavor else None),
'host': instance.hostId,
'flavor': instance.flavor,
'status': instance.status.lower(),
# Image properties
'image': instance.image,
'image_ref': (instance.image['id'] if instance.image else None),

View File

@ -38,6 +38,7 @@ class TestPollsterBase(test.BaseTestCase):
self.instance.id = 1
self.instance.flavor = {'name': 'm1.small', 'id': 2, 'vcpus': 1,
'ram': 512, 'disk': 20, 'ephemeral': 0}
self.instance.status = 'active'
patch_virt = mock.patch('ceilometer.compute.virt.inspector'
'.get_hypervisor_inspector',

View File

@ -42,6 +42,7 @@ class TestInstancePollster(base.TestPollsterBase):
self.assertEqual(20, samples[0].resource_metadata['disk_gb'])
self.assertEqual(20, samples[0].resource_metadata['root_gb'])
self.assertEqual(0, samples[0].resource_metadata['ephemeral_gb'])
self.assertEqual('active', samples[0].resource_metadata['status'])
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_samples_instance_flavor(self):

View File

@ -61,6 +61,7 @@ class TestLocationMetadata(test.BaseTestCase):
'kernel_id': 'kernel id',
'os_type': 'linux',
'ramdisk_id': 'ramdisk id',
'status': 'active',
'ephemeral_gb': 0,
'root_gb': 20,
'disk_gb': 20,