Ejemplo n.º 1
0
 def add_vxlan(self, name, vni, group=None, dev=None, ttl=None, tos=None,
               local=None, srcport=None, dstport=None, proxy=False):
     kwargs = {'vxlan_id': vni}
     if group:
         kwargs['vxlan_group'] = group
     if dev:
         kwargs['physical_interface'] = dev
     if ttl:
         kwargs['vxlan_ttl'] = ttl
     if tos:
         kwargs['vxlan_tos'] = tos
     if local:
         kwargs['vxlan_local'] = local
     if proxy:
         kwargs['vxlan_proxy'] = proxy
     # tuple: min,max
     if srcport:
         if len(srcport) == 2 and srcport[0] <= srcport[1]:
             kwargs['vxlan_port_range'] = (str(srcport[0]), str(srcport[1]))
         else:
             raise n_exc.NetworkVxlanPortRangeError(vxlan_range=srcport)
     if dstport:
         kwargs['vxlan_port'] = dstport
     privileged.create_interface(name, self.namespace, "vxlan", **kwargs)
     return (IPDevice(name, namespace=self.namespace))
Ejemplo n.º 2
0
 def add_vlan(self, name, physical_interface, vlan_id):
     privileged.create_interface(name,
                                 self.namespace,
                                 "vlan",
                                 physical_interface=physical_interface,
                                 vlan_id=vlan_id)
     return IPDevice(name, namespace=self.namespace)
Ejemplo n.º 3
0
 def setUp(self):
     super(TcFilterClassTestCase, self).setUp()
     self.namespace = 'ns_test-' + uuidutils.generate_uuid()
     priv_ip_lib.create_netns(self.namespace)
     self.addCleanup(self._remove_ns, self.namespace)
     self.device = 'int_dummy'
     priv_ip_lib.create_interface('int_dummy', self.namespace, 'dummy')
Ejemplo n.º 4
0
    def test_get_ip_addresses(self):
        namespace = 'ns_test-' + uuidutils.generate_uuid()
        priv_ip_lib.create_netns(namespace)
        self.addCleanup(self._remove_ns, namespace)
        interfaces = {
            '20': {'cidr': '192.168.10.20/24', 'scope': 'link',
                   'add_broadcast': True},
            '30': {'cidr': '2001::1/64', 'scope': 'global',
                   'add_broadcast': False}}

        for int_name, int_parameters in interfaces.items():
            priv_ip_lib.create_interface(int_name, namespace, 'dummy',
                                         index=int(int_name))
            ip_lib.add_ip_address(
                int_parameters['cidr'], int_name, namespace,
                int_parameters['scope'], int_parameters['add_broadcast'])

        ip_addresses = priv_ip_lib.get_ip_addresses(namespace)
        for ip_address in ip_addresses:
            int_name = str(ip_address['index'])
            ip = _get_attr(ip_address, 'IFA_ADDRESS')
            mask = ip_address['prefixlen']
            cidr = common_utils.ip_to_cidr(ip, mask)
            self.assertEqual(interfaces[int_name]['cidr'], cidr)
            self.assertEqual(interfaces[int_name]['scope'],
                             ip_lib.IP_ADDRESS_SCOPE[ip_address['scope']])
Ejemplo n.º 5
0
 def setUp(self):
     super(TcQdiscTestCase, self).setUp()
     self.namespace = 'ns_test-' + uuidutils.generate_uuid()
     priv_ip_lib.create_netns(self.namespace)
     self.addCleanup(self._remove_ns, self.namespace)
     self.device = 'int_dummy'
     priv_ip_lib.create_interface(self.device, self.namespace, 'dummy')
Ejemplo n.º 6
0
 def add_macvtap(self, name, src_dev, mode='bridge'):
     privileged.create_interface(name,
                                 self.namespace,
                                 "macvtap",
                                 physical_interface=src_dev,
                                 mode=mode)
     return IPDevice(name, namespace=self.namespace)
