Commit 483be60d authored by Adeodato Simo's avatar Adeodato Simo
Browse files

Introduce OpAddGroup.ndparams and expose in CLI


Signed-off-by: default avatarAdeodato Simo <dato@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 907af698
...@@ -54,7 +54,7 @@ def AddGroup(opts, args): ...@@ -54,7 +54,7 @@ def AddGroup(opts, args):
""" """
(group_name,) = 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) SubmitOpCode(op, opts=opts)
...@@ -137,7 +137,7 @@ def RenameGroup(opts, args): ...@@ -137,7 +137,7 @@ def RenameGroup(opts, args):
commands = { commands = {
"add": ( "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"), "<group_name>", "Add a new node group to the cluster"),
"list": ( "list": (
ListGroups, ARGS_MANY_GROUPS, ListGroups, ARGS_MANY_GROUPS,
......
...@@ -10178,6 +10178,7 @@ class LUAddGroup(LogicalUnit): ...@@ -10178,6 +10178,7 @@ class LUAddGroup(LogicalUnit):
_OP_PARAMS = [ _OP_PARAMS = [
_PGroupName, _PGroupName,
("ndparams", None, ht.TOr(ht.TDict, ht.TNone)),
] ]
REQ_BGL = False REQ_BGL = False
...@@ -10207,6 +10208,9 @@ class LUAddGroup(LogicalUnit): ...@@ -10207,6 +10208,9 @@ class LUAddGroup(LogicalUnit):
(self.op.group_name, existing_uuid), (self.op.group_name, existing_uuid),
errors.ECODE_EXISTS) errors.ECODE_EXISTS)
if self.op.ndparams:
utils.ForceDictType(self.op.ndparams, constants.NDS_PARAMETER_TYPES)
def BuildHooksEnv(self): def BuildHooksEnv(self):
"""Build hooks env. """Build hooks env.
...@@ -10222,7 +10226,8 @@ class LUAddGroup(LogicalUnit): ...@@ -10222,7 +10226,8 @@ class LUAddGroup(LogicalUnit):
""" """
group_obj = objects.NodeGroup(name=self.op.group_name, members=[], 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) self.cfg.AddNodeGroup(group_obj, self.proc.GetECId(), check_uuid=False)
del self.remove_locks[locking.LEVEL_NODEGROUP] del self.remove_locks[locking.LEVEL_NODEGROUP]
......
...@@ -725,7 +725,10 @@ class OpAddGroup(OpCode): ...@@ -725,7 +725,10 @@ class OpAddGroup(OpCode):
"""Add a node group to the cluster.""" """Add a node group to the cluster."""
OP_ID = "OP_GROUP_ADD" OP_ID = "OP_GROUP_ADD"
OP_DSC_FIELD = "group_name" OP_DSC_FIELD = "group_name"
__slots__ = ["group_name"] __slots__ = [
"group_name",
"ndparams",
]
class OpQueryGroups(OpCode): class OpQueryGroups(OpCode):
......
...@@ -23,11 +23,17 @@ COMMANDS ...@@ -23,11 +23,17 @@ COMMANDS
ADD ADD
~~~ ~~~
| **add** {*group*} | **add**
| [--node-parameters=*NDPARAMS*]
| {*group*}
Creates a new group with the given name. The node group will be Creates a new group with the given name. The node group will be
initially empty. 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 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