This unifies the two uses of --hypervisor-parameters with only options
(a=b,…) form. The patch changes a little SetInstanceParms since that
expected opts.hypervisor instead of opts.hvparams.
Note that there is another form of --hypervisor-parameters which also
takes the name, that comes in a separate patch.
---
lib/cli.py | 5 +++++
scripts/gnt-instance | 22 +++++++++-------------
2 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/lib/cli.py b/lib/cli.py
index 5898d06..2fed4cf 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 58a8750..144c5d6 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"),
--
1.6.3.3