Metadata in compute.instance.exists fix
Fixing problem with inconsistent metadata structure in messages from nova. When message['payload']['metadata'] was not dict ceilometer raised AttributeError. Related to: bug #1297686 Change-Id: Iaf9620202eda293acf6b4776d35600670f2e2a6b
This commit is contained in:
parent
77198470fb
commit
f2596964de
@ -36,7 +36,7 @@ class UserMetadataAwareInstanceNotificationBase(
|
||||
|
||||
def process_notification(self, message):
|
||||
instance_properties = self.get_instance_properties(message)
|
||||
if 'metadata' in instance_properties:
|
||||
if isinstance(instance_properties.get('metadata'), dict):
|
||||
src_metadata = instance_properties['metadata']
|
||||
del instance_properties['metadata']
|
||||
util.add_reserved_user_metadata(src_metadata, instance_properties)
|
||||
|
@ -166,6 +166,55 @@ INSTANCE_EXISTS = {
|
||||
u'timestamp': u'2012-05-08 16:03:44.122481',
|
||||
}
|
||||
|
||||
INSTANCE_EXISTS_METADATA_LIST = {
|
||||
u'_context_auth_token': None,
|
||||
u'_context_is_admin': True,
|
||||
u'_context_project_id': None,
|
||||
u'_context_quota_class': None,
|
||||
u'_context_read_deleted': u'no',
|
||||
u'_context_remote_address': None,
|
||||
u'_context_request_id': u'req-659a8eb2-4372-4c01-9028-ad6e40b0ed22',
|
||||
u'_context_roles': [u'admin'],
|
||||
u'_context_timestamp': u'2012-05-08T16:03:43.760204',
|
||||
u'_context_user_id': None,
|
||||
u'event_type': u'compute.instance.exists',
|
||||
u'message_id': u'4b884c03-756d-4c06-8b42-80b6def9d302',
|
||||
u'payload': {u'audit_period_beginning': u'2012-05-08 15:00:00',
|
||||
u'audit_period_ending': u'2012-05-08 16:00:00',
|
||||
u'bandwidth': {},
|
||||
u'created_at': u'2012-05-07 22:16:18',
|
||||
u'deleted_at': u'',
|
||||
u'disk_gb': 0,
|
||||
u'display_name': u'testme',
|
||||
u'image_ref_url': u'http://10.0.2.15:9292/images/UUID',
|
||||
u'instance_id': u'3a513875-95c9-4012-a3e7-f90c678854e5',
|
||||
u'instance_type': u'm1.tiny',
|
||||
u'instance_type_id': 2,
|
||||
u'launched_at': u'2012-05-07 23:01:27',
|
||||
u'memory_mb': 512,
|
||||
u'state': u'active',
|
||||
u'state_description': u'',
|
||||
u'tenant_id': u'7c150a59fe714e6f9263774af9688f0e',
|
||||
u'user_id': u'1e3ce043029547f1a61c1996d1a531a2',
|
||||
u'reservation_id': u'1e3ce043029547f1a61c1996d1a531a3',
|
||||
u'vcpus': 1,
|
||||
u'root_gb': 0,
|
||||
u'metadata': [],
|
||||
u'ephemeral_gb': 0,
|
||||
u'host': u'compute-host-name',
|
||||
u'availability_zone': u'1e3ce043029547f1a61c1996d1a531a4',
|
||||
u'os_type': u'linux?',
|
||||
u'architecture': u'x86',
|
||||
u'image_ref': u'UUID',
|
||||
u'kernel_id': u'1e3ce043029547f1a61c1996d1a531a5',
|
||||
u'ramdisk_id': u'1e3ce043029547f1a61c1996d1a531a6',
|
||||
},
|
||||
u'priority': u'INFO',
|
||||
u'publisher_id': u'compute.vagrant-precise',
|
||||
u'timestamp': u'2012-05-08 16:03:44.122481',
|
||||
}
|
||||
|
||||
|
||||
INSTANCE_FINISH_RESIZE_END = {
|
||||
u'_context_roles': [u'admin'],
|
||||
u'_context_request_id': u'req-e3f71bb9-e9b9-418b-a9db-a5950c851b25',
|
||||
@ -627,6 +676,11 @@ class TestNotifications(test.BaseTestCase):
|
||||
counters = list(ic.process_notification(INSTANCE_EXISTS))
|
||||
self.assertEqual(1, len(counters))
|
||||
|
||||
def test_instance_exists_metadata_list(self):
|
||||
ic = instance.Instance()
|
||||
counters = list(ic.process_notification(INSTANCE_EXISTS_METADATA_LIST))
|
||||
self.assertEqual(1, len(counters))
|
||||
|
||||
def test_instance_exists_flavor(self):
|
||||
ic = instance.Instance()
|
||||
counters = list(ic.process_notification(INSTANCE_EXISTS))
|
||||
|
Loading…
x
Reference in New Issue
Block a user