heat API : DescribeStacks return all when no stack name specified
The AWS DescribeStacks API documentation says if no stack name specified, we should return results for all stacks created. fixes #142 Change-Id: I3d17fef7f1b660bf399e8ff82ff39ca2b2d6f046 Signed-off-by: Steven Hardy <shardy@redhat.com>
This commit is contained in:
parent
8e5972a333
commit
b7eee6c64e
4
bin/heat
4
bin/heat
|
@ -270,9 +270,7 @@ def stack_describe(options, arguments):
|
||||||
try:
|
try:
|
||||||
parameters['StackName'] = arguments.pop(0)
|
parameters['StackName'] = arguments.pop(0)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
logging.error("Please specify the stack name you wish to describe")
|
logging.info("No stack name passed, getting results for ALL stacks")
|
||||||
logging.error("as the first argument")
|
|
||||||
return utils.FAILURE
|
|
||||||
|
|
||||||
c = get_client(options)
|
c = get_client(options)
|
||||||
result = c.describe_stacks(**parameters)
|
result = c.describe_stacks(**parameters)
|
||||||
|
|
|
@ -86,10 +86,17 @@ class StackController(object):
|
||||||
con = req.context
|
con = req.context
|
||||||
parms = dict(req.params)
|
parms = dict(req.params)
|
||||||
|
|
||||||
|
# If no StackName parameter is passed, we pass None into the engine
|
||||||
|
# this returns results for all stacks (visible to this user), which
|
||||||
|
# is the behavior described in the AWS DescribeStacks API docs
|
||||||
|
stack_name = None
|
||||||
|
if 'StackName' in req.params:
|
||||||
|
stack_name = req.params['StackName']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
stack_list = rpc.call(con, 'engine',
|
stack_list = rpc.call(con, 'engine',
|
||||||
{'method': 'show_stack',
|
{'method': 'show_stack',
|
||||||
'args': {'stack_name': req.params['StackName'],
|
'args': {'stack_name': stack_name,
|
||||||
'params': parms}})
|
'params': parms}})
|
||||||
|
|
||||||
except rpc_common.RemoteError as ex:
|
except rpc_common.RemoteError as ex:
|
||||||
|
|
|
@ -123,34 +123,47 @@ class EngineManager(manager.Manager):
|
||||||
"""
|
"""
|
||||||
The show_stack method returns the attributes of one stack.
|
The show_stack method returns the attributes of one stack.
|
||||||
arg1 -> RPC context.
|
arg1 -> RPC context.
|
||||||
arg2 -> Name of the stack you want to see.
|
arg2 -> Name of the stack you want to see, or None to see all
|
||||||
arg3 -> Dict of http request parameters passed in from API side.
|
arg3 -> Dict of http request parameters passed in from API side.
|
||||||
"""
|
"""
|
||||||
auth.authenticate(context)
|
auth.authenticate(context)
|
||||||
|
|
||||||
res = {'stacks': []}
|
res = {'stacks': []}
|
||||||
s = db_api.stack_get_by_name(context, stack_name)
|
stacks = []
|
||||||
if s:
|
if not stack_name:
|
||||||
ps = parser.Stack(context, s.name,
|
stacks = [s.name for s in db_api.stack_get_by_user(context)]
|
||||||
s.raw_template.parsed_template.template,
|
logging.debug("No stack name passed, got %s" % stacks)
|
||||||
s.id, _extract_user_params(params))
|
else:
|
||||||
mem = {}
|
stacks = [stack_name]
|
||||||
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)
|
|
||||||
mem['NotificationARNs'] = 'TODO'
|
|
||||||
mem['Parameters'] = ps.t['Parameters']
|
|
||||||
mem['Description'] = ps.t.get('Description',
|
|
||||||
'No description')
|
|
||||||
mem['StackStatus'] = s.status
|
|
||||||
mem['StackStatusReason'] = s.status_reason
|
|
||||||
|
|
||||||
# only show the outputs on a completely created stack
|
if not stacks:
|
||||||
if s.status == ps.CREATE_COMPLETE:
|
logging.debug("No stacks found to process")
|
||||||
mem['Outputs'] = ps.get_outputs()
|
return res
|
||||||
|
|
||||||
res['stacks'].append(mem)
|
for stack in stacks:
|
||||||
|
logging.debug("Processing show_stack for %s" % stack)
|
||||||
|
s = db_api.stack_get_by_name(context, stack)
|
||||||
|
if s:
|
||||||
|
ps = parser.Stack(context, s.name,
|
||||||
|
s.raw_template.parsed_template.template,
|
||||||
|
s.id, _extract_user_params(params))
|
||||||
|
mem = {}
|
||||||
|
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)
|
||||||
|
mem['NotificationARNs'] = 'TODO'
|
||||||
|
mem['Parameters'] = ps.t['Parameters']
|
||||||
|
mem['Description'] = ps.t.get('Description',
|
||||||
|
'No description')
|
||||||
|
mem['StackStatus'] = s.status
|
||||||
|
mem['StackStatusReason'] = s.status_reason
|
||||||
|
|
||||||
|
# only show the outputs on a completely created stack
|
||||||
|
if s.status == ps.CREATE_COMPLETE:
|
||||||
|
mem['Outputs'] = ps.get_outputs()
|
||||||
|
|
||||||
|
res['stacks'].append(mem)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue