summaryrefslogtreecommitdiff
path: root/heatclient/v1
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2015-03-02 12:55:26 +1300
committerSteve Baker <sbaker@redhat.com>2015-03-05 09:12:16 +1300
commit747d7d483c04ca7733699d145e13aa38853549a5 (patch)
tree01eaf53586066aa6e5910294af49615bbccb835f /heatclient/v1
parentaa30b7c4dff0b2cf6532b395b3de32b1cada6af6 (diff)
downloadpython-heatclient-747d7d483c04ca7733699d145e13aa38853549a5.tar.gz
Implement deployment-output-show
This allows a single deployment output to be displayed in either raw or json format. This is a convenience command for scripting based on deployment output values. Change-Id: Iaf6f5a3345a5554403588c3ad74b4c4c4ae0e81b
Diffstat (limited to 'heatclient/v1')
-rw-r--r--heatclient/v1/shell.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/heatclient/v1/shell.py b/heatclient/v1/shell.py
index 78b5486..326a17e 100644
--- a/heatclient/v1/shell.py
+++ b/heatclient/v1/shell.py
@@ -1081,6 +1081,45 @@ def do_deployment_delete(hc, args):
"deployments."))
+@utils.arg('id', metavar='<ID>',
+ help=_('ID deployment to show the output for.'))
+@utils.arg('output', metavar='<OUTPUT NAME>', nargs='?', default=None,
+ help=_('Name of an output to display.'))
+@utils.arg('-a', '--all', default=False, action='store_true',
+ help=_('Display all deployment outputs.'))
+@utils.arg('-F', '--format', metavar='<FORMAT>',
+ help=_('The output value format, one of: raw, json'),
+ default='raw')
+def do_deployment_output_show(hc, args):
+ '''Show a specific stack output.'''
+ if (not args.all and args.output is None or
+ args.all and args.output is not None):
+ raise exc.CommandError(
+ _('Error: either %(output)s or %(all)s argument is needed.')
+ % {'output': '<OUTPUT NAME>', 'all': '--all'})
+ try:
+ sd = hc.software_deployments.get(deployment_id=args.id)
+ except exc.HTTPNotFound:
+ raise exc.CommandError(_('Deployment not found: %s') % args.id)
+ outputs = sd.to_dict().get('output_values', {})
+
+ if args.all:
+ print(utils.json_formatter(outputs))
+ else:
+ for output_key, value in outputs.items():
+ if output_key == args.output:
+ break
+ else:
+ return
+
+ if (args.format == 'json'
+ or isinstance(value, dict)
+ or isinstance(value, list)):
+ print(utils.json_formatter(value))
+ else:
+ print(value)
+
+
def do_build_info(hc, args):
'''Retrieve build information.'''
result = hc.build_info.build_info()