From: Zane Bitter Date: Thu, 22 Nov 2012 10:06:57 +0000 (+0100) Subject: RPC API: Return an identifier for events X-Git-Tag: 2014.1~1180 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a5cef837fdfff5963a1c2ef5ee5fdc7367299db5;p=openstack-build%2Fheat-build.git RPC API: Return an identifier for events Change-Id: Iae2f08014e28997e499771ba9d89feb3954540da Signed-off-by: Zane Bitter --- diff --git a/heat/api/cfn/v1/stacks.py b/heat/api/cfn/v1/stacks.py index 630dab26..b7d6d2ea 100644 --- a/heat/api/cfn/v1/stacks.py +++ b/heat/api/cfn/v1/stacks.py @@ -50,12 +50,15 @@ class StackController(object): def _stackid_format(self, resp): """ - Add a host:port:stack prefix, this formats the StackId in the response - more like the AWS spec + Format the StackId field in the response as an ARN, and process other + IDs into the correct format. """ if 'StackId' in resp: identity = identifier.HeatIdentifier(**resp['StackId']) resp['StackId'] = identity.arn() + if 'EventId' in resp: + identity = identifier.EventIdentifier(**resp['EventId']) + resp['EventId'] = identity.event_id return resp @staticmethod diff --git a/heat/engine/api.py b/heat/engine/api.py index f53c16d3..62711f79 100644 --- a/heat/engine/api.py +++ b/heat/engine/api.py @@ -157,7 +157,7 @@ EVENT_KEYS = ( EVENT_RES_STATUS, EVENT_RES_STATUS_DATA, EVENT_RES_TYPE, EVENT_RES_PROPERTIES, ) = ( - 'event_id', + 'event_identity', STACK_ID, STACK_NAME, "event_time", RES_NAME, RES_PHYSICAL_ID, @@ -170,7 +170,7 @@ def format_event(event): stack_identifier = event.stack.identifier() result = { - EVENT_ID: event.id, + EVENT_ID: dict(event.identifier()), EVENT_STACK_ID: dict(stack_identifier), EVENT_STACK_NAME: stack_identifier.stack_name, EVENT_TIMESTAMP: timeutils.isotime(event.timestamp), diff --git a/heat/tests/test_api_cfn_v1.py b/heat/tests/test_api_cfn_v1.py index d1d95cd5..214baec2 100644 --- a/heat/tests/test_api_cfn_v1.py +++ b/heat/tests/test_api_cfn_v1.py @@ -779,7 +779,12 @@ class StackControllerTest(unittest.TestCase): u'path': u''}, u'logical_resource_id': u'WikiDatabase', u'resource_status_reason': u'state changed', - u'event_id': 42, + u'event_identity': { + u'tenant': u't', + u'stack_name': u'wordpress', + u'stack_id': u'6', + u'path': u'/resources/WikiDatabase/events/42' + }, u'resource_status': u'IN_PROGRESS', u'physical_resource_id': None, u'resource_properties': @@ -802,7 +807,7 @@ class StackControllerTest(unittest.TestCase): expected = {'DescribeStackEventsResponse': {'DescribeStackEventsResult': {'StackEvents': - [{'EventId': 42, + [{'EventId': u'42', 'StackId': u'arn:openstack:heat::t:stacks/wordpress/6', 'ResourceStatus': u'IN_PROGRESS', 'ResourceType': u'AWS::EC2::Instance', diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py index 4a6c74ea..7eb4cb90 100644 --- a/heat/tests/test_engine_service.py +++ b/heat/tests/test_engine_service.py @@ -412,8 +412,9 @@ class stackServiceTest(unittest.TestCase): self.assertEqual(len(events), 2) for ev in events: - self.assertTrue('event_id' in ev) - self.assertTrue(ev['event_id'] > 0) + self.assertTrue('event_identity' in ev) + self.assertEqual(type(ev['event_identity']), dict) + self.assertTrue(ev['event_identity']['path'].rsplit('/', 1)[1]) self.assertTrue('logical_resource_id' in ev) self.assertEqual(ev['logical_resource_id'], 'WebServer')