root / qa / qa_tags.py @ fe508a9d
History | View | Annotate | Download (2 kB)
1 | d74c2ca1 | Michael Hanselmann | # Copyright (C) 2007 Google Inc.
|
---|---|---|---|
2 | d74c2ca1 | Michael Hanselmann | #
|
3 | d74c2ca1 | Michael Hanselmann | # This program is free software; you can redistribute it and/or modify
|
4 | d74c2ca1 | Michael Hanselmann | # it under the terms of the GNU General Public License as published by
|
5 | d74c2ca1 | Michael Hanselmann | # the Free Software Foundation; either version 2 of the License, or
|
6 | d74c2ca1 | Michael Hanselmann | # (at your option) any later version.
|
7 | d74c2ca1 | Michael Hanselmann | #
|
8 | d74c2ca1 | Michael Hanselmann | # This program is distributed in the hope that it will be useful, but
|
9 | d74c2ca1 | Michael Hanselmann | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
10 | d74c2ca1 | Michael Hanselmann | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
11 | d74c2ca1 | Michael Hanselmann | # General Public License for more details.
|
12 | d74c2ca1 | Michael Hanselmann | #
|
13 | d74c2ca1 | Michael Hanselmann | # You should have received a copy of the GNU General Public License
|
14 | d74c2ca1 | Michael Hanselmann | # along with this program; if not, write to the Free Software
|
15 | d74c2ca1 | Michael Hanselmann | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
16 | d74c2ca1 | Michael Hanselmann | # 02110-1301, USA.
|
17 | d74c2ca1 | Michael Hanselmann | |
18 | d74c2ca1 | Michael Hanselmann | |
19 | d74c2ca1 | Michael Hanselmann | """Tags related QA tests.
|
20 | d74c2ca1 | Michael Hanselmann |
|
21 | d74c2ca1 | Michael Hanselmann | """
|
22 | d74c2ca1 | Michael Hanselmann | |
23 | a47f574c | Oleksiy Mishchenko | from ganeti import constants |
24 | d74c2ca1 | Michael Hanselmann | |
25 | a47f574c | Oleksiy Mishchenko | import qa_rapi |
26 | d74c2ca1 | Michael Hanselmann | |
27 | 2f4b4f78 | Iustin Pop | from qa_utils import AssertCommand |
28 | d74c2ca1 | Michael Hanselmann | |
29 | d74c2ca1 | Michael Hanselmann | |
30 | d74c2ca1 | Michael Hanselmann | _TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)] |
31 | d74c2ca1 | Michael Hanselmann | _TEMP_TAG_RE = r'^TEMP-Ganeti-QA-Tag\d+$'
|
32 | d74c2ca1 | Michael Hanselmann | |
33 | a47f574c | Oleksiy Mishchenko | _KIND_TO_COMMAND = { |
34 | a47f574c | Oleksiy Mishchenko | constants.TAG_CLUSTER: "gnt-cluster",
|
35 | a47f574c | Oleksiy Mishchenko | constants.TAG_NODE: "gnt-node",
|
36 | a47f574c | Oleksiy Mishchenko | constants.TAG_INSTANCE: "gnt-instance",
|
37 | fe508a9d | Michael Hanselmann | constants.TAG_NODEGROUP: "gnt-group",
|
38 | a47f574c | Oleksiy Mishchenko | } |
39 | a47f574c | Oleksiy Mishchenko | |
40 | d74c2ca1 | Michael Hanselmann | |
41 | a47f574c | Oleksiy Mishchenko | def _TestTags(kind, name): |
42 | d74c2ca1 | Michael Hanselmann | """Generic function for add-tags.
|
43 | d74c2ca1 | Michael Hanselmann |
|
44 | d74c2ca1 | Michael Hanselmann | """
|
45 | a47f574c | Oleksiy Mishchenko | def cmdfn(subcmd): |
46 | a47f574c | Oleksiy Mishchenko | cmd = [_KIND_TO_COMMAND[kind], subcmd] |
47 | a47f574c | Oleksiy Mishchenko | |
48 | a47f574c | Oleksiy Mishchenko | if kind != constants.TAG_CLUSTER:
|
49 | a47f574c | Oleksiy Mishchenko | cmd.append(name) |
50 | a47f574c | Oleksiy Mishchenko | |
51 | a47f574c | Oleksiy Mishchenko | return cmd
|
52 | a47f574c | Oleksiy Mishchenko | |
53 | 2f4b4f78 | Iustin Pop | for cmd in [ |
54 | 2f4b4f78 | Iustin Pop | cmdfn("add-tags") + _TEMP_TAG_NAMES,
|
55 | 2f4b4f78 | Iustin Pop | cmdfn("list-tags"),
|
56 | 2f4b4f78 | Iustin Pop | ["gnt-cluster", "search-tags", _TEMP_TAG_RE], |
57 | 2f4b4f78 | Iustin Pop | cmdfn("remove-tags") + _TEMP_TAG_NAMES,
|
58 | 2f4b4f78 | Iustin Pop | ]: |
59 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
60 | d74c2ca1 | Michael Hanselmann | |
61 | c326b4ef | Michael Hanselmann | if qa_rapi.Enabled():
|
62 | c326b4ef | Michael Hanselmann | qa_rapi.TestTags(kind, name, _TEMP_TAG_NAMES) |
63 | c326b4ef | Michael Hanselmann | |
64 | d74c2ca1 | Michael Hanselmann | |
65 | d74c2ca1 | Michael Hanselmann | def TestClusterTags(): |
66 | d74c2ca1 | Michael Hanselmann | """gnt-cluster tags"""
|
67 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_CLUSTER, "")
|
68 | d74c2ca1 | Michael Hanselmann | |
69 | d74c2ca1 | Michael Hanselmann | |
70 | d74c2ca1 | Michael Hanselmann | def TestNodeTags(node): |
71 | d74c2ca1 | Michael Hanselmann | """gnt-node tags"""
|
72 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_NODE, node["primary"])
|
73 | d74c2ca1 | Michael Hanselmann | |
74 | d74c2ca1 | Michael Hanselmann | |
75 | fe508a9d | Michael Hanselmann | def TestGroupTags(group): |
76 | fe508a9d | Michael Hanselmann | """gnt-group tags"""
|
77 | fe508a9d | Michael Hanselmann | _TestTags(constants.TAG_NODEGROUP, group) |
78 | fe508a9d | Michael Hanselmann | |
79 | fe508a9d | Michael Hanselmann | |
80 | d74c2ca1 | Michael Hanselmann | def TestInstanceTags(instance): |
81 | d74c2ca1 | Michael Hanselmann | """gnt-instance tags"""
|
82 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_INSTANCE, instance["name"]) |