Пример #1
0
 def create_bridge_port_fixture(self):
     bridge = self.useFixture(
         net_helpers.LinuxBridgeFixture(namespace=None)).bridge
     port_fixture = self.useFixture(
         net_helpers.LinuxBridgePortFixture(
             bridge, port_id=uuidutils.generate_uuid()))
     return bridge, port_fixture
Пример #2
0
    def test_plug_with_namespace_sets_mtu_higher_than_bridge(self):
        device_mtu = 1450

        # Create a new OVS bridge
        ovs_bridge = self.useFixture(net_helpers.OVSBridgeFixture()).bridge
        self.assertFalse(ovs_bridge.get_port_name_list())

        # Add a new linuxbridge port with reduced MTU to OVS bridge
        lb_bridge = self.useFixture(net_helpers.LinuxBridgeFixture()).bridge
        lb_bridge_port = self.useFixture(
            net_helpers.LinuxBridgePortFixture(lb_bridge))
        lb_bridge_port.port.link.set_mtu(device_mtu - 1)
        ovs_bridge.add_port(lb_bridge_port.port.name)

        # Now plug a device with intended MTU that is higher than for the port
        # above and validate that its MTU is not reduced to the least MTU on
        # the bridge
        device_name = utils.get_rand_name()
        mac_address = utils.get_random_mac('fa:16:3e:00:00:00'.split(':'))
        namespace = self.useFixture(net_helpers.NamespaceFixture()).name
        self.interface.plug(network_id=uuidutils.generate_uuid(),
                            port_id=uuidutils.generate_uuid(),
                            device_name=device_name,
                            mac_address=mac_address,
                            bridge=ovs_bridge.br_name,
                            namespace=namespace,
                            mtu=device_mtu)

        self.assertIn(device_name, ovs_bridge.get_port_name_list())
        self.assertTrue(ip_lib.device_exists(device_name, namespace))
        self.assertEqual(
            device_mtu,
            ip_lib.IPDevice(device_name, namespace=namespace).link.mtu)
Пример #3
0
    def setUp(self):
        cfg.CONF.register_opts(sg_cfg.security_group_opts, 'SECURITYGROUP')
        super(IptablesFirewallTestCase, self).setUp()
        bridge = self.useFixture(net_helpers.LinuxBridgeFixture()).bridge

        # FIXME(cbrandily): temporary, will be replaced by fake machines
        self.src_ip_wrapper = self.useFixture(
            net_helpers.NamespaceFixture()).ip_wrapper

        src_port_fixture = self.useFixture(
            net_helpers.LinuxBridgePortFixture(bridge,
                                               self.src_ip_wrapper.namespace))
        self.src_port = src_port_fixture.port
        self._set_ip_up(self.src_port, '%s/24' % self.SRC_ADDRESS)

        self.dst_ip_wrapper = self.useFixture(
            net_helpers.NamespaceFixture()).ip_wrapper
        self.dst_port = self.useFixture(
            net_helpers.LinuxBridgePortFixture(
                bridge, self.dst_ip_wrapper.namespace)).port
        self._set_ip_up(self.dst_port, '%s/24' % self.DST_ADDRESS)

        self.firewall = iptables_firewall.IptablesFirewallDriver(
            namespace=bridge.namespace)

        self._set_src_mac(self.MAC_REAL)

        self.src_port_desc = {
            'admin_state_up': True,
            'device': src_port_fixture.br_port.name,
            'device_owner': 'compute:None',
            'fixed_ips': [self.SRC_ADDRESS],
            'mac_address': self.MAC_REAL,
            'port_security_enabled': True,
            'security_groups': [self.FAKE_SECURITY_GROUP_ID],
            'status': 'ACTIVE'
        }
Пример #4
0
    def test_plug_with_namespace_sets_mtu_higher_than_bridge(self):
        # First, add a new linuxbridge port with reduced MTU to OVS bridge
        lb_bridge = self.useFixture(net_helpers.LinuxBridgeFixture()).bridge
        lb_bridge_port = self.useFixture(
            net_helpers.LinuxBridgePortFixture(lb_bridge))
        lb_bridge_port.port.link.set_mtu(1400)
        self.bridge.add_port(lb_bridge_port.port.name)

        device_name = utils.get_rand_name()
        namespace = self.useFixture(net_helpers.NamespaceFixture()).name

        # Now plug a device with intended MTU that is higher than for the port
        # above and validate that its MTU is not reduced to the least MTU on
        # the bridge
        self._test_mtu_set_after_action(device_name, self.bridge_name,
                                        namespace)
Пример #5
0
        def callback(br_fixture):
            # TODO(cbrandily): refactor net_helpers to avoid mocking it
            mock.patch.object(
                net_helpers, 'VETH0_PREFIX',
                new_callable=mock.PropertyMock(
                    return_value=constants.TAP_DEVICE_PREFIX + '0')).start()
            mock.patch.object(
                net_helpers, 'VETH1_PREFIX',
                new_callable=mock.PropertyMock(
                    return_value=constants.TAP_DEVICE_PREFIX + '1')).start()

            self.useFixture(
                tools.SafeCleanupFixture(
                    net_helpers.LinuxBridgePortFixture(
                        br_fixture.bridge, br_fixture.namespace)))
            return config_fixtures.ConfigDict()
Пример #6
0
 def create_bridge_port_fixture(self):
     bridge = self.useFixture(
         net_helpers.LinuxBridgeFixture(namespace=None)).bridge
     port_fixture = self.useFixture(
         net_helpers.LinuxBridgePortFixture(bridge))
     return bridge, port_fixture