Commit c51929b5 authored by zhifan huang's avatar zhifan huang Committed by Xiaowu Zhang

refactor: move connect test function, and typo

parent d288e269
......@@ -8,7 +8,8 @@ from pathlib2 import Path
DEMO_PATH = Path(__file__).resolve().parent.parent.parent.parent / "demo"
fix_file = DEMO_PATH / "fixnemu.py"
execfile(str(fix_file))
# execfile(str(fix_file)) Removed in python3
exec(open(str(fix_file)).read())
IPTABLES = 'iptables-nft'
class Node(nemu.Node):
......@@ -50,19 +51,13 @@ class NetManager(object):
def __init__(self):
self.object = []
self.registries = {}
def connectible_test(nm):
def connectable_test(self):
"""test each node can ping to their registry
Args:
nm: NetManger
Raise:
AssertionError
"""
for reg in nm.registries:
for node in nm.registries[reg]:
for reg, nodes in self.registries.items():
for node in nodes:
app0 = node.Popen(["ping", "-c", "1", reg.ip], stdout=PIPE)
ret = app0.wait()
if ret:
......@@ -71,6 +66,7 @@ def connectible_test(nm):
logging.debug("each node can ping to their registry")
def net_route():
"""build a network connect by a route(bridge)
......@@ -93,7 +89,7 @@ def net_route():
nm.object.append(switch1)
nm.registries[registry] = [machine1, machine2]
connectible_test(nm)
nm.connectable_test()
return nm
def net_demo():
......@@ -177,7 +173,7 @@ def net_demo():
stdout=PIPE, stderr=PIPE)
switch1.up = switch2.up = switch3.up =True
connectible_test(nm)
nm.connectable_test()
return nm
def network_direct():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment