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