diff --git a/doc/design-2.3.rst b/doc/design-2.3.rst index 31fd3cc3d4e8db13e48afdce46235c773a2fa8a7..debcd40bdb1e2e99fd6ba04a82954721e716294a 100644 --- a/doc/design-2.3.rst +++ b/doc/design-2.3.rst @@ -52,7 +52,7 @@ To manage node groups and the nodes belonging to them, the following new commands and flags will be introduced:: gnt-group add <group> # add a new node group - gnt-group del <group> # delete an empty node group + gnt-group remove <group> # delete an empty node group gnt-group list # list node groups gnt-group rename <oldname> <newname> # rename a node group gnt-node {list,info} -g <group> # list only nodes belonging to a node group diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py index 5477b1105702dd780ff493a0a5fe8e9b627053be..9ddd499a2734b9b7de1a29366bc34c083c9d683e 100644 --- a/lib/client/gnt_group.py +++ b/lib/client/gnt_group.py @@ -26,6 +26,7 @@ from ganeti.cli import * from ganeti import compat +from ganeti import opcodes from ganeti import utils @@ -42,6 +43,21 @@ _LIST_HEADERS = { } +def AddGroup(opts, args): + """Add a node group to the cluster. + + @param opts: the command line options selected by the user + @type args: list + @param args: a list of length 1 with the name of the group to create + @rtype: int + @return: the desired exit code + + """ + (group_name,) = args + op = opcodes.OpAddGroup(group_name=group_name) + SubmitOpCode(op, opts=opts) + + def ListGroups(opts, args): """List node groups and their properties. @@ -89,7 +105,40 @@ def ListGroups(opts, args): return 0 +def RemoveGroup(opts, args): + """Remove a node group from the cluster. + + @param opts: the command line options selected by the user + @type args: list + @param args: a list of length 1 with the name of the group to remove + @rtype: int + @return: the desired exit code + + """ + (group_name,) = args + op = opcodes.OpRemoveGroup(group_name=group_name) + SubmitOpCode(op, opts=opts) + + +def RenameGroup(opts, args): + """Rename a node group. + + @param opts: the command line options selected by the user + @type args: list + @param args: a list of length 2, [old_name, new_name] + @rtype: int + @return: the desired exit code + + """ + old_name, new_name = args + op = opcodes.OpRenameGroup(old_name=old_name, new_name=new_name) + SubmitOpCode(op, opts=opts) + + commands = { + "add": ( + AddGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT], + "<group_name>", "Add a new node group to the cluster"), "list": ( ListGroups, ARGS_MANY_GROUPS, [NOHDR_OPT, SEP_OPT, FIELDS_OPT, SYNC_OPT, ROMAN_OPT], @@ -97,6 +146,13 @@ commands = { "Lists the node groups in the cluster. The available fields are (see" " the man page for details): %s. The default list is (in order): %s." % (utils.CommaJoin(_LIST_HEADERS), utils.CommaJoin(_LIST_DEF_FIELDS))), + "remove": ( + RemoveGroup, ARGS_ONE_GROUP, [DRY_RUN_OPT], + "[--dry-run] <group_name>", + "Remove an (empty) node group from the cluster"), + "rename": ( + RenameGroup, [ArgGroup(min=2, max=2)], [DRY_RUN_OPT], + "[--dry-run] <old_name> <new_name>", "Rename a node group"), } diff --git a/man/gnt-group.rst b/man/gnt-group.rst index 086d6489abc76f2e9686cf2fb2a7e137a6a01bcb..e43a8b9d773cf36fb260f7b274f1b4eb9efe1d92 100644 --- a/man/gnt-group.rst +++ b/man/gnt-group.rst @@ -20,6 +20,21 @@ the Ganeti system. COMMANDS -------- +ADD +~~~ + +| **add** {*group*} + +Creates a new group with the given name. The node group will be +initially empty. + +REMOVE +~~~~~~ + +| **remove** {*group*} + +Deletes the indicated node group, which must be empty. + LIST ~~~~ @@ -78,3 +93,10 @@ serial_no If no group names are given, then all groups are included. Otherwise, only the named groups will be listed. + +RENAME +~~~~~~ + +| **rename** {*oldname*} {*newname*} + +Renames a given group from *oldname* to *newname*.