aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests/cpupool/02_cpupool_manage_pos.py
blob: a58cd887c1d1fc0a924105013ab1b9ef0681604c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/usr/bin/python

# Description:
# Verify commands pool-new and pool-delete.
#
import sys
import re
import time

from XmTestLib import *
from pools import *

checkRequirements()

#
# Check output of xm pool-list (of Pool-0)
#
status, output = traceCommand("xm pool-list Pool-0")
if status != 0:
    FAIL("xm pool-list failed, rc %s" % status)
lines = output.splitlines()
if len(lines) != 2:
    FAIL("Wrong output of xm pool-list Pool-0 (%s)" % lines)
if not re.search("Pool-0 +[0-9]+ +credit +y +[0-9]", lines[1]):
    FAIL("Wrong output of xm pool-list Pool-0 (%s)" % lines)

#
# Check output of xm pool-list -l (of Pool-0)
#
status, output = traceCommand("xm pool-list Pool-0 -l")
if status != 0:
    FAIL("xm pool-list failed, rc %s" % status)
if not re.search("name_label Pool-0", output):
    FAIL("Wrong output of xm pool-list Pool-0 -l; missing 'name_label'")
if not re.search("started_VMs 00000000-0000-0000-0000-000000000000", output):
    FAIL("Wrong output of xm pool-list Pool-0 -l; missing 'started_VMs'")
if not re.search("started_VM_names Domain-0", output):
    FAIL("Wrong output of xm pool-list Pool-0 -l; missing 'started_VMi_names'")


#
# Create a pool from pool1.cfg
#
cmd = "xm pool-new pool1.cfg name=Pool-1"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))

status, output = traceCommand("xm pool-list")
if status != 0:
    FAIL("xm pool-list failed, rc %s" % status)
if not re.search("Pool-1 +1 +credit", output):
    FAIL("Missing or wrong pool definition for 'Pool-1'")


#
# check persistence of pool; restart xend
#
restartXend()

status, output = traceCommand("xm pool-list")
if status != 0:
    FAIL("xm pool-list failed, rc %s" % status)
if not re.search("Pool-1 +1 +credit", output):
    FAIL("Missing or wrong pool definition for 'Pool-1'")


#
# Delete pool
#
deletePool("Pool-1")
status, output = traceCommand("xm pool-list")
if status != 0:
    FAIL("xm pool-list failed, rc %s" % status)
if re.search("Pool-1 +1 +credit", output):
    FAIL("'Pool-1' not deleted")


#
# create / start / check / destroy / delete a managed pool
#
cmd = "xm pool-new pool1.cfg"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))

cmd = "xm pool-start Pool-1"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))

cmd = "xm pool-list -l Pool-1"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))
if not re.search("host_CPU_numbers +[0-9]", output):
    FAIL("'Pool-1' not activated")

restartXend()

cmd = "xm pool-list -l Pool-1"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))
if not re.search("host_CPU_numbers +[0-9]", output):
    FAIL("'Pool-1' not activated")

destroyPool("Pool-1")
deletePool("Pool-1")

cmd = "xm pool-list Pool-1"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))
if re.search("Pool-1 +1 +credit", output):
    FAIL("'Pool-1' not deleted")


#
# create / check / destroy a unmanaged pool
#
cmd = "xm pool-create pool1.cfg"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))

cmd = "xm pool-list -l Pool-1"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))
if not re.search("host_CPU_numbers +[0-9]", output):
    FAIL("'Pool-1' not activated")

restartXend()

cmd = "xm pool-list -l Pool-1"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))
if not re.search("host_CPU_numbers +[0-9]", output):
    FAIL("'Pool-1' not activated")

destroyPool("Pool-1", True)

cmd = "xm pool-list"
status, output = traceCommand(cmd)
if status != 0:
    FAIL("%s failed, rc %s" % (cmd,status))
if re.search("Pool-1", output):
    FAIL("'Pool-1' not deleted")