Signed-off-by: Adeodato Simo <[email protected]>
---
lib/client/gnt_group.py | 4 ++--
lib/cmdlib.py | 7 ++++++-
lib/opcodes.py | 5 ++++-
man/gnt-group.rst | 8 +++++++-
4 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py
index 9ddd499..545f0d2 100644
--- a/lib/client/gnt_group.py
+++ b/lib/client/gnt_group.py
@@ -54,7 +54,7 @@ def AddGroup(opts, args):
"""
(group_name,) = args
- op = opcodes.OpAddGroup(group_name=group_name)
+ op = opcodes.OpAddGroup(group_name=group_name, ndparams=opts.ndparams)
SubmitOpCode(op, opts=opts)
@@ -137,7 +137,7 @@ def RenameGroup(opts, args):
commands = {
"add": (
- AddGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT],
+ AddGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT, NODE_PARAMS_OPT],
"<group_name>", "Add a new node group to the cluster"),
"list": (
ListGroups, ARGS_MANY_GROUPS,
diff --git a/lib/cmdlib.py b/lib/cmdlib.py
index be09c76..50e0be0 100644
--- a/lib/cmdlib.py
+++ b/lib/cmdlib.py
@@ -10368,6 +10368,7 @@ class LUAddGroup(LogicalUnit):
_OP_PARAMS = [
_PGroupName,
+ ("ndparams", None, ht.TOr(ht.TDict, ht.TNone)),
]
REQ_BGL = False
@@ -10397,6 +10398,9 @@ class LUAddGroup(LogicalUnit):
(self.op.group_name, existing_uuid),
errors.ECODE_EXISTS)
+ if self.op.ndparams:
+ utils.ForceDictType(self.op.ndparams, constants.NDS_PARAMETER_TYPES)
+
def BuildHooksEnv(self):
"""Build hooks env.
@@ -10412,7 +10416,8 @@ class LUAddGroup(LogicalUnit):
"""
group_obj = objects.NodeGroup(name=self.op.group_name, members=[],
- uuid=self.group_uuid)
+ uuid=self.group_uuid,
+ ndparams=self.op.ndparams)
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 7fdd7b5..577604f 100644
--- a/lib/opcodes.py
+++ b/lib/opcodes.py
@@ -724,7 +724,10 @@ class OpAddGroup(OpCode):
"""Add a node group to the cluster."""
OP_ID = "OP_GROUP_ADD"
OP_DSC_FIELD = "group_name"
- __slots__ = ["group_name"]
+ __slots__ = [
+ "group_name",
+ "ndparams",
+ ]
class OpQueryGroups(OpCode):
diff --git a/man/gnt-group.rst b/man/gnt-group.rst
index e43a8b9..777b0d2 100644
--- a/man/gnt-group.rst
+++ b/man/gnt-group.rst
@@ -23,11 +23,17 @@ COMMANDS
ADD
~~~
-| **add** {*group*}
+| **add**
+| [--node-parameters=*NDPARAMS*]
+| {*group*}
Creates a new group with the given name. The node group will be
initially empty.
+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.
+
REMOVE
~~~~~~
--
1.7.3.1