Browse Source

Use a consistent stack ID

Generate the StackId field of various API responses in the same place, so
it is consistent and can be easily modified later.

Change-Id: I09a3e170b5825533d8cf9c7dbf08a0ef6700a682
Signed-off-by: Zane Bitter <zbitter@redhat.com>
changes/25/9325/1
Zane Bitter 10 years ago
parent
commit
de02376d54
  1. 8
      heat/engine/manager.py
  2. 7
      heat/engine/parser.py

8
heat/engine/manager.py

@ -107,7 +107,7 @@ class EngineManager(manager.Manager):
for s in stacks:
stack = parser.Stack.load(context, s.id)
mem = {}
mem['StackId'] = "/".join([s.name, str(s.id)])
mem['StackId'] = stack.stack_id()
mem['StackName'] = s.name
mem['CreationTime'] = heat_utils.strtime(s.created_at)
mem['TemplateDescription'] = stack.t[parser.DESCRIPTION]
@ -143,7 +143,7 @@ class EngineManager(manager.Manager):
if s:
stack = parser.Stack.load(context, s.id)
mem = {}
mem['StackId'] = "/".join([s.name, str(s.id)])
mem['StackId'] = stack.stack_id()
mem['StackName'] = s.name
mem['CreationTime'] = heat_utils.strtime(s.created_at)
mem['LastUpdatedTimestamp'] = heat_utils.strtime(s.updated_at)
@ -191,7 +191,7 @@ class EngineManager(manager.Manager):
stack_id = stack.store()
greenpool.spawn_n(stack.create, **_extract_args(params))
return {'StackId': "/".join([stack.name, str(stack.id)])}
return {'StackId': stack.stack_id()}
def validate_template(self, context, template, params):
"""
@ -519,7 +519,7 @@ def format_stack_resource(resource):
rs = db_api.resource_get(resource.stack.context, resource.id)
last_updated_time = rs.updated_at or rs.created_at
return {
'StackId': resource.stack.id,
'StackId': resource.stack.stack_id(),
'StackName': resource.stack.name,
'LogicalResourceId': resource.name,
'PhysicalResourceId': resource.instance_id or '',

7
heat/engine/parser.py

@ -328,6 +328,13 @@ class Stack(object):
'''Return a human-readable string representation of the stack'''
return 'Stack "%s"' % self.name
def stack_id(self):
'''
Return a unique ID for this stack suitable for displaying to the
user
'''
return '/'.join([self.name, str(self.id)])
def validate(self):
'''
http://docs.amazonwebservices.com/AWSCloudFormation/latest/\

Loading…
Cancel
Save