lvmstrap: add support for non-partitioned md disks
[ganeti-local] / qa / qa_group.py
1 #
2 #
3
4 # Copyright (C) 2010 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 from ganeti import constants
23
24 import qa_config
25 from qa_utils import AssertCommand
26
27
28 def TestGroupAddRemoveRename():
29   """gnt-group add/remove/rename"""
30   groups = qa_config.get("groups", {})
31
32   existing_group_with_nodes = groups.get("group-with-nodes",
33                                          constants.INITIAL_NODE_GROUP_NAME)
34   group1, group2, group3 = groups.get("inexistent-groups",
35                                       ["group1", "group2", "group3"])[:3]
36
37   AssertCommand(["gnt-group", "add", group1])
38   AssertCommand(["gnt-group", "add", group2])
39   AssertCommand(["gnt-group", "add", group2], fail=True)
40   AssertCommand(["gnt-group", "add", existing_group_with_nodes], fail=True)
41
42   AssertCommand(["gnt-group", "rename", group1, group2], fail=True)
43   AssertCommand(["gnt-group", "rename", group1, group3])
44
45   try:
46     AssertCommand(["gnt-group", "rename", existing_group_with_nodes, group1])
47
48     AssertCommand(["gnt-group", "remove", group2])
49     AssertCommand(["gnt-group", "remove", group3])
50     AssertCommand(["gnt-group", "remove", group1], fail=True)
51   finally:
52     # Try to ensure idempotency re groups that already existed.
53     AssertCommand(["gnt-group", "rename", group1, existing_group_with_nodes])
54
55
56 def TestGroupAddWithOptions():
57   """gnt-group add with options"""
58   groups = qa_config.get("groups", {})
59   group1 = groups.get("inexistent-groups", ["group1"])[0]
60
61   AssertCommand(["gnt-group", "add", "--alloc-policy", "notvalid", group1],
62                 fail=True)
63
64   AssertCommand(["gnt-group", "add", "--alloc-policy", "last_resort",
65                  "--node-parameters", "oob_program=/bin/true", group1])
66
67   AssertCommand(["gnt-group", "remove", group1])
68
69
70 def TestGroupModify():
71   """gnt-group modify"""
72   groups = qa_config.get("groups", {})
73   group1 = groups.get("inexistent-groups", ["group1"])[0]
74
75   AssertCommand(["gnt-group", "add", group1])
76
77   try:
78     AssertCommand(["gnt-group", "modify", "--alloc-policy", "unallocable",
79                    "--node-parameters", "oob_program=/bin/false", group1])
80     AssertCommand(["gnt-group", "modify",
81                    "--alloc-policy", "notvalid", group1], fail=True)
82   finally:
83     AssertCommand(["gnt-group", "remove", group1])
84
85
86 def TestGroupListDefaultFields():
87   """gnt-group list"""
88   AssertCommand(["gnt-group", "list"])
89
90
91 def TestGroupListAllFields():
92   """gnt-group list -o FIELDS"""
93   AssertCommand(["gnt-group", "list", "-o",
94                  "name,uuid,node_cnt,node_list,pinst_cnt,pinst_list"])