Add cluster-create to CLI
cluster-create takes a json data structure and passes it on to the Savanna API. The data structure is read from stdin by default or from a file provided by the --json parameter. Implements: blueprint python-savannaclient-cli Change-Id: I08cd3a38df81e78c71cfbc7cdb4bd59902b2d374
This commit is contained in:
@@ -208,7 +208,7 @@ def do_image_remove_tag(cs, args):
|
||||
#
|
||||
# cluster-show --name <cluster>|--id <cluster_id> [--json]
|
||||
#
|
||||
# TODO(mattf): cluster-create
|
||||
# cluster-create [--json <file>]
|
||||
#
|
||||
# TODO(mattf): cluster-scale
|
||||
#
|
||||
@@ -247,6 +247,22 @@ def do_cluster_show(cs, args):
|
||||
_show_cluster(cluster)
|
||||
|
||||
|
||||
@utils.arg('--json',
|
||||
default=sys.stdin,
|
||||
type=argparse.FileType('r'),
|
||||
help='JSON representation of cluster')
|
||||
def do_cluster_create(cs, args):
|
||||
"""Create a cluster."""
|
||||
# TODO(mattf): improve template validation, e.g. template w/o name key
|
||||
template = json.loads(args.json.read())
|
||||
valid_args = inspect.getargspec(cs.clusters.create).args
|
||||
for name in template.keys():
|
||||
if name not in valid_args:
|
||||
# TODO(mattf): make this verbose - bug/1271147
|
||||
del template[name]
|
||||
_show_cluster(cs.clusters.create(**template))
|
||||
|
||||
|
||||
# TODO(mattf): Add --name
|
||||
#@utils.arg('--name',
|
||||
# metavar='<cluster>',
|
||||
|
||||
Reference in New Issue
Block a user