Add cluster-template-create to CLI
cluster-template-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. Change-Id: Ia824eb54b1f255ead8ea1a3e9cdff9ad8bdb07a9 Implements: blueprint python-savannaclient-cli
This commit is contained in:
@@ -342,7 +342,7 @@ def do_node_group_template_delete(cs, args):
|
||||
#
|
||||
# cluster-template-show --name <template>|--id <template_id> [--json]
|
||||
#
|
||||
# TODO(mattf): cluster-template-create
|
||||
# cluster-template-create [--json <file>]
|
||||
#
|
||||
# cluster-template-delete --name <template>|--id <template_id>
|
||||
#
|
||||
@@ -377,6 +377,22 @@ def do_cluster_template_show(cs, args):
|
||||
_show_cluster_template(template)
|
||||
|
||||
|
||||
@utils.arg('--json',
|
||||
default=sys.stdin,
|
||||
type=argparse.FileType('r'),
|
||||
help='JSON representation of cluster template')
|
||||
def do_cluster_template_create(cs, args):
|
||||
"""Create a cluster template."""
|
||||
# TODO(mattf): improve template validation, e.g. template w/o name key
|
||||
template = json.loads(args.json.read())
|
||||
valid_args = inspect.getargspec(cs.cluster_templates.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_template(cs.cluster_templates.create(**template))
|
||||
|
||||
|
||||
# TODO(mattf): Add --name
|
||||
#@utils.arg('--name',
|
||||
# metavar='<template>',
|
||||
|
||||
Reference in New Issue
Block a user