4 # Copyright (C) 2007 Google Inc.
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.
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.
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
22 """Tags related QA tests.
26 from ganeti import utils
31 from qa_utils import AssertEqual, StartSSH
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+$'
39 """Generic function for add-tags.
42 master = qa_config.GetMasterNode()
44 cmd = cmdfn('add-tags') + _TEMP_TAG_NAMES
45 AssertEqual(StartSSH(master['primary'],
46 utils.ShellQuoteArgs(cmd)).wait(), 0)
48 cmd = cmdfn('list-tags')
49 AssertEqual(StartSSH(master['primary'],
50 utils.ShellQuoteArgs(cmd)).wait(), 0)
52 cmd = ['gnt-cluster', 'search-tags', _TEMP_TAG_RE]
53 AssertEqual(StartSSH(master['primary'],
54 utils.ShellQuoteArgs(cmd)).wait(), 0)
56 cmd = cmdfn('remove-tags') + _TEMP_TAG_NAMES
57 AssertEqual(StartSSH(master['primary'],
58 utils.ShellQuoteArgs(cmd)).wait(), 0)
61 @qa_utils.DefineHook('tags-cluster')
62 def TestClusterTags():
63 """gnt-cluster tags"""
64 _TestTags(lambda subcmd: ['gnt-cluster', subcmd])
67 @qa_utils.DefineHook('tags-node')
68 def TestNodeTags(node):
70 _TestTags(lambda subcmd: ['gnt-node', subcmd, node['primary']])
73 @qa_utils.DefineHook('tags-instance')
74 def TestInstanceTags(instance):
75 """gnt-instance tags"""
76 _TestTags(lambda subcmd: ['gnt-instance', subcmd, instance['name']])