Ejemplo n.º 7
0
    def test_get_ip_addresses(self):
        namespace = 'ns_test-' + uuidutils.generate_uuid()
        priv_ip_lib.create_netns(namespace)
        self.addCleanup(self._remove_ns, namespace)
        interfaces = {
            '20': {
                'cidr': '192.168.10.20/24',
                'scope': 'link',
                'add_broadcast': True
            },
            '30': {
                'cidr': '2001::1/64',
                'scope': 'global',
                'add_broadcast': False
            }
        }

        for int_name, int_parameters in interfaces.items():
            priv_ip_lib.create_interface(int_name,
                                         namespace,
                                         'dummy',
                                         index=int(int_name))
            ip_lib.add_ip_address(int_parameters['cidr'], int_name, namespace,
                                  int_parameters['scope'],
                                  int_parameters['add_broadcast'])

        ip_addresses = priv_ip_lib.get_ip_addresses(namespace)
        for ip_address in ip_addresses:
            int_name = str(ip_address['index'])
            ip = ip_lib.get_attr(ip_address, 'IFA_ADDRESS')
            mask = ip_address['prefixlen']
            cidr = common_utils.ip_to_cidr(ip, mask)
            self.assertEqual(interfaces[int_name]['cidr'], cidr)
            self.assertEqual(interfaces[int_name]['scope'],
                             ip_lib.IP_ADDRESS_SCOPE[ip_address['scope']])
Ejemplo n.º 8
0
    def _ensure_vrf(self, vrf, vrf_ip, cidr):
        """Ensure vrf interface

        return: vrf_table
        """
        if self.vrf_tables:
            vrf_table = max(list(self.vrf_tables.values())) + 1
        else:
            vrf_table = VRF_TABLE_NAMBER_BASE
        if vrf not in list(self.vrf_tables):
            privileged.create_interface(vrf, None, "vrf", vrf_table=vrf_table)
            privileged.set_link_attribute(vrf, None, state="up")

            LOG.debug("VRF %s is created" % vrf)
            self.vrf_tables[vrf] = vrf_table

            # TODO(hichihara): Refactor to use ip_lib instead of command
            ip = vrf_ip + '/' + cidr
            self._setup_interface_ip(ip, vrf)
            cmd = ["ip", "route", "replace", vrf_ip, "dev", vrf]
            utils.execute(cmd, run_as_root=True, check_exit_code=False)
            vrf_sid = ("%(node_id)s:%(vrf_ip)s/128" % {
                "node_id": self.node_id,
                "vrf_ip": vrf_ip
            })
            self._setup_interface_ip(vrf_sid, vrf)
            self._setup_interface_ip("169.254.169.254/32", vrf)
            # Create encap rules
            for encap_info in self.encap_info:
                if vrf == encap_info['vrf']:
                    self.add_encap_rules([encap_info], add_flag=False)
                    break
        else:
            vrf_table = self.vrf_tables[vrf]
        return vrf_table
Ejemplo n.º 9
0
    def test_show(self):
        ip_str = str(netaddr.IPNetwork(self.ip).ip)
        bridge_lib.FdbInterface.add(self.MAC1,
                                    self.device_vxlan,
                                    namespace=self.namespace,
                                    dst_ip=ip_str)
        rules = bridge_lib.FdbInterface.show(dev=self.device_vxlan,
                                             namespace=self.namespace)
        self.assertEqual(1, len(rules))
        self.assertEqual(1, len(rules[self.device_vxlan]))
        self.assertEqual(self.MAC1, rules[self.device_vxlan][0]['mac'])
        self.assertEqual(ip_str, rules[self.device_vxlan][0]['dst_ip'])

        _uuid = uuidutils.generate_uuid()
        bridge_name = ('br_' + _uuid)[:constants.DEVICE_NAME_MAX_LEN]
        priv_ip_lib.create_interface(bridge_name, self.namespace, 'bridge')
        bridge = bridge_lib.BridgeDevice(bridge_name, namespace=self.namespace)
        bridge.addif(self.device)
        rules = bridge_lib.FdbInterface.show(dev=bridge_name,
                                             namespace=self.namespace)
        self.assertEqual(1, len(rules))
        self._assert_mac(MAC_ALL_NODES_ADDRESS, bridge_name)

        rules = bridge_lib.FdbInterface.show(dev=self.device,
                                             namespace=self.namespace)
        mac_address = ip_lib.IPDevice(self.device, self.namespace).link.address
        for rule in (rule for rule in rules[self.device]
                     if rule['mac'] == mac_address):
            self.assertEqual(bridge_name, rule['master'])
            self.assertIn(rule['vlan'], (1, None))
