Commit 48f212d7 authored by Iustin Pop's avatar Iustin Pop
Browse files

Unify the “--hypervisor” (params only) option



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.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 087ed2ed
......@@ -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.
......
......@@ -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"),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment