From 919852dab960fd8c9e091f4d6500c0b246c663fc Mon Sep 17 00:00:00 2001 From: Adeodato Simo <dato@google.com> Date: Fri, 7 Jan 2011 13:26:33 +0000 Subject: [PATCH] Add `gnt-group assign-nodes` in the CLI Signed-off-by: Adeodato Simo <dato@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- lib/client/gnt_group.py | 21 +++++++++++++++++++++ man/gnt-group.rst | 17 ++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py index f4578aac8..9b14c25bb 100644 --- a/lib/client/gnt_group.py +++ b/lib/client/gnt_group.py @@ -50,6 +50,24 @@ def AddGroup(opts, args): SubmitOpCode(op, opts=opts) +def AssignNodes(opts, args): + """Assign nodes to a group. + + @param opts: the command line options selected by the user + @type args: list + @param args: args[0]: group to assign nodes to; args[1:]: nodes to assign + @rtype: int + @return: the desired exit code + + """ + group_name = args[0] + node_names = args[1:] + + op = opcodes.OpAssignGroupNodes(group_name=group_name, nodes=node_names, + force=opts.force) + SubmitOpCode(op, opts=opts) + + def ListGroups(opts, args): """List node groups and their properties. @@ -148,6 +166,9 @@ commands = { "add": ( AddGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT, ALLOC_POLICY_OPT, NODE_PARAMS_OPT], "<group_name>", "Add a new node group to the cluster"), + "assign-nodes": ( + AssignNodes, ARGS_ONE_GROUP + ARGS_MANY_NODES, [DRY_RUN_OPT, FORCE_OPT], + "<group_name> <node>...", "Assign nodes to a group"), "list": ( ListGroups, ARGS_MANY_GROUPS, [NOHDR_OPT, SEP_OPT, FIELDS_OPT], diff --git a/man/gnt-group.rst b/man/gnt-group.rst index 712d38cda..84a2c01ba 100644 --- a/man/gnt-group.rst +++ b/man/gnt-group.rst @@ -29,7 +29,7 @@ ADD | {*group*} Creates a new group with the given name. The node group will be -initially empty. +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 @@ -52,6 +52,21 @@ preferred (this is the default). Note that prioritization among groups in this state will be deferred to the iallocator plugin that's being used. +ASSIGN-NODES +~~~~~~~~~~~~ + +| **assign-nodes** +| [--force] +| {*group*} {*node*...} + +Assigns one or more nodes to the specified group, moving them from their +original group (or groups). + +By default, this command will refuse to proceed if the move would split +between groups any instance that was not previously split (a split +instance is an instance with a mirrored disk template, e.g. DRBD, that +has the primary and secondary nodes in different node groups). You can +force the operation with ``--force``. MODIFY ~~~~~~ -- GitLab