コード例 #1
0
ファイル: GreOvsTunnelRecipe.py プロジェクト: pgagne/lnst
    def create_tunnel(self, configuration):
        """
        OvS bridges are created on each of the matched hosts with two ports.
        One port as an integration port and another port of type GRE acting
        as a tunnel interface connecting tunneled networks.

        Integration ports are configured with IPv4 and IPv6 addresses
        of the tunneled networks.
        """
        endpoint1, endpoint2 = configuration.tunnel_endpoints
        m1 = endpoint1.netns
        m2 = endpoint2.netns
        ip_filter = {"family": AF_INET}

        for i, (host, endpoint) in enumerate([(m1, endpoint2),
                                              (m2, endpoint1)]):
            remote_ip = endpoint.ips_filter(**ip_filter)[0]
            host.br0 = OvsBridgeDevice()
            host.int0 = host.br0.port_add(
                interface_options={"type": "internal"})
            configuration.tunnel_devices.append(host.int0)
            host.int0.ip_add(ipaddress("192.168.200." + str(i + 1) + "/24"))
            host.int0.ip_add(ipaddress("fc00::" + str(i + 1) + "/64"))

            host.br0.tunnel_add("gre", {"options:remote_ip": remote_ip})

            host.br0.up()
            host.int0.up()

        self.wait_tentative_ips(configuration.tunnel_devices)
コード例 #2
0
    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, 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
コード例 #3
0
    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, port_name in [(host1, "bond_port1"), (host2, "bond_port2")]:
            for dev in [host.eth0, host.eth1, host.tap0, host.tap1]:
                dev.down()
            host.br0 = OvsBridgeDevice()
            host.br0.port_add(device=host.tap0,
                              port_options={'tag': self.params.vlan0_id})
            host.br0.port_add(device=host.tap1,
                              port_options={'tag': self.params.vlan1_id})
            #miimon cannot be set due to colon in argument name -->
            #other_config:bond-miimon-interval
            host.br0.bond_add(port_name, (host.eth0, host.eth1),
                              bond_mode=self.params.bonding_mode)

        guest1.eth0.down()
        guest2.eth0.down()
        guest3.eth0.down()
        guest4.eth0.down()

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [
            guest1.eth0, guest2.eth0, guest3.eth0, guest4.eth0
        ]

        net_addr_1 = "192.168.10"
        net_addr6_1 = "fc00:0:0:1"
        net_addr_2 = "192.168.20"
        net_addr6_2 = "fc00:0:0:2"

        for i, guest in enumerate([guest1, guest3]):
            guest.eth0.ip_add(ipaddress(net_addr_1 + "." + str(i + 1) + "/24"))
            guest.eth0.ip_add(
                ipaddress(net_addr6_1 + "::" + str(i + 1) + "/64"))

        for i, guest in enumerate([guest2, guest4]):
            guest.eth0.ip_add(ipaddress(net_addr_2 + "." + str(i + 1) + "/24"))
            guest.eth0.ip_add(
                ipaddress(net_addr6_2 + "::" + str(i + 1) + "/64"))

        for host in [host1, host2]:
            for dev in [host.eth0, host.eth1, host.tap0, host.tap1, host.br0]:
                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
