1 # Copyright (C) 2007 Google Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 """Tags related QA tests.
23 from ganeti import utils
28 from qa_utils import AssertEqual, StartSSH
31 _TEMP_TAG_NAMES = ["TEMP-Ganeti-QA-Tag%d" % i for i in range(3)]
32 _TEMP_TAG_RE = r'^TEMP-Ganeti-QA-Tag\d+$'
36 """Generic function for add-tags.
39 master = qa_config.GetMasterNode()
41 cmd = cmdfn('add-tags') + _TEMP_TAG_NAMES
42 AssertEqual(StartSSH(master['primary'],
43 utils.ShellQuoteArgs(cmd)).wait(), 0)
45 cmd = cmdfn('list-tags')
46 AssertEqual(StartSSH(master['primary'],
47 utils.ShellQuoteArgs(cmd)).wait(), 0)
49 cmd = ['gnt-cluster', 'search-tags', _TEMP_TAG_RE]
50 AssertEqual(StartSSH(master['primary'],
51 utils.ShellQuoteArgs(cmd)).wait(), 0)
53 cmd = cmdfn('remove-tags') + _TEMP_TAG_NAMES
54 AssertEqual(StartSSH(master['primary'],
55 utils.ShellQuoteArgs(cmd)).wait(), 0)
58 def TestClusterTags():
59 """gnt-cluster tags"""
60 _TestTags(lambda subcmd: ['gnt-cluster', subcmd])
63 def TestNodeTags(node):
65 _TestTags(lambda subcmd: ['gnt-node', subcmd, node['primary']])
68 def TestInstanceTags(instance):
69 """gnt-instance tags"""
70 _TestTags(lambda subcmd: ['gnt-instance', subcmd, instance['name']])