diff --git a/heat/api/v1/stacks.py b/heat/api/v1/stacks.py index 53c4b7bb00..18deaee534 100644 --- a/heat/api/v1/stacks.py +++ b/heat/api/v1/stacks.py @@ -49,6 +49,15 @@ class StackController(object): def __init__(self, options): self.options = options + # On valid non-error response, we add a host:port:stack prefix + # This formats the StackId in the response more like the AWS spec + def _stackid_addprefix(self, resp): + if 'StackId' in resp: + hostportprefix = ":".join([socket.gethostname(), + str(self.options.bind_port), "stack"]) + resp['StackId'] = "/".join([hostportprefix, resp['StackId']]) + return resp + def list(self, req): """ Returns the following information for all stacks: @@ -66,7 +75,7 @@ class StackController(object): summaries = results['StackSummaries'] if stack_list is not None: for s in stack_list['stacks']: - summaries.append(s) + summaries.append(self._stackid_addprefix(s)) return res @@ -89,7 +98,7 @@ class StackController(object): res = {'DescribeStacksResult': {'Stacks': []}} stacks = res['DescribeStacksResult']['Stacks'] for s in stack_list['stacks']: - stacks.append(s) + stacks.append(self._stackid_addprefix(s)) return res @@ -142,7 +151,7 @@ class StackController(object): stack['Timeout'] = req.params['Timeout'] try: - return rpc.call(con, 'engine', + res = rpc.call(con, 'engine', {'method': 'create_stack', 'args': {'stack_name': req.params['StackName'], 'template': stack, @@ -150,6 +159,8 @@ class StackController(object): except rpc_common.RemoteError as ex: return webob.exc.HTTPBadRequest(str(ex)) + return {'CreateStackResult': self._stackid_addprefix(res)} + def get_template(self, req): con = req.context diff --git a/heat/engine/manager.py b/heat/engine/manager.py index 05bba3f244..f5ea1bb727 100644 --- a/heat/engine/manager.py +++ b/heat/engine/manager.py @@ -149,7 +149,7 @@ class EngineManager(manager.Manager): s.raw_template.parsed_template.template, s.id, _extract_user_params(params)) mem = {} - mem['StackId'] = s.id + mem['StackId'] = "/".join([s.name, str(s.id)]) mem['StackName'] = s.name mem['CreationTime'] = heat_utils.strtime(s.created_at) mem['TemplateDescription'] = ps.t.get('Description', @@ -175,7 +175,7 @@ class EngineManager(manager.Manager): s.raw_template.parsed_template.template, s.id, _extract_user_params(params)) mem = {} - mem['StackId'] = s.id + mem['StackId'] = "/".join([s.name, str(s.id)]) mem['StackName'] = s.name mem['CreationTime'] = heat_utils.strtime(s.created_at) mem['LastUpdatedTimestamp'] = heat_utils.strtime(s.updated_at) @@ -255,8 +255,7 @@ class EngineManager(manager.Manager): stack.parsed_template_id = new_pt.id greenpool.spawn_n(stack.create) - return {'stack': {'id': new_s.id, 'name': new_s.name, - 'CreationTime': heat_utils.strtime(new_s.created_at)}} + return {'StackId': "/".join([new_s.name, str(new_s.id)])} def validate_template(self, context, template, params): """