1 # Copyright (C) 2007 Google Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 """Tags related QA tests.
23 from ganeti import constants
27 from qa_utils import AssertCommand
30 _TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)]
31 _TEMP_TAG_RE = r'^TEMP-Ganeti-QA-Tag\d+$'
34 constants.TAG_CLUSTER: "gnt-cluster",
35 constants.TAG_NODE: "gnt-node",
36 constants.TAG_INSTANCE: "gnt-instance",
40 def _TestTags(kind, name):
41 """Generic function for add-tags.
45 cmd = [_KIND_TO_COMMAND[kind], subcmd]
47 if kind != constants.TAG_CLUSTER:
53 cmdfn("add-tags") + _TEMP_TAG_NAMES,
55 ["gnt-cluster", "search-tags", _TEMP_TAG_RE],
56 cmdfn("remove-tags") + _TEMP_TAG_NAMES,
61 qa_rapi.TestTags(kind, name, _TEMP_TAG_NAMES)
64 def TestClusterTags():
65 """gnt-cluster tags"""
66 _TestTags(constants.TAG_CLUSTER, "")
69 def TestNodeTags(node):
71 _TestTags(constants.TAG_NODE, node["primary"])
74 def TestInstanceTags(instance):
75 """gnt-instance tags"""
76 _TestTags(constants.TAG_INSTANCE, instance["name"])