From cfb60e52b20e04d7331610cc36136d6a033b5196 Mon Sep 17 00:00:00 2001 From: tengqm Date: Sun, 15 Feb 2015 19:52:22 +0800 Subject: [PATCH] Initial support to profile-type-schema --- senlinclient/v1/shell.py | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/senlinclient/v1/shell.py b/senlinclient/v1/shell.py index 7fa769be..3037a591 100644 --- a/senlinclient/v1/shell.py +++ b/senlinclient/v1/shell.py @@ -55,6 +55,28 @@ def do_profile_type_show(sc, args): print(jsonutils.dumps(profile_type, indent=2)) +@utils.arg('profile_type', metavar='', + help=_('Profile type to generate a template for.')) +@utils.arg('-F', '--format', metavar='', + help=_("The template output format, one of: %s.") + % ', '.join(utils.supported_formats.keys())) +def do_profile_type_schema(sc, args): + '''Get the spec of a profile type.''' + try: + params = {'profile_type': args.profile_type} + schema = sc.get(models.ProfileTypeSchema, params) + except exc.HTTPNotFound: + raise exc.CommandError( + _('Profile Type %s not found.') % args.profile_type) + + schema = dict(schema) + + if args.format: + print(utils.format_output(schema, format=args.format)) + else: + print(utils.format_output(schema)) + + @utils.arg('profile_type', metavar='', help=_('Profile type to generate a template for.')) @utils.arg('-F', '--format', metavar='', @@ -571,7 +593,7 @@ def do_cluster_node_del(sc, args): print('Request accepted by action %s' % resp['action']) -@utils.arg('-c', '--count', metavar='', default=1, +@utils.arg('-c', '--count', metavar='', help=_('Number of nodes to be added.')) @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) @@ -581,25 +603,29 @@ def do_cluster_scale_out(sc, args): 'id': args.id, 'action': 'scale_out', 'action_args': { - 'count': args.count, + 'count': args.count } } + resp = sc.action(models.Cluster, params) print('Request accepted by action %s' % resp['action']) -@utils.arg('-c', '--count', metavar='', default=1, +@utils.arg('-c', '--count', metavar='', help=_('Number of nodes to be added.')) @utils.arg('id', metavar='', help=_('Name or ID of cluster to operate on.')) def do_cluster_scale_in(sc, args): '''Scale in a cluster by the specified number of nodes.''' + if args.count is not None: + action_args = {'count': args.count} + else: + action_args = {} + params = { 'id': args.id, 'action': 'scale_in', - 'action_args': { - 'count': args.count, - } + 'action_args': action_args, } resp = sc.action(models.Cluster, params) print('Request accepted by action %s' % resp['action'])