From: Zane Bitter Date: Fri, 16 Nov 2012 11:10:21 +0000 (+0100) Subject: RPC API: Include less detail in resource list X-Git-Tag: 2014.1~1206 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=e743158e7a61c00e2a32c340d3f268d0835f4c69;p=openstack-build%2Fheat-build.git RPC API: Include less detail in resource list Since the stack_list_resources command could be returning data for a large number of resources, avoid returning the metadata and description (which are not needed) to save space. Change-Id: I4e3a46315952f8dd451410622de0d68423abbbf2 Signed-off-by: Zane Bitter --- diff --git a/heat/engine/api.py b/heat/engine/api.py index b0a4a668..74d4c750 100644 --- a/heat/engine/api.py +++ b/heat/engine/api.py @@ -124,14 +124,13 @@ RES_KEYS = ( ) -def format_stack_resource(resource): +def format_stack_resource(resource, detail=True): ''' Return a representation of the given resource that matches the API output expectations. ''' last_updated_time = resource.updated_time or resource.created_time res = { - RES_DESCRIPTION: resource.parsed_template().get('Description', ''), RES_UPDATED_TIME: timeutils.isotime(last_updated_time), RES_NAME: resource.name, RES_PHYSICAL_ID: resource.resource_id or '', @@ -144,6 +143,10 @@ def format_stack_resource(resource): RES_STACK_NAME: resource.stack.name, } + if detail: + res[RES_DESCRIPTION] = resource.parsed_template('Description', '') + res[RES_METADATA] = resource.metadata + return res diff --git a/heat/engine/service.py b/heat/engine/service.py index 655810e2..fcac3341 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -357,7 +357,7 @@ class EngineService(service.Service): stack = parser.Stack.load(context, stack=s) - return [api.format_stack_resource(resource) + return [api.format_stack_resource(resource, detail=False) for resource in stack if resource.id is not None] def metadata_update(self, context, stack_id, resource_name, metadata): diff --git a/heat/tests/test_api_cfn_v1.py b/heat/tests/test_api_cfn_v1.py index 938fb5aa..d1d95cd5 100644 --- a/heat/tests/test_api_cfn_v1.py +++ b/heat/tests/test_api_cfn_v1.py @@ -1031,8 +1031,7 @@ class StackControllerTest(unittest.TestCase): dummy_req = self._dummy_GET_request(params) # Stub out the RPC call to the engine with a pre-canned response - engine_resp = [{u'description': u'', - u'resource_identity': { + engine_resp = [{u'resource_identity': { u'tenant': u't', u'stack_name': u'wordpress', u'stack_id': u'6', @@ -1049,8 +1048,7 @@ class StackControllerTest(unittest.TestCase): u'resource_status': u'CREATE_COMPLETE', u'physical_resource_id': u'a3455d8c-9f88-404d-a85b-5315293e67de', - u'resource_type': u'AWS::EC2::Instance', - u'metadata': {}}] + u'resource_type': u'AWS::EC2::Instance'}] self.m.StubOutWithMock(rpc, 'call') rpc.call(dummy_req.context, self.topic, {'method': 'identify_stack',