4 # Copyright (C) 2007 Google Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 """Tags related QA tests.
26 from ganeti import constants
30 from qa_utils import AssertCommand
33 _TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)]
34 _TEMP_TAG_RE = r'^TEMP-Ganeti-QA-Tag\d+$'
37 constants.TAG_CLUSTER: "gnt-cluster",
38 constants.TAG_NODE: "gnt-node",
39 constants.TAG_INSTANCE: "gnt-instance",
40 constants.TAG_NODEGROUP: "gnt-group",
44 def _TestTags(kind, name):
45 """Generic function for add-tags.
49 cmd = [_KIND_TO_COMMAND[kind], subcmd]
51 if kind != constants.TAG_CLUSTER:
57 cmdfn("add-tags") + _TEMP_TAG_NAMES,
59 ["gnt-cluster", "search-tags", _TEMP_TAG_RE],
60 cmdfn("remove-tags") + _TEMP_TAG_NAMES,
65 qa_rapi.TestTags(kind, name, _TEMP_TAG_NAMES)
68 def TestClusterTags():
69 """gnt-cluster tags"""
70 _TestTags(constants.TAG_CLUSTER, "")
73 def TestNodeTags(node):
75 _TestTags(constants.TAG_NODE, node["primary"])
78 def TestGroupTags(group):
80 _TestTags(constants.TAG_NODEGROUP, group)
83 def TestInstanceTags(instance):
84 """gnt-instance tags"""
85 _TestTags(constants.TAG_INSTANCE, instance["name"])