コード例 #1
0
    def setUp(self):
        super(IptablesManagerTestCase, self).setUp()

        bridge = self.useFixture(net_helpers.VethBridgeFixture()).bridge
        self.client, self.server = self.useFixture(
            machine_fixtures.PeerMachines(bridge)).machines

        self.client_fw, self.server_fw = self.create_firewalls()
        # The port is used in isolated namespace that precludes possibility of
        # port conflicts
        self.port = helpers.get_free_namespace_port(self.server.namespace)
コード例 #2
0
ファイル: test_ipset.py プロジェクト: tatuhiro-furuya/neutron
    def setUp(self):
        super(IpsetBase, self).setUp()

        bridge = self.useFixture(net_helpers.VethBridgeFixture()).bridge
        self.source, self.destination = self.useFixture(
            machine_fixtures.PeerMachines(bridge)).machines

        self.ipset = self._create_ipset_manager_and_set(
            ip_lib.IPWrapper(self.destination.namespace), IPSET_SET)

        self.dst_iptables = iptables_manager.IptablesManager(
            namespace=self.destination.namespace)

        self._add_iptables_ipset_rules(self.dst_iptables)
コード例 #3
0
ファイル: test_ipset.py プロジェクト: williamwang0/MusicGen
    def setUp(self):
        super(IpsetBase, self).setUp()

        bridge = self.useFixture(net_helpers.VethBridgeFixture()).bridge
        self.source, self.destination = self.useFixture(
            machine_fixtures.PeerMachines(bridge)).machines

        self.ipset_name = utils.get_rand_name(MAX_IPSET_NAME_LENGTH, 'set-')
        self.icmp_accept_rule = (
            '-p icmp -m set --match-set %s src -j ACCEPT' % self.ipset_name)
        self.ipset = self._create_ipset_manager_and_set(
            ip_lib.IPWrapper(self.destination.namespace), self.ipset_name)
        self.addCleanup(self.ipset._destroy, self.ipset_name)
        self.dst_iptables = iptables_manager.IptablesManager(
            namespace=self.destination.namespace)

        self._add_iptables_ipset_rules()
        self.addCleanup(self._remove_iptables_ipset_rules)
コード例 #4
0
    def setUp(self):
        super(EbtablesLowLevelTestCase, self).setUp()

        bridge = self.useFixture(net_helpers.VethBridgeFixture()).bridge
        self.source, self.destination = self.useFixture(
            machine_fixtures.PeerMachines(bridge)).machines

        # Extract MAC and IP address of one of my interfaces
        self.mac = self.source.port.link.address
        self.addr = self.source.ip

        # Pick one of the namespaces and setup a bridge for the local ethernet
        # interface there, because ebtables only works on bridged interfaces.
        dev_mybridge = bridge_lib.BridgeDevice.addbr('mybridge',
                                                     self.source.namespace)
        dev_mybridge.addif(self.source.port.name)

        # Take the IP addrss off one of the interfaces and apply it to the
        # bridge interface instead.
        self.source.port.addr.delete(self.source.ip_cidr)
        dev_mybridge.link.set_up()
        dev_mybridge.addr.add(self.source.ip_cidr)