diff --git a/lib/cli.py b/lib/cli.py index 5898d06a89f947b9bb9396b1b575b1d1d5a7196c..2fed4cfaeb815ca3869a9f10537db2b52ffc5e79 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -52,6 +52,7 @@ __all__ = [ "FIELDS_OPT", "FILESTORE_DIR_OPT", "FILESTORE_DRIVER_OPT", + "HVOPTS_OPT", "IALLOCATOR_OPT", "FORCE_OPT", "NOHDR_OPT", @@ -516,6 +517,10 @@ BACKEND_OPT = cli_option("-B", "--backend-parameters", dest="beparams", type="keyval", default={}, help="Backend parameters") +HVOPTS_OPT = cli_option("-H", "--hypervisor-parameters", type="keyval", + default={}, dest="hvparams", + help="Hypervisor parameters") + def _ParseArgs(argv, commands, aliases): """Parser for the command line arguments. diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 58a87506991a0aa14ac1a87f0b0f72d2c67fc576..144c5d6937916d17238f927995b34446e99f6ad3 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -1271,7 +1271,7 @@ def SetInstanceParams(opts, args): """ if not (opts.nics or opts.disks or - opts.hypervisor or opts.beparams): + opts.hvparams or opts.beparams): ToStderr("Please give at least one of the parameters.") return 1 @@ -1283,12 +1283,12 @@ def SetInstanceParams(opts, args): utils.ForceDictType(opts.beparams, constants.BES_PARAMETER_TYPES, allowed_values=[constants.VALUE_DEFAULT]) - for param in opts.hypervisor: - if isinstance(opts.hypervisor[param], basestring): - if opts.hypervisor[param].lower() == "default": - opts.hypervisor[param] = constants.VALUE_DEFAULT + for param in opts.hvparams: + if isinstance(opts.hvparams[param], basestring): + if opts.hvparams[param].lower() == "default": + opts.hvparams[param] = constants.VALUE_DEFAULT - utils.ForceDictType(opts.hypervisor, constants.HVS_PARAMETER_TYPES, + utils.ForceDictType(opts.hvparams, constants.HVS_PARAMETER_TYPES, allowed_values=[constants.VALUE_DEFAULT]) for idx, (nic_op, nic_dict) in enumerate(opts.nics): @@ -1312,7 +1312,7 @@ def SetInstanceParams(opts, args): op = opcodes.OpSetInstanceParams(instance_name=args[0], nics=opts.nics, disks=opts.disks, - hvparams=opts.hypervisor, + hvparams=opts.hvparams, beparams=opts.beparams, force=opts.force) @@ -1540,9 +1540,7 @@ commands = { "Replaces all disks for the instance"), 'modify': (SetInstanceParams, ARGS_ONE_INSTANCE, [DEBUG_OPT, FORCE_OPT, - cli_option("-H", "--hypervisor", type="keyval", - default={}, dest="hypervisor", - help="Change hypervisor parameters"), + HVOPTS_OPT, BACKEND_OPT, cli_option("--disk", help="Disk changes", default=[], dest="disks", @@ -1566,9 +1564,7 @@ commands = { m_node_opt, m_pri_node_opt, m_sec_node_opt, m_clust_opt, m_inst_opt, SUBMIT_OPT, - cli_option("-H", "--hypervisor", type="keyval", - default={}, dest="hvparams", - help="Temporary hypervisor parameters"), + HVOPTS_OPT, BACKEND_OPT, ], "<instance>", "Starts an instance"),