Ejemplo n.º 1
0
    def _create_interfaces(self, ip, nic):
        if ip_lib.device_exists(nic['name'],
                                self.root_helper,
                                namespace=self.namespace):
            ip_lib.IPDevice(nic['name'],
                            self.root_helper,
                            self.namespace).link.delete()

        root_dev, ns_dev = ip.add_veth(self._get_tap_name(nic['uuid']),
                                       nic['name'],
                                       namespace2=self.namespace)
        if nic['mac']:
            ns_dev.link.set_address(str(nic['mac']))

        ns_dev.link.set_up()
        root_dev.link.set_up()

        if nic['ip']:
            ip = nic['ip']
            ns_dev.addr.flush()
            ns_dev.addr.add(ip.version, str(ip), str(ip.broadcast))
        else:
            #TODO(ethuleau): start DHCP client
            raise NotImplementedError

        # disable reverse path filtering
        self.ip_ns.netns.execute(['sysctl', '-w',
                                  'net.ipv4.conf.%s.rp_filter=2' % nic['name']]
                                 )
Ejemplo n.º 2
0
 def plug(self, network_id, port_id, device_name, mac_address,
          bridge=None, namespace=None, prefix=None, mtu=None):
     if not ip_lib.device_exists(device_name,
                                 namespace=namespace):
         try:
             self.plug_new(network_id, port_id, device_name, mac_address,
                           bridge, namespace, prefix, mtu)
         except TypeError:
             versionutils.report_deprecated_feature(
                 LOG,
                 _LW('Interface driver does not support MTU parameter. '
                     'This may not work in future releases.'))
             self.plug_new(network_id, port_id, device_name, mac_address,
                           bridge, namespace, prefix)
     else:
         LOG.info(_LI("Device %s already exists"), device_name)
Ejemplo n.º 3
0
 def check_bridge_exists(self, bridge):
     if not ip_lib.device_exists(bridge):
         raise common.BridgeDoesNotExist(bridge=bridge)