From 9cb1ce498451700b831435df6e67abecf194c72a Mon Sep 17 00:00:00 2001 From: Nikolay Mahotkin Date: Wed, 23 Apr 2014 17:51:10 +0400 Subject: [PATCH] Add upload workbook definition * Added ability to upload workbook definition using one command - workbook-create * Fix some error messages Partially implements blueprint mistral-cli-enhancements Change-Id: I387d8c6c9aae03d59e779128c5e0d1f8fd8d6ea6 --- mistralclient/api/client.py | 3 ++- mistralclient/commands/workbooks.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mistralclient/api/client.py b/mistralclient/api/client.py index e6195ebe..1012b06c 100644 --- a/mistralclient/api/client.py +++ b/mistralclient/api/client.py @@ -79,7 +79,8 @@ class Client(object): if "v2.0" in auth_url: raise RuntimeError('Mistral supports only v3 ' - 'keystone API.') + 'keystone API. Please see help and ' + 'configure the correct auth url.') keystone = keystone_client.Client(username=username, user_id=user_id, diff --git a/mistralclient/commands/workbooks.py b/mistralclient/commands/workbooks.py index 4e119506..435eec1a 100644 --- a/mistralclient/commands/workbooks.py +++ b/mistralclient/commands/workbooks.py @@ -88,8 +88,14 @@ class Create(ShowCommand): help='Workbook description') parser.add_argument( 'tags', - nargs='*', - help='Workbook tags') + nargs='?', + help='Workbook tags separated by ","') + parser.add_argument( + 'definition', + nargs='?', + type=argparse.FileType('r'), + help='Workbook definition file' + ) return parser @@ -97,7 +103,12 @@ class Create(ShowCommand): workbook = WorkbookManager(self.app.client)\ .create(parsed_args.name, parsed_args.description, - parsed_args.tags) + str(parsed_args.tags).split(',')) + + if parsed_args.definition: + WorkbookManager(self.app.client)\ + .upload_definition(parsed_args.name, + parsed_args.definition.read()) return format(workbook)