Commit 819cbfe5 authored by Michael Hanselmann's avatar Michael Hanselmann

gnt-group: Add commands for tagging groups

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 1ffd2673
......@@ -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)
......
......@@ -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})
......@@ -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
......
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