Modify Disk.GetNodes() to support LD_FILE
[ganeti-local] / qa / qa_tags.py
1 #
2 #
3
4 # Copyright (C) 2007 Google Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20
21
22 """Tags related QA tests.
23
24 """
25
26 from ganeti import utils
27
28 import qa_config
29 import qa_utils
30
31 from qa_utils import AssertEqual, StartSSH
32
33
34 _TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)]
35 _TEMP_TAG_RE = r'^TEMP-Ganeti-QA-Tag\d+$'
36
37
38 def _TestTags(cmdfn):
39   """Generic function for add-tags.
40
41   """
42   master = qa_config.GetMasterNode()
43
44   cmd = cmdfn('add-tags') + _TEMP_TAG_NAMES
45   AssertEqual(StartSSH(master['primary'],
46                        utils.ShellQuoteArgs(cmd)).wait(), 0)
47
48   cmd = cmdfn('list-tags')
49   AssertEqual(StartSSH(master['primary'],
50                        utils.ShellQuoteArgs(cmd)).wait(), 0)
51
52   cmd = ['gnt-cluster', 'search-tags', _TEMP_TAG_RE]
53   AssertEqual(StartSSH(master['primary'],
54                        utils.ShellQuoteArgs(cmd)).wait(), 0)
55
56   cmd = cmdfn('remove-tags') + _TEMP_TAG_NAMES
57   AssertEqual(StartSSH(master['primary'],
58                        utils.ShellQuoteArgs(cmd)).wait(), 0)
59
60
61 @qa_utils.DefineHook('tags-cluster')
62 def TestClusterTags():
63   """gnt-cluster tags"""
64   _TestTags(lambda subcmd: ['gnt-cluster', subcmd])
65
66
67 @qa_utils.DefineHook('tags-node')
68 def TestNodeTags(node):
69   """gnt-node tags"""
70   _TestTags(lambda subcmd: ['gnt-node', subcmd, node['primary']])
71
72
73 @qa_utils.DefineHook('tags-instance')
74 def TestInstanceTags(instance):
75   """gnt-instance tags"""
76   _TestTags(lambda subcmd: ['gnt-instance', subcmd, instance['name']])