Merge "Add resolve_outputs parameter to stack get method"

This commit is contained in:
Jenkins
2016-01-13 13:24:20 +00:00
committed by Gerrit Code Review
3 changed files with 51 additions and 3 deletions

View File

@@ -784,6 +784,46 @@ class ShellTestUserPass(ShellBase):
for r in required:
self.assertRegexpMatches(list_text, r)
def test_stack_show_without_outputs(self):
self.register_keystone_auth_fixture()
resp_dict = {"stack": {
"id": "1",
"stack_name": "teststack",
"stack_status": 'CREATE_COMPLETE',
"creation_time": "2012-10-25T01:58:47Z"
}}
resp = fakes.FakeHTTPResponse(
200,
'OK',
{'content-type': 'application/json'},
jsonutils.dumps(resp_dict))
params = {'resolve_outputs': False}
if self.client == http.SessionClient:
self.client.request(
'/stacks/teststack/1',
'GET', params=params).AndReturn(resp)
else:
self.client.json_request(
'GET', '/stacks/teststack/1', params=params
).AndReturn((resp, resp_dict))
self.m.ReplayAll()
list_text = self.shell(
'stack-show teststack/1 --no-resolve-outputs')
required = [
'id',
'stack_name',
'stack_status',
'creation_time',
'teststack',
'CREATE_COMPLETE',
'2012-10-25T01:58:47Z'
]
for r in required:
self.assertRegexpMatches(list_text, r)
def _output_fake_response(self, output_key):
outputs = [

View File

@@ -387,9 +387,12 @@ def do_action_check(hc, args):
@utils.arg('id', metavar='<NAME or ID>',
help=_('Name or ID of stack to describe.'))
@utils.arg('--no-resolve-outputs', action="store_true",
help='Do not resolve outputs of the stack.')
def do_stack_show(hc, args):
'''Describe the stack.'''
fields = {'stack_id': args.id}
fields = {'stack_id': args.id,
'resolve_outputs': not args.no_resolve_outputs}
_do_stack_show(hc, fields)

View File

@@ -252,12 +252,17 @@ class StackManager(StackChildManager):
body = utils.get_response_body(resp)
return body
def get(self, stack_id):
def get(self, stack_id, resolve_outputs=True):
"""Get the metadata for a specific stack.
:param stack_id: Stack ID to lookup
:param resolve_outputs: If True, then outputs for this
stack will be resolved
"""
resp = self.client.get('/stacks/%s' % stack_id)
kwargs = {}
if not resolve_outputs:
kwargs['params'] = {"resolve_outputs": False}
resp = self.client.get('/stacks/%s' % stack_id, **kwargs)
body = utils.get_response_body(resp)
return Stack(self, body.get('stack'))