def check(indent="", shellError=False): print indent + "checking External Network element type..." indent += "\t" try: print indent + "creating external_network..." id = checkCreate(indent=indent) print indent + "creating openvz device with one interface..." dev = element_create("openvz")["id"] print indent + "\tID: %d" % dev eth0 = element_create("openvz_interface", dev, {"use_dhcp": True})["id"] print indent + "\tID: %d" % eth0 print indent + "connecting interface with network..." con = connection_create(eth0, id)["id"] print indent + "\tID: %d" % con print indent + "starting openvz device..." element_action(dev, "prepare") element_action(dev, "start") print indent + "checking connectivity..." time.sleep(5) element_action(dev, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 8.8.8.8"}) print indent + "disconnecting interface and network..." connection_remove(con) print indent + "tearing down openvz device..." openvzTearDown(dev, indent=indent) print indent + "removing external network..." checkRemove(id, indent=indent) except: import traceback traceback.print_exc() if shellError: shell() finally: tearDownConnection(con, indent) tearDown(id, indent=indent) openvzTearDown(dev, indent=indent)
def check(indent="", shellError=False): print indent + "checking External Network element type..." indent += "\t" try: print indent+"creating external_network..." id = checkCreate(indent=indent) print indent+"creating openvz device with one interface..." dev = element_create("openvz")["id"] print indent+"\tID: %d" % dev eth0 = element_create("openvz_interface", dev, {"use_dhcp": True})["id"] print indent+"\tID: %d" % eth0 print indent+"connecting interface with network..." con = connection_create(eth0, id)["id"] print indent+"\tID: %d" % con print indent+"starting openvz device..." element_action(dev, "prepare") element_action(dev, "start") print indent+"checking connectivity..." time.sleep(5) element_action(dev, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 8.8.8.8"}) print indent+"disconnecting interface and network..." connection_remove(con) print indent+"tearing down openvz device..." openvzTearDown(dev, indent=indent) print indent+"removing external network..." checkRemove(id, indent=indent) except: import traceback traceback.print_exc() if shellError: shell() finally: tearDownConnection(con, indent) tearDown(id, indent=indent) openvzTearDown(dev, indent=indent)
def check(indent="", shellError=False): print indent + "checking UDP-Tunnel element type..." indent += "\t" try: print indent+"creating udp_tunnel endpoints..." id1 = checkCreate(indent=indent) id2 = checkCreate(indent=indent) print indent+"pointing endpoints towards each others..." info1 = element_info(id1) info2 = element_info(id2) element_modify(id2, {"connect": "%s:%d" % (__hostname__, info1["attrs"]["port"])}) print indent+"creating two openvz devices with one interface each..." dev0 = element_create("openvz")["id"] print indent+"\tID: %d" % dev0 eth0 = element_create("openvz_interface", dev0, {"use_dhcp": False, "ip4address": "10.0.0.1/24"})["id"] print indent+"\tID: %d" % eth0 dev1 = element_create("openvz")["id"] print indent+"\tID: %d" % dev1 eth1 = element_create("openvz_interface", dev1, {"use_dhcp": False, "ip4address": "10.0.0.2/24"})["id"] print indent+"\tID: %d" % eth1 print indent+"connecting interfaces with endpoints..." con1 = connection_create(eth0, id1)["id"] print indent+"\tID: %d" % con1 con2 = connection_create(eth1, id2)["id"] print indent+"\tID: %d" % con2 print indent+"starting openvz devices..." element_action(dev0, "prepare") element_action(dev1, "prepare") element_action(dev0, "start") element_action(dev1, "start") print indent+"starting udp_tunnel endpoints..." element_action(id1, "start") element_action(id2, "start") print indent+"starting connections..." connection_action(con1, "start") connection_action(con2, "start") print indent+"checking connectivity..." time.sleep(5) element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"}) print indent+"stopping connections..." connection_action(con1, "stop") connection_action(con2, "stop") print indent+"disconnecting interfaces and endpoints..." connection_remove(con1) connection_remove(con2) print indent+"stopping tinc endpoints..." element_action(id1, "stop") element_action(id2, "stop") print indent+"tearing down openvz devices..." openvzTearDown(dev0, indent=indent) openvzTearDown(dev1, indent=indent) print indent+"removing tinc endpoints..." checkRemove(id1, indent=indent) checkRemove(id2, indent=indent) except: import traceback traceback.print_exc() if shellError: shell() finally: tearDownConnection(con1, indent) tearDownConnection(con2, indent) tearDown(id1, indent) tearDown(id2, indent) openvzTearDown(dev0, indent=indent) openvzTearDown(dev1, indent=indent)
def check(indent="", shellError=False): print indent + "checking Bridge connection type..." indent += "\t" try: print indent+"creating two openvz devices with one interface each..." dev0 = element_create("openvz")["id"] print indent+"\tID: %d" % dev0 eth0 = element_create("openvz_interface", dev0, {"use_dhcp": False, "ip4address": "10.0.0.1/24"})["id"] print indent+"\tID: %d" % eth0 dev1 = element_create("openvz")["id"] print indent+"\tID: %d" % dev1 eth1 = element_create("openvz_interface", dev1, {"use_dhcp": False, "ip4address": "10.0.0.2/24"})["id"] print indent+"\tID: %d" % eth1 print indent+"creating bridge between interfaces..." id = checkCreate(eth0, eth1, indent=indent) print indent+"starting openvz devices..." element_action(dev0, "prepare") element_action(dev1, "prepare") element_action(dev0, "start") element_action(dev1, "start") print indent+"starting bridge..." checkAction(id, "start", assertState="started", indent=indent) print indent+"checking connectivity..." time.sleep(5) element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"}) print indent+"changing link emulation values..." connection_modify(id, {"emulation": True, "delay_to": 5.0, "delay_from": 2.0, "jitter_to": 0.0, "jitter_from": 0.0, "distribution_to": "uniform", "distribution_from": "uniform", "bandwidth_to": 10000, "bandwidth_from": 10000, "lossratio_to": 0.0, "lossratio_from": 0.0, "duplicate_to": 0.0, "duplicate_from": 0.0, "corrupt_to": 0.0, "corrupt_from": 0.0}) print indent+"checking connectivity..." element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"}) print indent+"checking file capture..." connection_modify(id, {"capturing": True, "capture_mode": "file", "capture_filter": "icmp"}) element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"}) print indent+"checking capture download..." fileserver_port = host_info()["fileserver_port"] assert fileserver_port grant = connection_action(id, "download_grant") assert grant lib.download("http://%s:%d/%s/download" % (__hostname__, fileserver_port, grant), "capture.pcap") assert os.path.exists("capture.pcap") print indent+"checking live capture..." connection_modify(id, {"capture_mode": "net"}) info = connection_info(id) assert "attrs" in info and "capture_port" in info["attrs"] assert lib.tcpPortOpen(__hostname__, info["attrs"]["capture_port"]), "Capture port not open" print indent+"stopping bridge..." checkAction(id, "stop", assertState="created", indent=indent) print indent+"removing bridge..." checkRemove(id, indent=indent) print indent+"tearing down openvz devices..." openvzTearDown(dev0, indent=indent) openvzTearDown(dev1, indent=indent) except: import traceback traceback.print_exc() if shellError: shell() finally: if os.path.exists("capture.pcap"): os.remove("capture.pcap") tearDown(id, indent) openvzTearDown(dev0, indent=indent) openvzTearDown(dev1, indent=indent)
def check(indent="", shellError=False): print indent + "checking Bridge connection type..." indent += "\t" try: print indent + "creating two openvz devices with one interface each..." dev0 = element_create("openvz")["id"] print indent + "\tID: %d" % dev0 eth0 = element_create("openvz_interface", dev0, { "use_dhcp": False, "ip4address": "10.0.0.1/24" })["id"] print indent + "\tID: %d" % eth0 dev1 = element_create("openvz")["id"] print indent + "\tID: %d" % dev1 eth1 = element_create("openvz_interface", dev1, { "use_dhcp": False, "ip4address": "10.0.0.2/24" })["id"] print indent + "\tID: %d" % eth1 print indent + "creating bridge between interfaces..." id = checkCreate(eth0, eth1, indent=indent) print indent + "starting openvz devices..." element_action(dev0, "prepare") element_action(dev1, "prepare") element_action(dev0, "start") element_action(dev1, "start") print indent + "starting bridge..." checkAction(id, "start", assertState="started", indent=indent) print indent + "checking connectivity..." time.sleep(5) element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"}) print indent + "changing link emulation values..." connection_modify( id, { "emulation": True, "delay_to": 5.0, "delay_from": 2.0, "jitter_to": 0.0, "jitter_from": 0.0, "distribution_to": "uniform", "distribution_from": "uniform", "bandwidth_to": 10000, "bandwidth_from": 10000, "lossratio_to": 0.0, "lossratio_from": 0.0, "duplicate_to": 0.0, "duplicate_from": 0.0, "corrupt_to": 0.0, "corrupt_from": 0.0 }) print indent + "checking connectivity..." element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"}) print indent + "checking file capture..." connection_modify(id, { "capturing": True, "capture_mode": "file", "capture_filter": "icmp" }) element_action(dev0, "execute", {"cmd": "ping -I eth0 -A -c 10 -n -q 10.0.0.2"}) print indent + "checking capture download..." fileserver_port = host_info()["fileserver_port"] assert fileserver_port grant = connection_action(id, "download_grant") assert grant lib.download( "http://%s:%d/%s/download" % (__hostname__, fileserver_port, grant), "capture.pcap") assert os.path.exists("capture.pcap") print indent + "checking live capture..." connection_modify(id, {"capture_mode": "net"}) info = connection_info(id) assert "attrs" in info and "capture_port" in info["attrs"] assert lib.tcpPortOpen( __hostname__, info["attrs"]["capture_port"]), "Capture port not open" print indent + "stopping bridge..." checkAction(id, "stop", assertState="created", indent=indent) print indent + "removing bridge..." checkRemove(id, indent=indent) print indent + "tearing down openvz devices..." openvzTearDown(dev0, indent=indent) openvzTearDown(dev1, indent=indent) except: import traceback traceback.print_exc() if shellError: shell() finally: if os.path.exists("capture.pcap"): os.remove("capture.pcap") tearDown(id, indent) openvzTearDown(dev0, indent=indent) openvzTearDown(dev1, indent=indent)