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 <zbitter@redhat.com>
This commit is contained in:
parent
8118aebece
commit
e743158e7a
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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',
|
||||
|
|
Loading…
Reference in New Issue