コード例 #4
0
    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]:
            host.eth0.down()
            host.tap0.down()
            host.tap1.down()
        for guest in [guest1, guest2, guest3, guest4]:
            guest.eth0.down()

        net_addr = "192.168.2"
        vxlan_net_addr = "192.168.100"
        vxlan_net_addr6 = "fc00:0:0:0"

        flow_entries=[]
        flow_entries.append("table=0,in_port=5,actions=set_field:100->"
            "tun_id,output:10")
        flow_entries.append("table=0,in_port=6,actions=set_field:200->"
            "tun_id,output:10")
        flow_entries.append("table=0,in_port=10,tun_id=100,actions="
            "output:5")
        flow_entries.append("table=0,in_port=10,tun_id=200,actions="
            "output:6")
        flow_entries.append("table=0,priority=100,actions=drop")

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [host1.eth0, host2.eth0,
            guest1.eth0, guest2.eth0, guest3.eth0, guest4.eth0]

        for i, host in enumerate([host1, host2]):
            host.eth0.ip_add(ipaddress(net_addr + "." + str(i+1) + "/24"))
            host.br0 = OvsBridgeDevice()
            for dev, ofport_r in [(host.tap0, '5'), (host.tap1, '6')]:
                host.br0.port_add(
                        device=dev,
                        interface_options={'ofport_request': ofport_r})
            tunnel_opts = {"option:remote_ip" : net_addr + "." + str(2-i),
                "option:key" : "flow", "ofport_request" : '10'}
            host.br0.tunnel_add("vxlan", tunnel_opts)
            host.br0.flows_add(flow_entries)
            for dev in [host.eth0, host.tap0, host.tap1, host.br0]:
                dev.up()

        for i, guest in enumerate([guest1, guest2, guest3, guest4]):
            guest.eth0.ip_add(ipaddress(vxlan_net_addr + "." + str(i+1) +
                "/24"))
            guest.eth0.ip_add(ipaddress(vxlan_net_addr6 + "::" + str(i+1) +
                "/64"))
            guest.eth0.up()

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
コード例 #5
0
ファイル: NoVirtOvsVxlanRecipe.py プロジェクト: pgagne/lnst
    def test_wide_configuration(self):
        host1, host2 = self.matched.host1, self.matched.host2

        net_addr = "192.168.2"
        vxlan_net_addr = "192.168.100"
        vxlan_net_addr6 = "fc00:0:0:0"

        flow_entries = []
        flow_entries.append("table=0,in_port=5,actions=set_field:100->"
                            "tun_id,output:10")
        flow_entries.append("table=0,in_port=10,tun_id=100,actions="
                            "output:5")
        flow_entries.append("table=0,priority=100,actions=drop")

        for i, host in enumerate([host1, host2]):
            host.eth0.down()
            host.eth0.ip_add(ipaddress(net_addr + "." + str(i + 1) + "/24"))
            host.br0 = OvsBridgeDevice()
            host.int0 = host.br0.port_add(interface_options={
                'type': 'internal',
                'ofport_request': 5,
                'name': 'int0'
            })
            host.int0.ip_add(
                ipaddress(vxlan_net_addr + "." + str(i + 1) + "/24"))
            host.int0.ip_add(
                ipaddress(vxlan_net_addr6 + "::" + str(i + 1) + "/64"))
            tunnel_opts = {
                "option:remote_ip": net_addr + "." + str(2 - i),
                "option:key": "flow",
                "ofport_request": "10"
            }
            host.br0.tunnel_add("vxlan", tunnel_opts)
            host.br0.flows_add(flow_entries)
            host.eth0.up()
            host.int0.up()
            host.br0.up()

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [
            host1.eth0, host1.int0, host2.eth0, host2.int0
        ]

        self.wait_tentative_ips(configuration.test_wide_devices)

        return configuration
コード例 #6
0
ファイル: VxlanOvsTunnelRecipe.py プロジェクト: pgagne/lnst
    def create_tunnel(self, configuration):
        """
        OvS bridges are created on each of the matched hosts with two ports.
        One port as an integration port and another port of type VXLAN acting
        as a tunnel interface connecting tunneled networks.

        Integration ports are configured with IPv4 and IPv6 addresses
        of the tunneled networks.
        """
        endpoint1, endpoint2 = configuration.tunnel_endpoints
        m1 = endpoint1.netns
        m2 = endpoint2.netns
        ip_filter = {"family": AF_INET}

        for i, (host, endpoint) in enumerate([(m1, endpoint2), (m2, endpoint1)]):
            remote_ip = endpoint.ips_filter(**ip_filter)[0]
            host.br0 = OvsBridgeDevice()
            host.int0 = host.br0.port_add(
                interface_options={"type": "internal", "ofport_request": 5}
            )
            configuration.tunnel_devices.append(host.int0)
            host.int0.ip_add(ipaddress("192.168.200." + str(i + 1) + "/24"))
            host.int0.ip_add(ipaddress("fc00::" + str(i + 1) + "/64"))

            host.br0.tunnel_add(
                "vxlan",
                {
                    "options:remote_ip": remote_ip,
                    "options:key": "flow",
                    "ofport_request": 10,
                },
            )

            host.br0.flows_add(
                [
                    "table=0,in_port=5,actions=set_field:1234->tun_id,output:10",
                    "table=0,in_port=10,tun_id=1234,actions=output:5",
                    "table=0,priority=100,actions=drop",
                ]
            )

            host.br0.up()
            host.int0.up()

        self.wait_tentative_ips(configuration.tunnel_devices)
コード例 #7
0
    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.eth0.down()
            host.tap0.down()
            host.br0 = OvsBridgeDevice()
            for dev in [host.eth0, host.tap0]:
                host.br0.port_add(device=dev)

        guest1.eth0.down()
        guest2.eth0.down()

        guest1.vlan0 = VlanDevice(realdev=guest1.eth0, vlan_id=10)
        guest2.vlan0 = VlanDevice(realdev=guest2.eth0, vlan_id=10)

        configuration = super().test_wide_configuration()
        configuration.test_wide_devices = [guest1.vlan0, guest2.vlan0]

        net_addr_1 = "192.168.10"
        net_addr6_1 = "fc00:0:0:1"
        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