def test_ns_create_delete(self): global ivn_file global fake_node1 global fake_node2 topo = Topology(ivn_file) topo.create() result1 = subprocess.check_output(['ovs-vsctl', 'list-br']) self.assertIn("br-int", result1, "vswitch is missing") result2 = subprocess.check_output( ['ovs-vsctl', 'list-ports', 'br-int']) self.assertIn("vint0", result2, "ports is missing") self.assertIn("vint1", result2, "ports is missing") result = subprocess.check_output(["ip", "netns", "list"]) reobj = re.search(r'node1ns(\s?\(id:\s?\d+\))?', result) assert reobj reobj = re.search(r'node0ns(\s?\(id:\s?\d+\))?', result) assert reobj a_boot_image = cloud_img.gen_qemuimg(fixtures.cloud_img_ubuntu_16_04, "mytest0.img") b_boot_image = cloud_img.gen_qemuimg(fixtures.cloud_img_ubuntu_16_04, "mytest1.img") newnetwork0 = create_new_networkconfig(node0_mac0, "192.168.188.211", "192.168.188.1", node0_mac1) newnetwork1 = create_new_networkconfig(node1_mac0, "192.168.188.210", "192.168.188.1", node1_mac1) a_iso = cloud_img.geniso("my-seed0.iso", "305c9cc1-2f5a-4e76-b28e-ed8313fa283e", newnetwork0) b_iso = cloud_img.geniso("my-seed1.iso", "305c9cc1-2f5a-4e76-b28e-ed8313fa283f", newnetwork1) fake_node1 = self.start_node_with_config('test0', 'node0ns', a_boot_image, a_iso) fake_node2 = self.start_node_with_config('test1', 'node1ns', b_boot_image, b_iso) self._verify_node_in_netns(fake_node1, "node0ns") self._verify_node_in_netns(fake_node2, "node1ns") node1_ssh = self.client_ssh('192.168.188.211') node2_ssh = self.client_ssh('192.168.188.210') self.ping_peer(node1_ssh, '192.168.188.210') self.ping_peer(node2_ssh, '192.168.188.211') test_ivn._stop_node(fake_node1) test_ivn._stop_node(fake_node2) cloud_img.clear_files() fake_node1 = None fake_node2 = None topo.delete() result = subprocess.check_output(["ip", "netns", "list"]) self.assertNotIn("node1ns", result, "delete node1ns failed") self.assertNotIn("node0ns", result, "delete node0ns failed") result1 = subprocess.check_output(['ovs-vsctl', 'list-br']) self.assertNotIn("br-int", result1, "delete vswitch success")
def teardown_module(): global conf global ivn_cfg_file if conf: stop_chassis() os.environ["PATH"] = old_path topo = Topology(ivn_cfg_file) topo.delete() os.unlink(ivn_cfg_file)
def teardown_module(): global conf global ivn_cfg_file if conf: stop_chassis() os.environ["PATH"] = old_path topo = Topology(ivn_cfg_file) topo.delete() os.unlink(ivn_cfg_file) if os.path.exists("/tmp/sas_0.img"): os.unlink("/tmp/sas_0.img") if os.path.exists("/tmp/disk-nvme-3.img"): os.unlink("/tmp/disk-nvme-3.img")
def test_ns_create_delete(self): global ivn_file topo = Topology(ivn_file) topo.create() result = subprocess.check_output(["ip", "netns", "list"]) reobj = re.search(r'node1ns(\s?\(id:\s?\d+\))?', result) assert reobj reobj = re.search(r'node0ns(\s?\(id:\s?\d+\))?', result) assert reobj topo.delete() result = subprocess.check_output(["ip", "netns", "list"]) self.assertNotIn("node1ns", result, "delete node1ns failed") self.assertNotIn("node0ns", result, "delete node0ns failed")
def test_ns_create_delete(self): global ivn_file global fake_node1 global fake_node2 topo = Topology(ivn_file) topo.create() result1 = subprocess.check_output(['ovs-vsctl', 'list-br']) self.assertIn("br-int", result1, "vswitch is missing") result2 = subprocess.check_output( ['ovs-vsctl', 'list-ports', 'br-int']) self.assertIn("vint0", result2, "ports is missing") self.assertIn("vint1", result2, "ports is missing") result = subprocess.check_output(["ip", "netns", "list"]) reobj = re.search(r'node1ns(\s?\(id:\s?\d+\))?', result) assert reobj reobj = re.search(r'node0ns(\s?\(id:\s?\d+\))?', result) assert reobj fake_node1 = self.start_node_with_config('test0', 'node0ns', a_boot_image, a_iso) fake_node2 = self.start_node_with_config('test1', 'node1ns', b_boot_image, b_iso) self._verify_node_in_netns(fake_node1, "node0ns") self._verify_node_in_netns(fake_node2, "node1ns") node1_ssh = self.client_ssh('192.168.188.211') node2_ssh = self.client_ssh('192.168.188.210') self.ping_peer(node1_ssh, '192.168.188.210') self.ping_peer(node2_ssh, '192.168.188.211') test_ivn._stop_node(fake_node1) test_ivn._stop_node(fake_node2) cloud_img.clear_files() fake_node1 = None fake_node2 = None topo.delete() result = subprocess.check_output(["ip", "netns", "list"]) self.assertNotIn("node1ns", result, "delete node1ns failed") self.assertNotIn("node0ns", result, "delete node0ns failed") result1 = subprocess.check_output(['ovs-vsctl', 'list-br']) self.assertNotIn("br-int", result1, "delete vswitch success")
def teardown_module(): global ivn_file topo = Topology(ivn_file) topo.delete() os.unlink(ivn_file) os.environ['PATH'] = old_path
#!/usr/bin/env python from ivn.core import Topology import sys if __name__ == "__main__": if sys.argv[1] == "create": topo = Topology("./config.yml") topo.create() elif sys.argv[1] == "delete": topo = Topology("./config.yml") topo.delete() else: print sys.argv[1]