Ejemplo n.º 10
0
    def test_get_devices_info_vlan(self):
        interfaces_tested = []
        vlan_interfaces = []
        vlan_id = 1000
        for interface in self.interfaces:
            priv_ip_lib.create_interface(interface, self.namespace, 'dummy')
            vlan_interface = interface + '_' + str(vlan_id)
            vlan_interfaces.append(vlan_interface)
            priv_ip_lib.create_interface(vlan_interface,
                                         self.namespace,
                                         'vlan',
                                         physical_interface=interface,
                                         vlan_id=vlan_id)
            vlan_id += 1

        devices = priv_ip_lib.get_link_devices(self.namespace)
        self.assertGreater(len(devices), 0)
        for device in devices:
            name = ip_lib.get_attr(device, 'IFLA_IFNAME')
            if name in self.interfaces_to_exclude:
                continue
            self.assertIn(name, self.interfaces + vlan_interfaces)
            ifla_linkinfo = ip_lib.get_attr(device, 'IFLA_LINKINFO')
            if name in vlan_interfaces:
                self.assertEqual(
                    ip_lib.get_attr(ifla_linkinfo, 'IFLA_INFO_KIND'), 'vlan')
                ifla_infodata = ip_lib.get_attr(ifla_linkinfo,
                                                'IFLA_INFO_DATA')
                vlan_id = int(name.split('_')[-1])
                self.assertEqual(
                    ip_lib.get_attr(ifla_infodata, 'IFLA_VLAN_ID'), vlan_id)
            interfaces_tested.append(name)
        self.assertEqual(sorted(interfaces_tested),
                         sorted(self.interfaces + vlan_interfaces))
Ejemplo n.º 11
0
 def add_vlan(self, name, physical_interface, vlan_id):
     privileged.create_interface(name,
                                 self.namespace,
                                 "vlan",
                                 physical_interface=physical_interface,
                                 vlan_id=vlan_id)
     return IPDevice(name, namespace=self.namespace)
Ejemplo n.º 12
0
    def test_add_rule_priority_table_iif(self):
        table = 213
        priority = 12346
        iif = 'iif_device_2'
        priv_ip_lib.create_interface(iif, self.namespace, 'dummy')
        priv_ip_lib.add_ip_rule(self.namespace,
                                priority=priority,
                                iifname=iif,
                                table=table)

        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self._check_rules(
            rules, ['priority', 'iif', 'table'],
            [str(priority), iif, str(table)],
            'priority %s, table %s and iif name %s' % (priority, table, iif))

        priv_ip_lib.delete_ip_rule(self.namespace,
                                   priority=priority,
                                   iifname=iif,
                                   table=table)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self.assertFalse(
            self._check_rules(
                rules, ['priority', 'iif', 'table'],
                [str(priority), iif, str(table)],
                raise_exception=False))
Ejemplo n.º 13
0
 def add_vxlan(self,
               name,
               vni,
               group=None,
               dev=None,
               ttl=None,
               tos=None,
               local=None,
               srcport=None,
               dstport=None,
               proxy=False):
     kwargs = {'vxlan_id': vni}
     if group:
         kwargs['vxlan_group'] = group
     if dev:
         kwargs['physical_interface'] = dev
     if ttl:
         kwargs['vxlan_ttl'] = ttl
     if tos:
         kwargs['vxlan_tos'] = tos
     if local:
         kwargs['vxlan_local'] = local
     if proxy:
         kwargs['vxlan_proxy'] = proxy
     # tuple: min,max
     if srcport:
         if len(srcport) == 2 and srcport[0] <= srcport[1]:
             kwargs['vxlan_port_range'] = (str(srcport[0]), str(srcport[1]))
         else:
             raise n_exc.NetworkVxlanPortRangeError(vxlan_range=srcport)
     if dstport:
         kwargs['vxlan_port'] = dstport
     privileged.create_interface(name, self.namespace, "vxlan", **kwargs)
     return (IPDevice(name, namespace=self.namespace))
Ejemplo n.º 14
0
 def add_macvtap(self, name, src_dev, mode='bridge'):
     privileged.create_interface(name,
                                 self.namespace,
                                 "macvtap",
                                 physical_interface=src_dev,
                                 mode=mode)
     return IPDevice(name, namespace=self.namespace)
Ejemplo n.º 15
0
    def test_add_rule_iif(self):
        iif = 'iif_device_1'
        priv_ip_lib.create_interface(iif, self.namespace, 'dummy')
        priv_ip_lib.add_ip_rule(self.namespace, iifname=iif)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self._check_rules(rules, ['iif'], [iif], 'iif name %s' % iif)

        priv_ip_lib.delete_ip_rule(self.namespace, iifname=iif)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self.assertFalse(
            self._check_rules(rules, ['iif'], [iif], raise_exception=False))
