Revision 6023923b qa/qa_network.py
b/qa/qa_network.py | ||
---|---|---|
28 | 28 |
|
29 | 29 |
from qa_utils import AssertCommand |
30 | 30 |
|
31 |
|
|
32 | 31 |
TEST_NET_1 = "192.0.2.0/24" |
33 | 32 |
TEST_NET_2 = "198.51.100.0/24" |
34 | 33 |
TEST_NET_3 = "203.0.113.0/24" |
... | ... | |
50 | 49 |
IP_IN_NET_2 = "198.51.100.82" |
51 | 50 |
IP_IN_NET_3 = "203.0.113.118" |
52 | 51 |
|
52 |
|
|
53 | 53 |
def GetNicParams(): |
54 | 54 |
default_mode = "bridged" |
55 | 55 |
default_link = "br0" |
... | ... | |
89 | 89 |
instance.Release() |
90 | 90 |
|
91 | 91 |
|
92 |
def GetInstance(): |
|
93 |
return qa_config.AcquireInstance() |
|
94 |
|
|
95 |
|
|
92 | 96 |
def LaunchInstance(instance, mac=None, ip=None, network=None, |
93 | 97 |
mode=None, link=None, fail=False): |
94 | 98 |
|
95 | 99 |
name = instance.name |
100 |
templ = qa_config.GetDefaultDiskTemplate() |
|
96 | 101 |
net = GetNetOption(0, None, mac, ip, network, mode, link) |
97 |
AssertCommand(["gnt-instance", "add", "-o", "debootstrap+default",
|
|
98 |
"-t", "file", "--disk", "0:size=1G", "--net", net,
|
|
102 |
AssertCommand(["gnt-instance", "add", "-o", qa_config.get("os"),
|
|
103 |
"-t", templ, "--disk", "0:size=1G", "--net", net,
|
|
99 | 104 |
"--no-name-check", "--no-ip-check", "--no-install", name], |
100 | 105 |
fail=fail) |
101 | 106 |
|
... | ... | |
219 | 224 |
# Network still connected |
220 | 225 |
AssertCommand(["gnt-network", "remove", network1], fail=True) |
221 | 226 |
|
222 |
instance1 = qa_config.AcquireInstance()
|
|
227 |
instance1 = GetInstance()
|
|
223 | 228 |
# Add instance inside the network |
224 | 229 |
LaunchInstance(instance1, ip="pool", network=network1) |
225 | 230 |
# Conflicting IP, at least one instance belongs to the network |
... | ... | |
230 | 235 |
# This should only produce a warning. |
231 | 236 |
AssertCommand(["gnt-network", "disconnect", network1]) |
232 | 237 |
|
233 |
instance1 = qa_config.AcquireInstance()
|
|
238 |
instance1 = GetInstance()
|
|
234 | 239 |
# TODO: add conflicting image. |
235 | 240 |
LaunchInstance(instance1, ip=IP_IN_NET_2) |
236 | 241 |
# Conflicting IPs |
... | ... | |
273 | 278 |
# TODO: include this use case with --no-conflicts-check |
274 | 279 |
# just add an extra field in Launch|ModifyInstance |
275 | 280 |
#(None, "192.168.1.6", None, None, None), # IP but no net |
276 |
(None, None, network1, None, None) # nicparams/mac inherited by network |
|
281 |
(None, None, network1, None, None), # nicparams/mac inherited by network
|
|
277 | 282 |
] |
278 | 283 |
|
279 | 284 |
for (mac, ip, network, mode, link) in success_cases: |
280 |
instance1 = qa_config.AcquireInstance()
|
|
285 |
instance1 = GetInstance()
|
|
281 | 286 |
LaunchInstance(instance1, mac, ip, network, mode, link) |
282 | 287 |
ModifyInstance(instance1, idx=-1, action="add", mac=mac, |
283 | 288 |
ip=ip, network=network, mode=mode, link=link) |
... | ... | |
303 | 308 |
(None, IP_IN_NET_2, None, None, None), # conflicting IP |
304 | 309 |
(None, None, None, "routed", None), # routed with no IP |
305 | 310 |
(None, "pool", network1, "routed", None), # nicparams along with network |
306 |
(None, "pool", network1, None, deflink) |
|
311 |
(None, "pool", network1, None, deflink),
|
|
307 | 312 |
] |
308 | 313 |
|
309 |
instance1 = qa_config.AcquireInstance()
|
|
310 |
instance2 = qa_config.AcquireInstance()
|
|
314 |
instance1 = GetInstance()
|
|
315 |
instance2 = GetInstance()
|
|
311 | 316 |
LaunchInstance(instance2) |
312 | 317 |
for (mac, ip, network, mode, link) in fail_cases: |
313 | 318 |
LaunchInstance(instance1, mac=mac, ip=ip, network=network, |
... | ... | |
345 | 350 |
(None, IP2_IN_NET_1, network1, None, None), # IP inside network |
346 | 351 |
#TODO: include this use case with --no-conflickts-check |
347 | 352 |
#(None, IP2_IN_NET_1, None, None, None), # IP but no net |
348 |
(None, None, network1, None, None) # nicparams/mac inherited by network |
|
353 |
(None, None, network1, None, None), # nicparams/mac inherited by network
|
|
349 | 354 |
] |
350 | 355 |
|
351 |
instance1 = qa_config.AcquireInstance()
|
|
356 |
instance1 = GetInstance()
|
|
352 | 357 |
LaunchInstance(instance1) |
353 | 358 |
for (mac, ip, network, mode, link) in success_cases: |
354 | 359 |
ModifyInstance(instance1, idx=0, action="modify", mac=mac, |
Also available in: Unified diff