root / qa / qa_tags.py @ 2237687b
History | View | Annotate | Download (1.9 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 | a47f574c | Oleksiy Mishchenko | } |
38 | a47f574c | Oleksiy Mishchenko | |
39 | d74c2ca1 | Michael Hanselmann | |
40 | a47f574c | Oleksiy Mishchenko | def _TestTags(kind, name): |
41 | d74c2ca1 | Michael Hanselmann | """Generic function for add-tags.
|
42 | d74c2ca1 | Michael Hanselmann |
|
43 | d74c2ca1 | Michael Hanselmann | """
|
44 | a47f574c | Oleksiy Mishchenko | def cmdfn(subcmd): |
45 | a47f574c | Oleksiy Mishchenko | cmd = [_KIND_TO_COMMAND[kind], subcmd] |
46 | a47f574c | Oleksiy Mishchenko | |
47 | a47f574c | Oleksiy Mishchenko | if kind != constants.TAG_CLUSTER:
|
48 | a47f574c | Oleksiy Mishchenko | cmd.append(name) |
49 | a47f574c | Oleksiy Mishchenko | |
50 | a47f574c | Oleksiy Mishchenko | return cmd
|
51 | a47f574c | Oleksiy Mishchenko | |
52 | 2f4b4f78 | Iustin Pop | for cmd in [ |
53 | 2f4b4f78 | Iustin Pop | cmdfn("add-tags") + _TEMP_TAG_NAMES,
|
54 | 2f4b4f78 | Iustin Pop | cmdfn("list-tags"),
|
55 | 2f4b4f78 | Iustin Pop | ["gnt-cluster", "search-tags", _TEMP_TAG_RE], |
56 | 2f4b4f78 | Iustin Pop | cmdfn("remove-tags") + _TEMP_TAG_NAMES,
|
57 | 2f4b4f78 | Iustin Pop | ]: |
58 | 2f4b4f78 | Iustin Pop | AssertCommand(cmd) |
59 | d74c2ca1 | Michael Hanselmann | |
60 | c326b4ef | Michael Hanselmann | if qa_rapi.Enabled():
|
61 | c326b4ef | Michael Hanselmann | qa_rapi.TestTags(kind, name, _TEMP_TAG_NAMES) |
62 | c326b4ef | Michael Hanselmann | |
63 | d74c2ca1 | Michael Hanselmann | |
64 | d74c2ca1 | Michael Hanselmann | def TestClusterTags(): |
65 | d74c2ca1 | Michael Hanselmann | """gnt-cluster tags"""
|
66 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_CLUSTER, "")
|
67 | d74c2ca1 | Michael Hanselmann | |
68 | d74c2ca1 | Michael Hanselmann | |
69 | d74c2ca1 | Michael Hanselmann | def TestNodeTags(node): |
70 | d74c2ca1 | Michael Hanselmann | """gnt-node tags"""
|
71 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_NODE, node["primary"])
|
72 | d74c2ca1 | Michael Hanselmann | |
73 | d74c2ca1 | Michael Hanselmann | |
74 | d74c2ca1 | Michael Hanselmann | def TestInstanceTags(instance): |
75 | d74c2ca1 | Michael Hanselmann | """gnt-instance tags"""
|
76 | a47f574c | Oleksiy Mishchenko | _TestTags(constants.TAG_INSTANCE, instance["name"]) |