Ejemplo n.º 16
0
 def test_vlan_exists(self):
     attr = self.generate_device_details()
     ip = ip_lib.IPWrapper(namespace=attr.namespace)
     ip.netns.add(attr.namespace)
     self.addCleanup(ip.netns.delete, attr.namespace)
     priv_ip_lib.create_interface(attr.name, attr.namespace, 'dummy')
     self.assertFalse(ip_lib.vlan_in_use(1999, namespace=attr.namespace))
     device = ip.add_vlan('vlan1999', attr.name, 1999)
     self.assertTrue(ip_lib.vlan_in_use(1999, namespace=attr.namespace))
     device.link.delete()
     self.assertFalse(ip_lib.vlan_in_use(1999, namespace=attr.namespace))
Ejemplo n.º 17
0
    def test_add_rule_iif(self):
        iif = 'iif_device_1'
        priv_ip_lib.create_interface(iif, self.namespace, 'dummy')
        priv_ip_lib.add_ip_rule(self.namespace, iifname=iif)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self._check_rules(rules, ['iif'], [iif], 'iif name %s' % iif)

        priv_ip_lib.delete_ip_rule(self.namespace, iifname=iif)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self.assertFalse(
            self._check_rules(rules, ['iif'], [iif], raise_exception=False))
Ejemplo n.º 18
0
 def test_vlan_exists(self):
     attr = self.generate_device_details()
     ip = ip_lib.IPWrapper(namespace=attr.namespace)
     ip.netns.add(attr.namespace)
     self.addCleanup(ip.netns.delete, attr.namespace)
     priv_ip_lib.create_interface(attr.name, attr.namespace, 'dummy')
     self.assertFalse(ip_lib.vlan_in_use(1999, namespace=attr.namespace))
     device = ip.add_vlan('vlan1999', attr.name, 1999)
     self.assertTrue(ip_lib.vlan_in_use(1999, namespace=attr.namespace))
     device.link.delete()
     self.assertFalse(ip_lib.vlan_in_use(1999, namespace=attr.namespace))
Ejemplo n.º 19
0
    def add_veth(self, name1, name2, namespace2=None):
        peer = {'ifname': name2}

        if namespace2 is None:
            namespace2 = self.namespace
        else:
            self.ensure_namespace(namespace2)
            peer['net_ns_fd'] = namespace2

        privileged.create_interface(name1, self.namespace, 'veth', peer=peer)

        return (IPDevice(name1, namespace=self.namespace),
                IPDevice(name2, namespace=namespace2))
Ejemplo n.º 20
0
    def test_add_rule_exists(self):
        iif = 'iif_device_1'
        priv_ip_lib.create_interface(iif, self.namespace, 'dummy')
        priv_ip_lib.add_ip_rule(self.namespace, iifname=iif)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self._check_rules(rules, ['iif'], [iif], 'iif name %s' % iif)
        self.assertEqual(4, len(rules))

        # pyroute2.netlink.exceptions.NetlinkError(17, 'File exists')
        # exception is catch.
        priv_ip_lib.add_ip_rule(self.namespace, iifname=iif)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self._check_rules(rules, ['iif'], [iif], 'iif name %s' % iif)
        self.assertEqual(4, len(rules))
Ejemplo n.º 21
0
    def test_add_rule_exists(self):
        iif = 'iif_device_1'
        priv_ip_lib.create_interface(iif, self.namespace, 'dummy')
        priv_ip_lib.add_ip_rule(self.namespace, iifname=iif)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self._check_rules(rules, ['iif'], [iif], 'iif name %s' % iif)
        self.assertEqual(4, len(rules))

        # pyroute2.netlink.exceptions.NetlinkError(17, 'File exists')
        # exception is catch.
        priv_ip_lib.add_ip_rule(self.namespace, iifname=iif)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self._check_rules(rules, ['iif'], [iif], 'iif name %s' % iif)
        self.assertEqual(4, len(rules))
