Merge "Add attribute 'state' to meter metadata when source is polling"

This commit is contained in:
Jenkins 2015-09-15 05:09:59 +00:00 committed by Gerrit Code Review
commit 72eb6985c4
3 changed files with 4 additions and 0 deletions

View File

@ -41,6 +41,7 @@ def _get_metadata_from_object(instance):
'host': instance.hostId,
'flavor': instance.flavor,
'status': instance.status.lower(),
'state': getattr(instance, 'OS-EXT-STS:vm_state', u''),
}
# Image properties

View File

@ -30,6 +30,8 @@ class TestPollsterBase(base.BaseTestCase):
self.instance.name = 'instance-00000001'
setattr(self.instance, 'OS-EXT-SRV-ATTR:instance_name',
self.instance.name)
setattr(self.instance, 'OS-EXT-STS:vm_state',
'active')
self.instance.id = 1
self.instance.flavor = {'name': 'm1.small', 'id': 2, 'vcpus': 1,
'ram': 512, 'disk': 20, 'ephemeral': 0}

View File

@ -40,6 +40,7 @@ class TestInstancePollster(base.TestPollsterBase):
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'])
self.assertEqual('active', samples[0].resource_metadata['state'])
@mock.patch('ceilometer.pipeline.setup_pipeline', mock.MagicMock())
def test_get_reserved_metadata_with_keys(self):