Revision 3c5d3f7b
b/qa/qa_network.py | ||
---|---|---|
84 | 84 |
|
85 | 85 |
|
86 | 86 |
def RemoveInstance(instance): |
87 |
name = instance["name"]
|
|
87 |
name = instance.name
|
|
88 | 88 |
AssertCommand(["gnt-instance", "remove", "-f", name]) |
89 |
qa_config.ReleaseInstance(instance)
|
|
89 |
instance.Release()
|
|
90 | 90 |
|
91 | 91 |
|
92 | 92 |
def LaunchInstance(instance, mac=None, ip=None, network=None, |
93 | 93 |
mode=None, link=None, fail=False): |
94 | 94 |
|
95 |
name = instance["name"]
|
|
95 |
name = instance.name
|
|
96 | 96 |
net = GetNetOption(0, None, mac, ip, network, mode, link) |
97 | 97 |
AssertCommand(["gnt-instance", "add", "-o", "debootstrap+default", |
98 | 98 |
"-t", "file", "--disk", "0:size=1G", "--net", net, |
... | ... | |
103 | 103 |
def ModifyInstance(instance, idx=-1, action="add", mac=None, |
104 | 104 |
ip=None, network=None, mode=None, link=None, fail=False): |
105 | 105 |
|
106 |
name = instance["name"]
|
|
106 |
name = instance.name
|
|
107 | 107 |
net = GetNetOption(idx, action, mac, ip, network, mode, link) |
108 | 108 |
AssertCommand(["gnt-instance", "modify", "--net", net, name], fail=fail) |
109 | 109 |
|
110 | 110 |
|
111 | 111 |
def TestNetworkAddRemove(): |
112 | 112 |
"""gnt-network add/remove""" |
113 |
(network1, network2, network3, ) = qa_utils.GetNonexistentNetworks(3)
|
|
113 |
(network1, network2, network3) = qa_utils.GetNonexistentNetworks(3) |
|
114 | 114 |
|
115 | 115 |
# Note: Using RFC5737 addresses. |
116 | 116 |
# Add a network without subnet |
117 |
# TODO: make this fail=False once abstract networks are implemented
|
|
118 |
AssertCommand(["gnt-network", "add", network1], fail=True)
|
|
117 |
AssertCommand(["gnt-network", "add", network1])
|
|
118 |
AssertCommand(["gnt-network", "remove", network1])
|
|
119 | 119 |
# remove non-existing network |
120 |
AssertCommand(["gnt-network", "remove", network1], fail=True)
|
|
120 |
AssertCommand(["gnt-network", "remove", network2], fail=True)
|
|
121 | 121 |
|
122 | 122 |
# Check wrong opcode parameters |
123 | 123 |
# wrone cidr notation |
... | ... | |
190 | 190 |
AssertCommand(["gnt-network", "modify", "--gateway", GW2_IN_NET_1, |
191 | 191 |
"--network6", TEST_NET6_2, |
192 | 192 |
"--gateway6", GW_IN_NET6_2, |
193 |
network1])
|
|
193 |
network1]) |
|
194 | 194 |
|
195 | 195 |
# reset everything |
196 | 196 |
AssertCommand(["gnt-network", "modify", "--gateway", "none", |
... | ... | |
249 | 249 |
|
250 | 250 |
def TestInstanceAddAndNetAdd(): |
251 | 251 |
""" gnt-istance add / gnt-instance modify --net -1:add """ |
252 |
(network1, network2) = qa_utils.GetNonexistentNetworks(2)
|
|
252 |
(network1, network2, network3) = qa_utils.GetNonexistentNetworks(3)
|
|
253 | 253 |
defmode, deflink = GetNicParams() |
254 | 254 |
|
255 | 255 |
AssertCommand(["gnt-network", "add", "--network", TEST_NET_1, |
... | ... | |
262 | 262 |
AssertCommand(["gnt-network", "add", "--network", TEST_NET_2, network2]) |
263 | 263 |
AssertCommand(["gnt-network", "connect", network2, "routed", "rt5000"]) |
264 | 264 |
|
265 |
AssertCommand(["gnt-network", "add", network3]) |
|
266 |
AssertCommand(["gnt-network", "connect", network3, "routed", "rt100"]) |
|
265 | 267 |
|
266 | 268 |
# (mac, ip, network, mode, link) |
267 | 269 |
success_cases = [ |
... | ... | |
282 | 284 |
ModifyInstance(instance1, idx=1, action="remove") |
283 | 285 |
RemoveInstance(instance1) |
284 | 286 |
|
287 |
# test _AllIPs() |
|
288 |
instance1 = qa_config.AcquireInstance() |
|
289 |
LaunchInstance(instance1, ip="10.10.10.10") |
|
290 |
# this results to "Configuration data not consistent |
|
291 |
ModifyInstance(instance1, idx=-1, action="add", ip="10.10.10.10") |
|
292 |
ModifyInstance(instance1, idx=-1, action="add", |
|
293 |
ip="10.10.10.10", network=network3) |
|
294 |
# this raises Corrupt configuration data |
|
295 |
ModifyInstance(instance1, idx=-1, action="add", |
|
296 |
ip="10.10.10.10", network=network3, fail=True) |
|
297 |
RemoveInstance(instance1) |
|
298 |
|
|
285 | 299 |
fail_cases = [ |
286 | 300 |
(None, None, None, "lala", None), |
287 | 301 |
(None, "lala", None, None, None), |
... | ... | |
308 | 322 |
AssertCommand(["gnt-network", "remove", network1]) |
309 | 323 |
AssertCommand(["gnt-network", "disconnect", network2]) |
310 | 324 |
AssertCommand(["gnt-network", "remove", network2]) |
325 |
AssertCommand(["gnt-network", "disconnect", network3]) |
|
326 |
AssertCommand(["gnt-network", "remove", network3]) |
|
311 | 327 |
|
312 | 328 |
|
313 | 329 |
def TestInstanceNetMod(): |
Also available in: Unified diff