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
This commit is contained in:
Nikolay Mahotkin 2014-04-23 17:51:10 +04:00
parent f403e29d5c
commit 9cb1ce4984
2 changed files with 16 additions and 4 deletions

View File

@ -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,

View File

@ -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)