Ejemplo n.º 22
0
    def test_get_devices_info_vxlan(self):
        interfaces_tested = []
        vxlan_interfaces = []
        vxlan_id = 1000
        for interface in self.interfaces:
            priv_ip_lib.create_interface(interface, self.namespace, 'dummy')
            vxlan_interface = interface + '_' + str(vxlan_id)
            vxlan_interfaces.append(vxlan_interface)
            priv_ip_lib.create_interface(vxlan_interface,
                                         self.namespace,
                                         'vxlan',
                                         physical_interface=interface,
                                         vxlan_id=vxlan_id,
                                         vxlan_group='239.1.1.1')
            vxlan_id += 1

        devices = priv_ip_lib.get_link_devices(self.namespace)
        self.assertGreater(len(devices), 0)
        device_name_index = {}
        for device in devices:
            name = ip_lib.get_attr(device, 'IFLA_IFNAME')
            device_name_index[name] = device['index']

        for device in devices:
            name = ip_lib.get_attr(device, 'IFLA_IFNAME')
            if name in self.interfaces_to_exclude:
                continue
            self.assertIn(name, self.interfaces + vxlan_interfaces)
            ifla_linkinfo = ip_lib.get_attr(device, 'IFLA_LINKINFO')
            if name in vxlan_interfaces:
                self.assertEqual(
                    ip_lib.get_attr(ifla_linkinfo, 'IFLA_INFO_KIND'), 'vxlan')
                ifla_infodata = ip_lib.get_attr(ifla_linkinfo,
                                                'IFLA_INFO_DATA')
                vxlan_id = int(name.split('_')[-1])
                self.assertEqual(
                    ip_lib.get_attr(ifla_infodata, 'IFLA_VXLAN_ID'), vxlan_id)
                self.assertEqual(
                    ip_lib.get_attr(ifla_infodata, 'IFLA_VXLAN_GROUP'),
                    '239.1.1.1')
                vxlan_link_name = self.interfaces[vxlan_interfaces.index(name)]
                vxlan_link_index = device_name_index[vxlan_link_name]
                self.assertEqual(
                    vxlan_link_index,
                    ip_lib.get_attr(ifla_infodata, 'IFLA_VXLAN_LINK'))
            interfaces_tested.append(name)
        self.assertEqual(sorted(interfaces_tested),
                         sorted(self.interfaces + vxlan_interfaces))
Ejemplo n.º 23
0
    def test_get_devices_info_dummy(self):
        interfaces_tested = []
        for interface in self.interfaces:
            priv_ip_lib.create_interface(interface, self.namespace, 'dummy')

        devices = priv_ip_lib.get_link_devices(self.namespace)
        self.assertGreater(len(devices), 0)
        for device in devices:
            name = ip_lib.get_attr(device, 'IFLA_IFNAME')
            if name in self.interfaces_to_exclude:
                continue
            self.assertIn(name, self.interfaces)
            ifla_linkinfo = ip_lib.get_attr(device, 'IFLA_LINKINFO')
            self.assertEqual(ip_lib.get_attr(ifla_linkinfo, 'IFLA_INFO_KIND'),
                             'dummy')
            interfaces_tested.append(name)
        self.assertEqual(sorted(interfaces_tested), sorted(self.interfaces))
Ejemplo n.º 24
0
    def test_get_devices(self):
        namespace = 'ns_test-' + uuidutils.generate_uuid()
        priv_ip_lib.create_netns(namespace)
        self.addCleanup(self._remove_ns, namespace)
        interfaces = ['int_01', 'int_02', 'int_03', 'int_04', 'int_05']
        interfaces_to_check = (interfaces + ip_lib.FB_TUNNEL_DEVICE_NAMES +
                               [ip_lib.LOOPBACK_DEVNAME])
        for interface in interfaces:
            priv_ip_lib.create_interface(interface, namespace, 'dummy')

        device_names = priv_ip_lib.get_devices(namespace)
        for name in device_names:
            self.assertIn(name, interfaces_to_check)

        for interface in interfaces:
            priv_ip_lib.delete_interface(interface, namespace)

        device_names = priv_ip_lib.get_devices(namespace)
        for name in device_names:
            self.assertNotIn(name, interfaces)
Ejemplo n.º 25
0
    def test_add_rule_priority_table_iif(self):
        table = 213
        priority = 12346
        iif = 'iif_device_2'
        priv_ip_lib.create_interface(iif, self.namespace, 'dummy')
        priv_ip_lib.add_ip_rule(self.namespace, priority=priority, iifname=iif,
                                table=table)

        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self._check_rules(
            rules, ['priority', 'iif', 'table'],
            [str(priority), iif, str(table)],
            'priority %s, table %s and iif name %s' % (priority, table, iif))

        priv_ip_lib.delete_ip_rule(self.namespace, priority=priority,
                                   iifname=iif, table=table)
        rules = ip_lib.list_ip_rules(self.namespace, 4)
        self.assertFalse(
            self._check_rules(rules, ['priority', 'iif', 'table'],
                              [str(priority), iif, str(table)],
                              raise_exception=False))
