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

gnt-group: Add hv/disk state to add

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent c4929a8b
......@@ -60,9 +60,18 @@ def AddGroup(opts, args):
(group_name,) = args
diskparams = dict(opts.diskparams)
if opts.disk_state:
disk_state = utils.FlatToDict(opts.disk_state)
else:
disk_state = {}
hv_state = dict(opts.hv_state)
op = opcodes.OpGroupAdd(group_name=group_name, ndparams=opts.ndparams,
alloc_policy=opts.alloc_policy,
diskparams=diskparams, ipolicy=ipolicy)
diskparams=diskparams, ipolicy=ipolicy,
hv_state=hv_state,
disk_state=disk_state)
SubmitOpCode(op, opts=opts)
......@@ -279,8 +288,8 @@ INSTANCE_POLICY_OPTS = [
commands = {
"add": (
AddGroup, ARGS_ONE_GROUP,
[DRY_RUN_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, DISK_PARAMS_OPT] +
INSTANCE_POLICY_OPTS,
[DRY_RUN_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT, DISK_PARAMS_OPT,
HV_STATE_OPT, DISK_STATE_OPT] + INSTANCE_POLICY_OPTS,
"<group_name>", "Add a new node group to the cluster"),
"assign-nodes": (
AssignNodes, ARGS_ONE_GROUP + ARGS_MANY_NODES, [DRY_RUN_OPT, FORCE_OPT],
......
......@@ -12786,6 +12786,16 @@ class LUGroupAdd(LogicalUnit):
if self.op.ndparams:
utils.ForceDictType(self.op.ndparams, constants.NDS_PARAMETER_TYPES)
if self.op.hv_state:
self.new_hv_state = _MergeAndVerifyHvState(self.op.hv_state, None)
else:
self.new_hv_state = None
if self.op.disk_state:
self.new_disk_state = _MergeAndVerifyDiskState(self.op.disk_state, None)
else:
self.new_disk_state = None
if self.op.diskparams:
for templ in constants.DISK_TEMPLATES:
if templ not in self.op.diskparams:
......@@ -12823,7 +12833,9 @@ class LUGroupAdd(LogicalUnit):
alloc_policy=self.op.alloc_policy,
ndparams=self.op.ndparams,
diskparams=self.op.diskparams,
ipolicy=self.op.ipolicy)
ipolicy=self.op.ipolicy,
hv_state_static=self.new_hv_state,
disk_state_static=self.new_disk_state)
self.cfg.AddNodeGroup(group_obj, self.proc.GetECId(), check_uuid=False)
del self.remove_locks[locking.LEVEL_NODEGROUP]
......
......@@ -1413,6 +1413,8 @@ class OpGroupAdd(OpCode):
_PNodeGroupAllocPolicy,
_PGroupNodeParams,
_PDiskParams,
_PHvState,
_PDiskState,
("ipolicy", None, ht.TMaybeDict, "Group-wide instance policy specs"),
]
......
......@@ -32,6 +32,8 @@ ADD
| [--specs-disk-size *spec-param*=*value* [,*spec-param*=*value*...]]
| [--specs-mem-size *spec-param*=*value* [,*spec-param*=*value*...]]
| [--specs-nic-count *spec-param*=*value* [,*spec-param*=*value*...]]
| [--disk-state *diskstate*]
| [--hypervisor-state *hvstate*]
| {*group*}
Creates a new group with the given name. The node group will be
......@@ -39,7 +41,8 @@ initially empty; to add nodes to it, use ``gnt-group assign-nodes``.
The ``--node-parameters`` option allows you to set default node
parameters for nodes in the group. Please see **ganeti**(7) for more
information about supported key=value pairs.
information about supported key=value pairs and their corresponding
options.
The ``--alloc-policy`` option allows you to set an allocation policy for
the group at creation time. Possible values are:
......
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