Statistics
| Branch: | Tag: | Revision:

root / qa / qa_group.py @ 66787da5

History | View | Annotate | Download (2.1 kB)

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
import qa_config
23
from qa_utils import AssertCommand
24

    
25

    
26
def TestGroupAddRemoveRename():
27
  """gnt-group add/remove/rename"""
28
  groups = qa_config.get("groups", {})
29

    
30
  existing_group_with_nodes = groups.get("group-with-nodes", "default")
31
  group1, group2, group3 = groups.get("inexistent-groups",
32
                                      ["group1", "group2", "group3"])[:3]
33

    
34
  AssertCommand(["gnt-group", "add", group1])
35
  AssertCommand(["gnt-group", "add", group2])
36
  AssertCommand(["gnt-group", "add", group2], fail=True)
37
  AssertCommand(["gnt-group", "add", existing_group_with_nodes], fail=True)
38

    
39
  AssertCommand(["gnt-group", "rename", group1, group2], fail=True)
40
  AssertCommand(["gnt-group", "rename", group1, group3])
41

    
42
  try:
43
    AssertCommand(["gnt-group", "rename", existing_group_with_nodes, group1])
44

    
45
    AssertCommand(["gnt-group", "remove", group2])
46
    AssertCommand(["gnt-group", "remove", group3])
47
    AssertCommand(["gnt-group", "remove", group1], fail=True)
48
  finally:
49
    # Try to ensure idempotency re groups that already existed.
50
    AssertCommand(["gnt-group", "rename", group1, existing_group_with_nodes])
51

    
52

    
53
def TestGroupListDefaultFields():
54
  """gnt-group list"""
55
  AssertCommand(["gnt-group", "list"])
56

    
57

    
58
def TestGroupListAllFields():
59
  """gnt-group list -o FIELDS"""
60
  AssertCommand(["gnt-group", "list", "-o",
61
                 "name,uuid,node_cnt,node_list,pinst_cnt,pinst_list"])