gnt-group: Add hv/disk state to add
authorRené Nussbaumer <rn@google.com>
Thu, 8 Dec 2011 11:43:16 +0000 (12:43 +0100)
committerRené Nussbaumer <rn@google.com>
Fri, 16 Dec 2011 08:30:31 +0000 (09:30 +0100)
Signed-off-by: René Nussbaumer <rn@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>

lib/client/gnt_group.py
lib/cmdlib.py
lib/opcodes.py
man/gnt-group.rst

index e1e3925..8cde11e 100644 (file)
@@ -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],
index 04d26f9..9772a44 100644 (file)
@@ -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]
index 372efea..782a938 100644 (file)
@@ -1413,6 +1413,8 @@ class OpGroupAdd(OpCode):
     _PNodeGroupAllocPolicy,
     _PGroupNodeParams,
     _PDiskParams,
+    _PHvState,
+    _PDiskState,
     ("ipolicy", None, ht.TMaybeDict, "Group-wide instance policy specs"),
     ]
 
index d6154f8..977b3c3 100644 (file)
@@ -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: