|
22 | 22 | OVSKernelSwitch,
|
23 | 23 | Switch,
|
24 | 24 | DynamipsRouter,
|
25 |
| - DynamipsHostRouter, |
26 | 25 | )
|
27 | 26 | from mtv.node import Node as MTVNode
|
28 | 27 |
|
@@ -89,15 +88,15 @@ def do_inferred_topo():
|
89 | 88 | "s13": {"params": {"name": "s13", "dpid": "000000000000000d"}},
|
90 | 89 | }
|
91 | 90 | hosts = {
|
92 |
| - "h7": {"params": {"name": "h7", "ip": "10.0.0.7/24"}}, |
93 |
| - "h9": {"params": {"name": "h9", "ip": "10.0.0.9/24"}}, |
94 |
| - "h6": {"params": {"name": "h6", "ip": "10.0.0.6/24"}}, |
95 |
| - "h5": {"params": {"name": "h5", "ip": "10.0.0.5/24"}}, |
96 |
| - "h3": {"params": {"name": "h3", "ip": "10.0.0.3/24"}}, |
97 |
| - "h4": {"params": {"name": "h4", "ip": "10.0.0.4/24"}}, |
98 |
| - "h1": {"params": {"name": "h1", "ip": "10.0.0.1/24"}}, |
99 |
| - "h2": {"params": {"name": "h2", "ip": "10.0.0.2/24"}}, |
100 |
| - "h8": {"params": {"name": "h8", "ip": "10.0.0.8/24"}}, |
| 91 | + "h7": {"params": {"name": "h7", "ip": "10.0.0.7", "mac": "00:00:00:00:00:07"}}, |
| 92 | + "h9": {"params": {"name": "h9", "ip": "10.0.0.9", "mac": "00:00:00:00:00:09"}}, |
| 93 | + "h6": {"params": {"name": "h6", "ip": "10.0.0.6", "mac": "00:00:00:00:00:06"}}, |
| 94 | + "h5": {"params": {"name": "h5", "ip": "10.0.0.5", "mac": "00:00:00:00:00:05"}}, |
| 95 | + "h3": {"params": {"name": "h3", "ip": "10.0.0.3", "mac": "00:00:00:00:00:03"}}, |
| 96 | + "h4": {"params": {"name": "h4", "ip": "10.0.0.4", "mac": "00:00:00:00:00:04"}}, |
| 97 | + "h1": {"params": {"name": "h1", "ip": "10.0.0.1", "mac": "00:00:00:00:00:01"}}, |
| 98 | + "h2": {"params": {"name": "h2", "ip": "10.0.0.2", "mac": "00:00:00:00:00:02"}}, |
| 99 | + "h8": {"params": {"name": "h8", "ip": "10.0.0.8", "mac": "00:00:00:00:00:08"}}, |
101 | 100 | }
|
102 | 101 | switch_links = [
|
103 | 102 | [{"name": "s10", "port": 6}, {"name": "s13", "port": 3}],
|
@@ -200,9 +199,12 @@ def post_build():
|
200 | 199 |
|
201 | 200 | inst = host["instance"]
|
202 | 201 | inst.cmd(f"ip route add 2.128.0.0/24 via 10.0.0.7")
|
203 |
| - inst.cmd(f"ip route add 2.128.1.0/24 via 10.0.0.7") |
| 202 | + inst.cmd(f"ip route add 2.128.1.0/24 via 10.0.0.8") |
204 | 203 |
|
205 | 204 | hosts["h7"]["instance"].cmd(f"iptables -t nat -I POSTROUTING -o h7-eth1 -j SNAT --to 2.128.0.101")
|
| 205 | + hosts["h8"]["instance"].cmd(f"iptables -t nat -I POSTROUTING -o h8-eth1 -j SNAT --to 2.128.1.101") |
| 206 | + hosts["h7"]["instance"].cmd(f"ip route add 2.128.1.0/24 via 10.0.0.8") |
| 207 | + hosts["h8"]["instance"].cmd(f"ip route add 2.128.0.0/24 via 10.0.0.7") |
206 | 208 |
|
207 | 209 | c1.start()
|
208 | 210 |
|
@@ -353,93 +355,17 @@ def post_start():
|
353 | 355 |
|
354 | 356 | return post_start
|
355 | 357 |
|
356 |
| -def add_inter(): |
357 |
| - root_dir = Path("/extra/") |
358 |
| - dynamips_image = str(root_dir / "c7200-adventerprisek9-mz.153-3.XB12.image") |
359 |
| - |
360 |
| - h50 = net.addHost("h50", ip="10.0.0.50/24") |
361 |
| - net.addLink("s6", h50, port2=2, addr2="00:00:00") |
362 |
| - |
363 |
| - normal_config = """hostname h50r |
364 |
| -ip routing |
365 |
| -router rip |
366 |
| -version 2 |
367 |
| -network 10.0.0.0 |
368 |
| -network 11.0.0.0 |
369 |
| -interface FastEthernet 1/0 |
370 |
| -no cdp enable |
371 |
| -ip address 10.0.0.50 255.0.0.0 |
372 |
| -no shut |
373 |
| -interface GigabitEthernet 2/0 |
374 |
| -no cdp enable |
375 |
| -ip address 10.0.0.50 255.0.0.0 |
376 |
| -shut |
377 |
| -interface FastEthernet 3/0 |
378 |
| -no cdp enable |
379 |
| -ip address 11.0.0.1 255.0.0.0 |
380 |
| -no shut |
381 |
| -end""" |
382 |
| - config = config_patches.get("h50r", normal_config) |
383 |
| - |
384 |
| - h50r = net.addHost( |
385 |
| - "h50r", |
386 |
| - ip="10.0.0.50", |
387 |
| - cls=DynamipsHostRouter, |
388 |
| - dynamips_platform="7200", |
389 |
| - dynamips_image=dynamips_image, |
390 |
| - dynamips_console_port=7123, |
391 |
| - dynamips_args=[ |
392 |
| - "-i {}".format("h10"), |
393 |
| - "--idle-pc=0x60630338", |
394 |
| - "-P 7200", |
395 |
| - "-o 64", |
396 |
| - "-r 200", |
397 |
| - ], |
398 |
| - dynamips_config=config, |
399 |
| - dynamips_ports=[("PA-FE-TX", "FastEthernet", 1, [(0, "s6")]), |
400 |
| - ("PA-GE", "GigabitEthernet", 2, [(0, "s7")]), |
401 |
| - ("PA-FE-TX", "FastEthernet", 3, [(0, "h52")])], |
402 |
| - ) |
403 |
| - |
404 |
| - h52 = net.addHost("h52", ip="11.0.0.52/8") |
405 |
| - s6_h50r_link = net.addLink("s6", h50r, addr2="00:00:00:00:00:32") |
406 |
| - s7_h50r_link = net.addLink("s7", h50r, addr2="00:00:00:00:00:33") |
407 |
| - h52_h50r_link = net.addLink(h52, h50r) |
408 |
| - |
409 |
| - def post_build(hosts): |
410 |
| - pass |
411 |
| - # h50r.setIP("10.0.0.50", intf=) |
412 |
| - |
413 |
| - # h50.setIP("11.0.0.50/8", intf=h50_h50r_link.intf1) |
414 |
| - # h51.setIP("11.1.0.51/8", intf=h51_h50r_link.intf1) |
415 |
| - # h52.setIP("11.2.0.52/8", intf=h52_h50r_link.intf1) |
416 |
| - # h52.cmd("ip route add 10.0.0.0/8 via 11.0.0.1") |
417 |
| - # h50.cmd(f"iptables -t nat -I POSTROUTING -o {h50_h50r_link.intf1} -j SNAT --to 11.0.0.50") |
418 |
| - # h51.cmd(f"iptables -t nat -I POSTROUTING -o {h51_h50r_link.intf1} -j SNAT --to 11.1.0.51") |
419 |
| - |
420 |
| - def post_start(hosts): |
421 |
| - for host in hosts.values(): |
422 |
| - inst = host["instance"] |
423 |
| - inst.cmd("ip route add 11.0.0.0/8 via 10.0.0.50") |
424 |
| - h52.cmd("ip route add 10.0.0.0/8 via 11.0.0.1") |
425 |
| - h50r.start() |
426 |
| - |
427 |
| - return post_build, post_start |
428 |
| - |
429 | 358 | # h1 ip r add 2.128.0.0/24 via 10.0.0.2
|
430 | 359 | # h1 ip r add 2.128.1.0/24 via 10.0.0.2
|
431 | 360 |
|
432 | 361 | post_build, hosts = do_inferred_topo()
|
433 | 362 | post_start = do_batfish()
|
434 |
| -post_build_inter, post_start_inter = add_inter() |
435 | 363 |
|
436 | 364 | net.build()
|
437 | 365 | post_build()
|
438 |
| -post_build_inter(hosts) |
439 | 366 | net.start()
|
440 |
| -#net.staticArp() |
| 367 | +net.staticArp() |
441 | 368 | post_start()
|
442 |
| -post_start_inter(hosts) |
443 | 369 | REST(net)
|
444 | 370 |
|
445 | 371 | exit = Event()
|
|
0 commit comments