Ejemplo n.º 26
0
    def test_get_device_names(self):
        namespace = 'ns_test-' + uuidutils.generate_uuid()
        priv_ip_lib.create_netns(namespace)
        self.addCleanup(self._remove_ns, namespace)
        interfaces = ['int_01', 'int_02', 'int_03', 'int_04', 'int_05']
        interfaces_to_check = (interfaces + ip_lib.FB_TUNNEL_DEVICE_NAMES +
                               [ip_lib.LOOPBACK_DEVNAME])
        for interface in interfaces:
            priv_ip_lib.create_interface(interface, namespace, 'dummy')

        device_names = priv_ip_lib.get_device_names(namespace)
        self.assertGreater(len(device_names), 0)
        for name in device_names:
            self.assertIn(name, interfaces_to_check)

        for interface in interfaces:
            priv_ip_lib.delete_interface(interface, namespace)

        device_names = priv_ip_lib.get_device_names(namespace)
        self.assertGreater(len(device_names), 0)
        for name in device_names:
            self.assertNotIn(name, interfaces)
Ejemplo n.º 27
0
    def test_get_devices_info_veth_different_namespaces(self):
        namespace2 = 'ns_test-' + uuidutils.generate_uuid()
        priv_ip_lib.create_netns(namespace2)
        self.addCleanup(self._remove_ns, namespace2)
        # Create a random number of dummy interfaces in namespace2, in order
        # to increase the 'veth1_2' interface index in its namespace.
        for idx in range(5, random.randint(15, 20)):
            priv_ip_lib.create_interface('int_%s' % idx, namespace2, 'dummy')

        ip_wrapper = ip_lib.IPWrapper(self.namespace)
        ip_wrapper.add_veth('veth1_1', 'veth1_2', namespace2)

        veth1_1 = self._retrieve_interface('veth1_1', self.namespace)
        veth1_2 = self._retrieve_interface('veth1_2', namespace2)

        ifla_linkinfo = ip_lib.get_attr(veth1_1, 'IFLA_LINKINFO')
        self.assertEqual(ip_lib.get_attr(ifla_linkinfo, 'IFLA_INFO_KIND'),
                         'veth')
        # NOTE(ralonsoh): since kernel_version=4.15.0-60-generic, iproute2
        # provides the veth pair index, even if the pair interface is in other
        # namespace. In previous versions, the parameter 'IFLA_LINK' was not
        # present. We need to handle both cases.
        self.assertIn(ip_lib.get_attr(veth1_1, 'IFLA_LINK'),
                      [None, veth1_2['index']])
Ejemplo n.º 28
0
 def create(self):
     privileged.create_interface(self.name, self._parent.namespace,
                                 self.kind)
Ejemplo n.º 29
0
 def test_add_rule_iif(self):
     iif = 'iif_device_1'
     priv_ip_lib.create_interface(iif, self.namespace, 'dummy')
     priv_ip_lib.add_ip_rule(self.namespace, iifname=iif)
     rules = ip_lib.list_ip_rules(self.namespace, 4)
     self._check_rules(rules, ['iif'], [iif], 'iif name %s' % iif)
Ejemplo n.º 30
0
 def add_dummy(self, name):
     """Create a Linux dummy interface with the given name."""
     privileged.create_interface(name, self.namespace, "dummy")
     return IPDevice(name, namespace=self.namespace)
Ejemplo n.º 31
0
 def add_tuntap(self, name, mode='tap'):
     privileged.create_interface(
         name, self.namespace, "tuntap", mode=mode)
     return IPDevice(name, namespace=self.namespace)
Ejemplo n.º 32
0
 def add_dummy(self, name):
     """Create a Linux dummy interface with the given name."""
     privileged.create_interface(name, self.namespace, "dummy")
     return IPDevice(name, namespace=self.namespace)
Ejemplo n.º 33
0
 def add_tuntap(self, name, mode='tap'):
     privileged.create_interface(name, self.namespace, "tuntap", mode=mode)
     return IPDevice(name, namespace=self.namespace)