From dbbdcdc63543c82065f99ccfa8f02500da13f742 Mon Sep 17 00:00:00 2001 From: "Li, Chen" Date: Thu, 23 Jul 2015 16:07:50 +0800 Subject: [PATCH] Add cluster-scale command to the CLI Cluster scaling is supported in the API but is not exposed in the client shell. It should be added. Change-Id: I319b75f628c48b8d4ecee9ca05b7dd54d15296df Closes-bug: 1446370 --- saharaclient/api/shell.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/saharaclient/api/shell.py b/saharaclient/api/shell.py index 38f6e372..6d00e51f 100644 --- a/saharaclient/api/shell.py +++ b/saharaclient/api/shell.py @@ -277,7 +277,7 @@ def do_image_remove_tag(cs, args): # # cluster-create [--json ] # -# TODO(mattf): cluster-scale +# cluster-scale --name |--id [--json ] # # cluster-delete --name |--id # @@ -331,6 +331,22 @@ def do_cluster_create(cs, args): _show_cluster(cs.clusters.create(**template)) +@utils.arg('--name', + help='Name of the cluster.') +@utils.arg('--id', + metavar='', + help='ID of the cluster.') +@utils.arg('--json', + default=sys.stdin, + type=argparse.FileType('r'), + help='JSON representation of cluster scale.') +def do_cluster_scale(cs, args): + """Scale a cluster """ + cluster_id = args.id or _get_by_id_or_name(cs.clusters, name=args.name).id + scale_template = json.loads(args.json.read()) + _show_cluster(cs.clusters.scale(cluster_id, **scale_template)) + + @utils.arg('--name', help='Name of the cluster.') @utils.arg('--id',