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",
37 constants.TAG_NODEGROUP: "gnt-group",
41 def _TestTags(kind, name):
42 """Generic function for add-tags.
46 cmd = [_KIND_TO_COMMAND[kind], subcmd]
48 if kind != constants.TAG_CLUSTER:
54 cmdfn("add-tags") + _TEMP_TAG_NAMES,
56 ["gnt-cluster", "search-tags", _TEMP_TAG_RE],
57 cmdfn("remove-tags") + _TEMP_TAG_NAMES,
62 qa_rapi.TestTags(kind, name, _TEMP_TAG_NAMES)
65 def TestClusterTags():
66 """gnt-cluster tags"""
67 _TestTags(constants.TAG_CLUSTER, "")
70 def TestNodeTags(node):
72 _TestTags(constants.TAG_NODE, node["primary"])
75 def TestGroupTags(group):
77 _TestTags(constants.TAG_NODEGROUP, group)
80 def TestInstanceTags(instance):
81 """gnt-instance tags"""
82 _TestTags(constants.TAG_INSTANCE, instance["name"])