4 # Copyright (C) 2010 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 from ganeti import constants
25 from qa_utils import AssertCommand
28 def TestGroupAddRemoveRename():
29 """gnt-group add/remove/rename"""
30 groups = qa_config.get("groups", {})
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]
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)
42 AssertCommand(["gnt-group", "rename", group1, group2], fail=True)
43 AssertCommand(["gnt-group", "rename", group1, group3])
46 AssertCommand(["gnt-group", "rename", existing_group_with_nodes, group1])
48 AssertCommand(["gnt-group", "remove", group2])
49 AssertCommand(["gnt-group", "remove", group3])
50 AssertCommand(["gnt-group", "remove", group1], fail=True)
52 # Try to ensure idempotency re groups that already existed.
53 AssertCommand(["gnt-group", "rename", group1, existing_group_with_nodes])
56 def TestGroupAddWithOptions():
57 """gnt-group add with options"""
58 groups = qa_config.get("groups", {})
59 group1 = groups.get("inexistent-groups", ["group1"])[0]
61 AssertCommand(["gnt-group", "add", "--alloc-policy", "notvalid", group1],
64 AssertCommand(["gnt-group", "add", "--alloc-policy", "last_resort",
65 "--node-parameters", "oob_program=/bin/true", group1])
67 AssertCommand(["gnt-group", "remove", group1])
70 def TestGroupModify():
71 """gnt-group modify"""
72 groups = qa_config.get("groups", {})
73 group1 = groups.get("inexistent-groups", ["group1"])[0]
75 AssertCommand(["gnt-group", "add", group1])
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)
83 AssertCommand(["gnt-group", "remove", group1])
86 def TestGroupListDefaultFields():
88 AssertCommand(["gnt-group", "list"])
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"])