gnt-group: Add commands for tagging groups
authorMichael Hanselmann <hansmi@google.com>
Thu, 21 Apr 2011 09:25:56 +0000 (11:25 +0200)
committerMichael Hanselmann <hansmi@google.com>
Thu, 21 Apr 2011 13:08:35 +0000 (15:08 +0200)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/cli.py
lib/client/gnt_group.py
man/gnt-group.rst

index c70e437..6a5c083 100644 (file)
@@ -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)
index 23d2d38..082d0bf 100644 (file)
@@ -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})
index 068ef4a..2569bc0 100644 (file)
@@ -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