Commit a8282327 authored by René Nussbaumer's avatar René Nussbaumer

gnt-group: Allow modify disk/hv state

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 0ec2ce46
......@@ -135,15 +135,24 @@ def SetGroupParams(opts, args):
@return: the desired exit code
"""
if (opts.ndparams is None and opts.alloc_policy is None
and not opts.diskparams):
if (opts.ndparams is None and opts.alloc_policy is None and
not (opts.hv_state or opts.disk_state)):
ToStderr("Please give at least one of the parameters.")
return 1
if opts.disk_state:
disk_state = utils.FlatToDict(opts.disk_state)
else:
disk_state = {}
hv_state = dict(opts.hv_state)
diskparams = dict(opts.diskparams)
op = opcodes.OpGroupSetParams(group_name=args[0],
ndparams=opts.ndparams,
alloc_policy=opts.alloc_policy,
hv_state=hv_state,
disk_state=disk_state,
diskparams=diskparams)
result = SubmitOrSend(op, opts)
......@@ -237,8 +246,8 @@ commands = {
"Lists all available fields for node groups"),
"modify": (
SetGroupParams, ARGS_ONE_GROUP,
[DRY_RUN_OPT, SUBMIT_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT,
DISK_PARAMS_OPT],
[DRY_RUN_OPT, SUBMIT_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, HV_STATE_OPT,
DISK_STATE_OPT, DISK_PARAMS_OPT],
"<group_name>", "Alters the parameters of a node group"),
"remove": (
RemoveGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT],
......
......@@ -12955,6 +12955,8 @@ class LUGroupSetParams(LogicalUnit):
self.op.ndparams,
self.op.diskparams,
self.op.alloc_policy,
self.op.hv_state,
self.op.disk_state
]
if all_changes.count(None) == len(all_changes):
......@@ -12994,6 +12996,15 @@ class LUGroupSetParams(LogicalUnit):
utils.ForceDictType(new_templ_params, constants.DISK_DT_TYPES)
self.new_diskparams[templ] = new_templ_params
if self.op.hv_state:
self.new_hv_state = _MergeAndVerifyHvState(self.op.hv_state,
self.group.hv_state_static)
if self.op.disk_state:
self.new_disk_state = \
_MergeAndVerifyDiskState(self.op.disk_state,
self.group.disk_state_static)
def BuildHooksEnv(self):
"""Build hooks env.
......@@ -13027,6 +13038,12 @@ class LUGroupSetParams(LogicalUnit):
if self.op.alloc_policy:
self.group.alloc_policy = self.op.alloc_policy
if self.op.hv_state:
self.group.hv_state_static = self.new_hv_state
if self.op.disk_state:
self.group.disk_state_static = self.new_disk_state
self.cfg.Update(self.group, feedback_fn)
return result
......
......@@ -1145,6 +1145,8 @@ class NodeGroup(TaggableObject):
"ndparams",
"diskparams",
"serial_no",
"hv_state_static",
"disk_state_static",
"alloc_policy",
] + _TIMESTAMPS + _UUID
......
......@@ -1440,6 +1440,8 @@ class OpGroupSetParams(OpCode):
_PNodeGroupAllocPolicy,
_PGroupNodeParams,
_PDiskParams,
_PHvState,
_PDiskState,
]
OP_RESULT = _TSetParamsResult
......
......@@ -74,12 +74,15 @@ MODIFY
| **modify**
| [--node-parameters=*NDPARAMS*]
| [--alloc-policy=*POLICY*]
| [--hypervisor-state *hvstate*]
| [--disk-state *diskstate*]
| {*group*}
Modifies some parameters from the node group.
The ``--node-parameters`` and ``--alloc-policy`` optiosn are documented
in the **add** command above.
The ``--node-parameters`` and ``--alloc-policy`` options are documented
in the **add** command above. ``--hypervisor-state`` as well as
``--disk-state`` are documented in detail in **ganeti**(7).
REMOVE
~~~~~~
......
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