From ad8d03c0139a3fbd71b0fa5796cd3ca9f1509758 Mon Sep 17 00:00:00 2001 From: Matthew Farrellee Date: Mon, 27 Jan 2014 16:05:06 -0500 Subject: [PATCH] Add job-create to CLI Change-Id: I441fe2f488fa82bb3d0df50876929f22b71cd666 Implements: blueprint python-savannaclient-cli --- savannaclient/api/shell.py | 46 +++++++++++++++++++++++++++++++++----- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/savannaclient/api/shell.py b/savannaclient/api/shell.py index 063501ce..72e0a8b2 100644 --- a/savannaclient/api/shell.py +++ b/savannaclient/api/shell.py @@ -702,12 +702,11 @@ def do_job_template_delete(cs, args): # # job-show --name |--id # -# TODO(mattf): job-create --name --job-template -# --input-data -# --output-data -# --cluster-template -# NB: Optional job_configs -# NB: POST /jobs/{job_template_id}/execute +# job-create --job-template --cluster +# [--input-data ] [--output-data ] +# [--param ] +# [--arg ] +# [--config ] # # job-delete --name |--id # @@ -732,6 +731,41 @@ def do_job_show(cs, args): _show_job(cs.job_executions.get(args.id)) +@utils.arg('--job-template', + required=True, + help='Id of the job template to run') +@utils.arg('--cluster', + required=True, + help='Id of the cluster to run the job in') +@utils.arg('--input-data', + default=None, + help='Id of the input data source') +@utils.arg('--output-data', + default=None, + help='Id of the output data source') +@utils.arg('--param', + metavar='name=value', + action='append', + default=[], + help='Params to add to the job, repeatable') +@utils.arg('--arg', + action='append', + default=[], + help='Args to add to the job, repeatable') +@utils.arg('--config', + metavar='name=value', + action='append', + default=[], + help='Config parameters to add to the job, repeatable') +def do_job_create(cs, args): + _convert = lambda ls: dict(map(lambda i: i.split('=', 1), ls)) + _show_job(cs.job_executions.create(args.job_template, args.cluster, + args.input_data, args.output_data, + {'params': _convert(args.param), + 'args': dict(zip(args.arg, args.arg)), + 'configs': _convert(args.config)})) + + @utils.arg('--id', required=True, help='Id of a job')