From 819cbfe57eb37d9ac9c2287e45ce64035b05de0b Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 21 Apr 2011 11:25:56 +0200 Subject: [PATCH] gnt-group: Add commands for tagging groups Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/cli.py | 4 +++- lib/client/gnt_group.py | 16 ++++++++++++++-- man/gnt-group.rst | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/lib/cli.py b/lib/cli.py index c70e437af..6a5c08354 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -360,7 +360,9 @@ def _ExtractTagsObject(opts, args): kind = opts.tag_type if kind == constants.TAG_CLUSTER: retval = kind, kind - elif kind == constants.TAG_NODE or kind == constants.TAG_INSTANCE: + elif kind in (constants.TAG_NODEGROUP, + constants.TAG_NODE, + constants.TAG_INSTANCE): if not args: raise errors.OpPrereqError("no arguments passed to the command") name = args.pop(0) diff --git a/lib/client/gnt_group.py b/lib/client/gnt_group.py index 23d2d3876..082d0bf4f 100644 --- a/lib/client/gnt_group.py +++ b/lib/client/gnt_group.py @@ -209,8 +209,20 @@ commands = { "rename": ( RenameGroup, [ArgGroup(min=2, max=2)], [DRY_RUN_OPT], "[--dry-run] <group-name> <new-name>", "Rename a node group"), -} + "list-tags": ( + ListTags, ARGS_ONE_GROUP, [PRIORITY_OPT], + "<instance_name>", "List the tags of the given instance"), + "add-tags": ( + AddTags, [ArgGroup(min=1, max=1), ArgUnknown()], + [TAG_SRC_OPT, PRIORITY_OPT], + "<instance_name> tag...", "Add tags to the given instance"), + "remove-tags": ( + RemoveTags, [ArgGroup(min=1, max=1), ArgUnknown()], + [TAG_SRC_OPT, PRIORITY_OPT], + "<instance_name> tag...", "Remove tags from given instance"), + } def Main(): - return GenericMain(commands) + return GenericMain(commands, + override={"tag_type": constants.TAG_NODEGROUP}) diff --git a/man/gnt-group.rst b/man/gnt-group.rst index 068ef4a7a..2569bc023 100644 --- a/man/gnt-group.rst +++ b/man/gnt-group.rst @@ -137,6 +137,45 @@ RENAME Renames a given group from *oldname* to *newname*. + +TAGS +~~~~ + +ADD-TAGS +^^^^^^^^ + +**add-tags** [--from *file*] {*groupname*} {*tag*...} + +Add tags to the given node group. If any of the tags contains invalid +characters, the entire operation will abort. + +If the ``--from`` option is given, the list of tags will be extended +with the contents of that file (each line becomes a tag). In this case, +there is not need to pass tags on the command line (if you do, both +sources will be used). A file name of ``-`` will be interpreted as +stdin. + +LIST-TAGS +^^^^^^^^^ + +**list-tags** {*groupname*} + +List the tags of the given node group. + +REMOVE-TAGS +^^^^^^^^^^^ + +**remove-tags** [--from *file*] {*groupname*} {*tag*...} + +Remove tags from the given node group. If any of the tags are not +existing on the node, the entire operation will abort. + +If the ``--from`` option is given, the list of tags to be removed will +be extended with the contents of that file (each line becomes a tag). In +this case, there is not need to pass tags on the command line (if you +do, tags from both sources will be removed). A file name of ``-`` will +be interpreted as stdin. + .. vim: set textwidth=72 : .. Local Variables: .. mode: rst -- GitLab