From e4c03256a608b64421258ea50f60d6fa032ef0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com> Date: Thu, 8 Dec 2011 12:43:16 +0100 Subject: [PATCH] gnt-group: Add hv/disk state to add MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: RenΓ© Nussbaumer <rn@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/client/gnt_group.py | 15 ++++++++++++--- lib/cmdlib.py | 14 +++++++++++++- lib/opcodes.py | 2 ++ man/gnt-group.rst | 5 ++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py index e1e39257e..8cde11ed6 100644 --- a/lib/client/gnt_group.py +++ b/lib/client/gnt_group.py @@ -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], diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 04d26f95b..9772a44d0 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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] diff --git a/lib/opcodes.py b/lib/opcodes.py index 372efea7b..782a938e8 100644 --- a/lib/opcodes.py +++ b/lib/opcodes.py @@ -1413,6 +1413,8 @@ class OpGroupAdd(OpCode): _PNodeGroupAllocPolicy, _PGroupNodeParams, _PDiskParams, + _PHvState, + _PDiskState, ("ipolicy", None, ht.TMaybeDict, "Group-wide instance policy specs"), ] diff --git a/man/gnt-group.rst b/man/gnt-group.rst index d6154f885..977b3c3e9 100644 --- a/man/gnt-group.rst +++ b/man/gnt-group.rst @@ -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: -- GitLab