From 811aecd6ab662c63a5fad66a47e36bac844becd5 Mon Sep 17 00:00:00 2001 From: Jan Scotka Date: Thu, 5 Mar 2015 15:36:38 +0100 Subject: [PATCH] extended options passed to kwargs value in python dict syntax like -o '{"a":"b","c":"d"}' --- virtdeploy/cli.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/virtdeploy/cli.py b/virtdeploy/cli.py index 23cf4aa..ac8f6a0 100644 --- a/virtdeploy/cli.py +++ b/virtdeploy/cli.py @@ -25,6 +25,7 @@ import pkg_resources import subprocess import sys +import ast import virtdeploy import virtdeploy.errors @@ -38,7 +39,8 @@ def instance_create(args): driver = virtdeploy.get_driver(DRIVER) - instance = driver.instance_create(args.id, args.template) + options=ast.literal_eval(args.options) + instance = driver.instance_create(args.id, args.template,**options) print('name: {0}'.format(instance['name'])) print('root password: {0}'.format(instance['password'])) @@ -109,7 +111,9 @@ def parse_command_line(cmdline): version = pkg_resources.get_distribution('virt-deploy').version parser.add_argument('-v', '--version', action='version', version='%(prog)s {0}'.format(version)) - + parser.add_argument('-o', '--options', action='store',default="{}", + help='add options in python format {a:b, c:d}') + cmd = parser.add_subparsers(dest='command') cmd_create = cmd.add_parser('create', help='create a new instance')