Commit 625ac113 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add support for modifying cluster OS parameters



We use _GetUpdatedParams in order to support removal too, and then
validate the OS parameters if the OS exists.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 21d7df5f
......@@ -2426,6 +2426,30 @@ class LUSetClusterParams(LogicalUnit):
else:
self.new_os_hvp[os_name][hv_name].update(hv_dict)
# os parameters
self.new_osp = objects.FillDict(cluster.osparams, {})
if self.op.osparams:
if not isinstance(self.op.osparams, dict):
raise errors.OpPrereqError("Invalid 'osparams' parameter on input",
errors.ECODE_INVAL)
for os_name, osp in self.op.osparams.items():
if not isinstance(osp, dict):
raise errors.OpPrereqError(("Invalid 'osparams' parameter on"
" input"), errors.ECODE_INVAL)
if os_name not in self.new_osp:
self.new_osp[os_name] = {}
self.new_osp[os_name] = _GetUpdatedParams(self.new_osp[os_name], osp,
use_none=True)
if not self.new_osp[os_name]:
# we removed all parameters
del self.new_osp[os_name]
else:
# check the parameter validity (remote check)
_CheckOSParams(self, False, [self.cfg.GetMasterNode()],
os_name, self.new_osp[os_name])
# changes to the hypervisor list
if self.op.enabled_hypervisors is not None:
self.hv_list = self.op.enabled_hypervisors
......@@ -2502,6 +2526,8 @@ class LUSetClusterParams(LogicalUnit):
self.cluster.beparams[constants.PP_DEFAULT] = self.new_beparams
if self.op.nicparams:
self.cluster.nicparams[constants.PP_DEFAULT] = self.new_nicparams
if self.op.osparams:
self.cluster.osparams = self.new_osp
if self.op.candidate_pool_size is not None:
self.cluster.candidate_pool_size = self.op.candidate_pool_size
......
......@@ -303,6 +303,7 @@ class OpSetClusterParams(OpCode):
"hvparams",
"os_hvp",
"beparams",
"osparams",
"nicparams",
"candidate_pool_size",
"maintain_node_health",
......
......@@ -168,15 +168,29 @@ def ModifyOS(opts, args):
"""
os = args[0]
if opts.hvparams:
os_hvp = {os: dict(opts.hvparams)}
else:
os_hvp = None
if opts.osparams:
osp = {os: opts.osparams}
else:
osp = None
if not (os_hvp or osp):
ToStderr("At least one of OS parameters or hypervisor parameters"
" must be passed")
return 1
op = opcodes.OpSetClusterParams(vg_name=None,
enabled_hypervisors=None,
hvparams=None,
beparams=None,
nicparams=None,
candidate_pool_size=None,
os_hvp={
os: dict(opts.hvparams)
})
os_hvp=os_hvp,
osparams=osp)
SubmitOpCode(op)
return 0
......@@ -184,11 +198,13 @@ def ModifyOS(opts, args):
commands = {
'list': (
ListOS, ARGS_NONE, [NOHDR_OPT], "", "Lists all valid OSes on the master"),
ListOS, ARGS_NONE, [NOHDR_OPT], "", "Lists all valid operating systems"
" on the cluster"),
'diagnose': (
DiagnoseOS, ARGS_NONE, [], "", "Diagnose all OSes"),
DiagnoseOS, ARGS_NONE, [], "", "Diagnose all operating systems"),
'modify': (
ModifyOS, ARGS_ONE_OS, [HVLIST_OPT], "", "Modify os parameters"),
ModifyOS, ARGS_ONE_OS, [HVLIST_OPT, OSPARAMS_OPT], "",
"Modify the OS parameters"),
}
if __name__ == '__main__':
......
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