def configure_underlying_network(self, configuration): """ The underlying network for the tunnel consists of two Ethernet devices on the matched hosts. A VLAN is configured on top of each device. """ host1, host2 = self.matched.host1, self.matched.host2 host1.vlan0 = VlanDevice(realdev=host1.eth0, vlan_id=self.params.vlan_id) host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=self.params.vlan_id) for i, device in enumerate([host1.vlan0, host2.vlan0]): device.ip_add(ipaddress("192.168.101." + str(i + 1) + "/24")) configuration.test_wide_devices.append(device) for dev in [ host1.eth0, host1.vlan0, host2.eth0, host2.vlan0, ]: dev.up() configuration.tunnel_endpoints = (host1.vlan0, host2.vlan0)
def test_wide_configuration(self): host1, host2, guest1 = (self.matched.host1, self.matched.host2, self.matched.guest1) host1.br0 = OvsBridgeDevice() for dev in [host1.eth0, host1.tap0]: dev.down() host1.br0.port_add(dev) host2.eth0.down() guest1.eth0.down() host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=self.params.vlan_id) guest1.vlan0 = VlanDevice(realdev=guest1.eth0, vlan_id=self.params.vlan_id) configuration = super().test_wide_configuration() configuration.test_wide_devices = [host2.vlan0, guest1.vlan0] net_addr_1 = "192.168.10" net_addr6_1 = "fc00:0:0:1" for i, machine in enumerate([host2, guest1]): machine.vlan0.ip_add(ipaddress(net_addr_1 + "." + str(i+2) + "/24")) machine.vlan0.ip_add(ipaddress(net_addr6_1 + "::" + str(i+2) + "/64")) for dev in [host1.eth0, host1.tap0, host1.br0, host2.eth0, host2.vlan0, guest1.eth0, guest1.vlan0]: dev.up() self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test_wide_configuration(self): host1, host2, guest1, guest2 = (self.matched.host1, self.matched.host2, self.matched.guest1, self.matched.guest2) for host in [host1, host2]: host.br0 = BridgeDevice() for dev in [host.eth0, host.tap0]: dev.down() host.br0.slave_add(dev) guest1.eth0.down() guest2.eth0.down() guest1.vlan0 = VlanDevice(realdev=guest1.eth0, vlan_id=self.params.vlan_id) guest2.vlan0 = VlanDevice(realdev=guest2.eth0, vlan_id=self.params.vlan_id) configuration = super().test_wide_configuration() configuration.test_wide_devices = [ guest1.vlan0, guest2.vlan0, host1.br0, host2.br0 ] net_addr_1 = "192.168.10" net_addr6_1 = "fc00:0:0:1" host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24")) host2.br0.ip_add(ipaddress(net_addr_1 + ".2/24")) for i, guest in enumerate([guest1, guest2]): guest.vlan0.ip_add(ipaddress(net_addr_1 + "." + str(i + 3) + "/24")) guest.vlan0.ip_add( ipaddress(net_addr6_1 + "::" + str(i + 3) + "/64")) for host in [host1, host2]: for dev in [host.eth0, host.tap0, host.br0]: dev.up() for guest in [guest1, guest2]: guest.eth0.up() guest.vlan0.up() if "perf_tool_cpu" in self.params: logging.info("'perf_tool_cpu' param (%d) to be set to None" % self.params.perf_tool_cpu) self.params.perf_tool_cpu = None self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test_wide_configuration(self): host1, host2, guest1 = (self.matched.host1, self.matched.host2, self.matched.guest1) host1.eth0.down() host1.tap0.down() host1.br0 = OvsBridgeDevice() host1.br0.port_add(host1.eth0) host1.br0.port_add(host1.tap0, port_options={'tag': 10}) host2.eth0.down() guest1.eth0.down() host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10) configuration = super().test_wide_configuration() configuration.test_wide_devices = [guest1.eth0, host2.vlan0] net_addr_1 = "192.168.10" net_addr6_1 = "fc00:0:0:1" for i, dev in enumerate([host2.vlan0, guest1.eth0]): dev.ip_add(ipaddress(net_addr_1 + "." + str(i + 2) + "/24")) dev.ip_add(ipaddress(net_addr6_1 + "::" + str(i + 2) + "/64")) for dev in [ host1.eth0, host1.tap0, host1.br0, host2.eth0, host2.vlan0, guest1.eth0 ]: dev.up() self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test_wide_configuration(self): host1, host2, guest1 = (self.matched.host1, self.matched.host2, self.matched.guest1) host1.eth0.down() host1.tap0.down() host1.br0 = BridgeDevice() host1.br0.slave_add(host1.tap0) host2.eth0.down() guest1.eth0.down() host1_vlan_args0 = dict() host2_vlan_args0 = dict(realdev=host2.eth0, vlan_id=10) host1.vlan0 = VlanDevice(realdev=host1.eth0, vlan_id=10, master=host1.br0) host2.vlan0 = VlanDevice(**host2_vlan_args0) configuration = super().test_wide_configuration() configuration.test_wide_devices = [guest1.eth0, host2.vlan0, host1.br0] net_addr_1 = "192.168.10" net_addr6_1 = "fc00:0:0:1" host1.br0.ip_add(ipaddress(net_addr_1 + ".1/24")) for i, dev in enumerate([host2.vlan0, guest1.eth0]): dev.ip_add(ipaddress(net_addr_1 + "." + str(i + 2) + "/24")) dev.ip_add(ipaddress(net_addr6_1 + "::" + str(i + 2) + "/64")) for dev in [ host1.eth0, host1.tap0, host1.vlan0, host1.br0, host2.eth0, host2.vlan0, guest1.eth0 ]: dev.up() self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test_wide_configuration(self): """ Test wide configuration for this recipe involves creating three VLAN (802.1Q) tunnels on top of the matched host's NIC with vlan ids 10, 20, 30. The same tunnels are configured on the second host. An IPv4 and IPv6 address is configured on each tunnel endpoint. | host1.vlan0 = 192.168.10.1/24 and fc00:0:0:1::1/64 | host1.vlan1 = 192.168.20.1/24 and fc00:0:0:2::1/64 | host1.vlan2 = 192.168.30.1/24 and fc00:0:0:3::1/64 | host2.vlan0 = 192.168.10.2/24 and fc00:0:0:1::2/64 | host2.vlan1 = 192.168.20.2/24 and fc00:0:0:2::2/64 | host2.vlan2 = 192.168.30.2/24 and fc00:0:0:3::2/64 """ host1, host2 = self.matched.host1, self.matched.host2 host1.eth0.down() host2.eth0.down() host1.vlan0 = VlanDevice(realdev=host1.eth0, vlan_id=10) host1.vlan1 = VlanDevice(realdev=host1.eth0, vlan_id=20) host1.vlan2 = VlanDevice(realdev=host1.eth0, vlan_id=30) host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10) host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=20) host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=30) configuration = super().test_wide_configuration() configuration.test_wide_devices = [] for host in [host1, host2]: configuration.test_wide_devices.extend( [host.vlan0, host.vlan1, host.vlan2]) net_addr = "192.168" net_addr6 = "fc00:0:0" for i, host in enumerate([host1, host2]): host.vlan0.ip_add(ipaddress('{}.10.{}/24'.format(net_addr, i + 1))) host.vlan1.ip_add(ipaddress('{}.20.{}/24'.format(net_addr, i + 1))) host.vlan2.ip_add(ipaddress('{}.30.{}/24'.format(net_addr, i + 1))) host.vlan0.ip_add(ipaddress('{}:1::{}/64'.format(net_addr6, i + 1))) host.vlan1.ip_add(ipaddress('{}:2::{}/64'.format(net_addr6, i + 1))) host.vlan2.ip_add(ipaddress('{}:3::{}/64'.format(net_addr6, i + 1))) for dev in [host.eth0, host.vlan0, host.vlan1, host.vlan2]: dev.up() self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test_wide_configuration(self): host1, host2 = self.matched.host1, self.matched.host2 #The config argument needs to be used with a team device normally #(e.g to specify the runner mode), but it is not used here due to #a bug in the TeamDevice module host1.team0 = TeamDevice() for dev in [host1.eth0, host1.eth1]: dev.down() host1.team0.slave_add(dev) host1.vlan0 = VlanDevice(realdev=host1.team0, vlan_id=10) host1.vlan1 = VlanDevice(realdev=host1.team0, vlan_id=20) host1.vlan2 = VlanDevice(realdev=host1.team0, vlan_id=30) host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10) host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=20) host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=30) configuration = super().test_wide_configuration() configuration.test_wide_devices = [] for host in [host1, host2]: configuration.test_wide_devices.extend( [host.vlan0, host.vlan1, host.vlan2]) configuration.test_wide_devices.append(host1.team0) net_addr = "192.168" net_addr6 = "fc00:0:0" for i, host in enumerate([host1, host2]): host.vlan0.ip_add( ipaddress(net_addr + '.10' + '.' + str(i + 1) + "/24")) host.vlan0.ip_add( ipaddress(net_addr6 + ":1::" + str(i + 1) + "/64")) host.vlan1.ip_add( ipaddress(net_addr + '.20' + '.' + str(i + 1) + "/24")) host.vlan1.ip_add( ipaddress(net_addr6 + ":2::" + str(i + 1) + "/64")) host.vlan2.ip_add( ipaddress(net_addr + '.30' + '.' + str(i + 1) + "/24")) host.vlan2.ip_add( ipaddress(net_addr6 + ":3::" + str(i + 1) + "/64")) for dev in [ host1.eth0, host1.eth1, host1.team0, host1.vlan0, host1.vlan1, host1.vlan2, host2.eth0, host2.vlan0, host2.vlan1, host2.vlan2 ]: dev.up() self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test_wide_configuration(self): host1, host2 = self.matched.host1, self.matched.host2 host1.bond0 = BondDevice(mode=self.params.bonding_mode, miimon=self.params.miimon_value) for dev in [host1.eth0, host1.eth1]: dev.down() host1.bond0.slave_add(dev) host1.vlan0 = VlanDevice(realdev=host1.bond0, vlan_id=10) host1.vlan1 = VlanDevice(realdev=host1.bond0, vlan_id=20) host1.vlan2 = VlanDevice(realdev=host1.bond0, vlan_id=30) host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10) host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=20) host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=30) configuration = super().test_wide_configuration() configuration.test_wide_devices = [] for host in [host1, host2]: configuration.test_wide_devices.extend( [host.vlan0, host.vlan1, host.vlan2]) configuration.test_wide_devices.append(host1.bond0) net_addr = "192.168" net_addr6 = "fc00:0:0" for i, host in enumerate([host1, host2]): host.vlan0.ip_add( ipaddress(net_addr + '.10' + '.' + str(i + 1) + "/24")) host.vlan0.ip_add( ipaddress(net_addr6 + ":1::" + str(i + 1) + "/64")) host.vlan1.ip_add( ipaddress(net_addr + '.20' + '.' + str(i + 1) + "/24")) host.vlan1.ip_add( ipaddress(net_addr6 + ":2::" + str(i + 1) + "/64")) host.vlan2.ip_add( ipaddress(net_addr + '.30' + '.' + str(i + 1) + "/24")) host.vlan2.ip_add( ipaddress(net_addr6 + ":3::" + str(i + 1) + "/64")) for dev in [ host1.eth0, host1.eth1, host1.bond0, host1.vlan0, host1.vlan1, host1.vlan2, host2.eth0, host2.vlan0, host2.vlan1, host2.vlan2 ]: dev.up() self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test_wide_configuration(self): host1, host2 = self.matched.host1, self.matched.host2 host1.team0 = TeamDevice( config={'runner': { 'name': self.params.runner_name }}) for dev in [host1.eth0, host1.eth1]: dev.down() host1.team0.slave_add(dev) host1.vlan0 = VlanDevice(realdev=host1.team0, vlan_id=10) host1.vlan1 = VlanDevice(realdev=host1.team0, vlan_id=20) host1.vlan2 = VlanDevice(realdev=host1.team0, vlan_id=30) host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=10) host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=20) host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=30) configuration = super().test_wide_configuration() configuration.test_wide_devices = [] for host in [host1, host2]: configuration.test_wide_devices.extend( [host.vlan0, host.vlan1, host.vlan2]) configuration.test_wide_devices.append(host1.team0) net_addr = "192.168" net_addr6 = "fc00:0:0" for i, host in enumerate([host1, host2]): host.vlan0.ip_add(ipaddress('{}.10.{}/24'.format(net_addr, i + 1))) host.vlan1.ip_add(ipaddress('{}.20.{}/24'.format(net_addr, i + 1))) host.vlan2.ip_add(ipaddress('{}.30.{}/24'.format(net_addr, i + 1))) host.vlan0.ip_add(ipaddress('{}:1::{}/64'.format(net_addr6, i + 1))) host.vlan1.ip_add(ipaddress('{}:2::{}/64'.format(net_addr6, i + 1))) host.vlan2.ip_add(ipaddress('{}:3::{}/64'.format(net_addr6, i + 1))) for dev in [ host1.eth0, host1.eth1, host1.team0, host1.vlan0, host1.vlan1, host1.vlan2, host2.eth0, host2.vlan0, host2.vlan1, host2.vlan2 ]: dev.up() self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test_wide_configuration(self): host1, host2, guest1, guest2, guest3, guest4 = (self.matched.host1, self.matched.host2, self.matched.guest1, self.matched.guest2, self.matched.guest3, self.matched.guest4) for host in [host1, host2]: for dev in [host.eth0, host.eth1, host.tap0, host.tap1]: dev.down() host.bond0 = BondDevice(mode=self.params.bonding_mode, miimon=self.params.miimon_value) host.bond0.slave_add(host.eth0) host.bond0.slave_add(host.eth1) host.br0 = BridgeDevice() host.br0.slave_add(host.tap0) host.br1 = BridgeDevice() host.br1.slave_add(host.tap1) for guest in (guest1, guest2, guest3, guest4): guest.eth0.down() host1.vlan0 = VlanDevice(realdev=host1.bond0, vlan_id=10, master=host1.br0) host1.vlan1 = VlanDevice(realdev=host1.bond0, vlan_id=20, master=host1.br1) host2.vlan0 = VlanDevice(realdev=host2.bond0, vlan_id=10, master=host2.br0) host2.vlan1 = VlanDevice(realdev=host2.bond0, vlan_id=20, master=host2.br1) configuration = super().test_wide_configuration() configuration.test_wide_devices = [ host1.br0, host2.br0, guest1.eth0, guest2.eth0, guest3.eth0, guest4.eth0 ] net_addr = "192.168" net_addr6 = "fc00:0:0" for host, (guest_a, guest_b), n in [(host1, (guest1, guest2), 1), (host2, (guest3, guest4), 3)]: host.br0.ip_add(ipaddress(net_addr + ".10." + str(n) + "/24")) host.br1.ip_add(ipaddress(net_addr + ".20." + str(n) + "/24")) guest_a.eth0.ip_add( ipaddress(net_addr + ".10." + str(n + 1) + "/24")) guest_a.eth0.ip_add( ipaddress(net_addr6 + ":1::" + str(n + 1) + "/64")) guest_b.eth0.ip_add( ipaddress(net_addr + ".20." + str(n + 1) + "/24")) guest_b.eth0.ip_add( ipaddress(net_addr6 + ":2::" + str(n + 1) + "/64")) for host in [host1, host2]: for dev in [ host.eth0, host.eth1, host.tap0, host.tap1, host.bond0, host.vlan0, host.vlan1, host.br0, host.br1 ]: dev.up() for guest in [guest1, guest2, guest3, guest4]: guest.eth0.up() if "perf_tool_cpu" in self.params: logging.info("'perf_tool_cpu' param (%d) to be set to None" % self.params.perf_tool_cpu) self.params.perf_tool_cpu = None self.wait_tentative_ips(configuration.test_wide_devices) return configuration
def test(self): self.matched.m1.eth0.ip_add(ipaddress("192.168.1.1/24")) self.matched.m1.eth0.up() self.matched.m2.eth0.ip_add(ipaddress("192.168.1.2/24")) self.matched.m2.eth0.up() ping_job = self.matched.m1.run( Ping(dst=self.matched.m2.eth0, interval=0, iface=self.matched.m1.eth0)) netserver_job = self.matched.m1.run( Netserver(bind=self.matched.m1.eth0), bg=True) netperf_job = self.matched.m2.run( Netperf(server=self.matched.m1.eth0, duration=1, confidence="99,5", runs="5", debug=0, max_deviation={ 'type': "percent", 'value': 20.0 }, testname="TCP_STREAM")) netserver_job.kill(signal=signal.SIGINT) #examples of how to create soft devices self.matched.m1.eth0.down() m1 = self.matched.m1 eth0 = m1.eth0 #Bonding m1.bond = BondDevice(mode="active-backup", name="my_bond0") m1.bond.slave_add(eth0) m1.bond.up() m1.run("ip a") m1.bond.destroy() #Bridging m1.br = BridgeDevice() m1.br.slave_add(eth0) m1.br.up() m1.run("ip a") m1.br.destroy() #Teaming m1.team = TeamDevice() m1.team.slave_add(eth0) m1.team.up() m1.run("ip a") m1.team.destroy() #VethPair m1.veth0, m1.veth1 = VethPair() m1.veth0.up() m1.veth1.up() m1.run("ip a") m1.veth0.destroy() #Macvlan m1.mvlan = MacvlanDevice(realdev=eth0) m1.mvlan.up() m1.run("ip a") m1.mvlan.destroy() #Vlan eth0.up() m1.vlan = VlanDevice(realdev=eth0, vlan_id=123) m1.vlan.up() m1.run("ip a") m1.vlan.destroy() eth0.down() #Vti m1.vti = VtiDevice(local="1.2.3.4", ikey=123, okey=321) m1.vti.up() m1.run("ip a") m1.vti.destroy() #Vxlan m1.vxlan0 = VxlanDevice(vxlan_id=123, remote='1.2.3.4') m1.vxlan0.up() self.matched.m1.run("ip a") m1.vxlan0.destroy()
def test_wide_configuration(self): """ Test wide configuration for this recipe involves creating one bonding device on the first host. This device bonds two NICs matched by the recipe. The bonding mode and miimon interval is configured on the bonding device according to the recipe parameters. Then three VLAN (802.1Q) tunnels are created on top of the bonding device on the first host and on the matched NIC on the second host. The tunnels are configured with VLAN ids from vlan0_id, vlan1_id and vlan2_id params (by default: 10, 20, 30). An IPv4 and IPv6 address is configured on each tunnel endpoint. | host1.vlan0 = 192.168.10.1/24 and fc00:0:0:1::1/64 | host1.vlan1 = 192.168.20.1/24 and fc00:0:0:2::1/64 | host1.vlan2 = 192.168.30.1/24 and fc00:0:0:3::1/64 | host2.vlan0 = 192.168.10.2/24 and fc00:0:0:1::2/64 | host2.vlan1 = 192.168.20.2/24 and fc00:0:0:2::2/64 | host2.vlan2 = 192.168.30.2/24 and fc00:0:0:3::2/64 """ host1, host2 = self.matched.host1, self.matched.host2 host1.bond0 = BondDevice(mode=self.params.bonding_mode, miimon=self.params.miimon_value) for dev in [host1.eth0, host1.eth1]: dev.down() host1.bond0.slave_add(dev) host1.vlan0 = VlanDevice(realdev=host1.bond0, vlan_id=self.params.vlan0_id) host1.vlan1 = VlanDevice(realdev=host1.bond0, vlan_id=self.params.vlan1_id) host1.vlan2 = VlanDevice(realdev=host1.bond0, vlan_id=self.params.vlan2_id) host2.vlan0 = VlanDevice(realdev=host2.eth0, vlan_id=self.params.vlan0_id) host2.vlan1 = VlanDevice(realdev=host2.eth0, vlan_id=self.params.vlan1_id) host2.vlan2 = VlanDevice(realdev=host2.eth0, vlan_id=self.params.vlan2_id) configuration = super().test_wide_configuration() configuration.test_wide_devices = [] for host in [host1, host2]: configuration.test_wide_devices.extend([host.vlan0, host.vlan1, host.vlan2]) configuration.test_wide_devices.append(host1.bond0) net_addr = "192.168" net_addr6 = "fc00:0:0" for i, host in enumerate([host1, host2]): host.vlan0.ip_add(ipaddress('{}.10.{}/24'.format(net_addr, i+1))) host.vlan1.ip_add(ipaddress('{}.20.{}/24'.format(net_addr, i+1))) host.vlan2.ip_add(ipaddress('{}.30.{}/24'.format(net_addr, i+1))) host.vlan0.ip_add(ipaddress('{}:1::{}/64'.format(net_addr6, i+1))) host.vlan1.ip_add(ipaddress('{}:2::{}/64'.format(net_addr6, i+1))) host.vlan2.ip_add(ipaddress('{}:3::{}/64'.format(net_addr6, i+1))) for dev in [host1.eth0, host1.eth1, host1.bond0, host1.vlan0, host1.vlan1, host1.vlan2, host2.eth0, host2.vlan0, host2.vlan1, host2.vlan2]: dev.up() self.wait_tentative_ips(configuration.test_wide_devices) return configuration