Beispiel #1
0
 def unplug_tap(self, instance, vif):
     """Unplug a VIF_TYPE_TAP virtual interface."""
     dev = self.get_vif_devname(vif)
     try:
         linux_net.delete_net_dev(dev)
     except processutils.ProcessExecutionError:
         LOG.exception(_LE("Failed while unplugging vif"), instance=instance)
Beispiel #2
0
 def unplug_tap(self, instance, vif):
     """Unplug a VIF_TYPE_TAP virtual interface."""
     dev = get_vif_devname(vif)
     try:
         linux_net.delete_net_dev(dev)
     except processutils.ProcessExecutionError:
         LOG.exception("Failed while unplugging vif", instance=instance)
 def delete_device(self, dev):
     time.sleep(2)
     LOG.debug(dev)
     if cfg.CONF.libvirt.virt_type == 'lxc':
         linux_net.LinuxBridgeInterfaceDriver.remove_bridge(
             self._get_br_name(dev))
     linux_net.delete_net_dev(dev)
Beispiel #4
0
    def unplug_iovisor(self, instance, vif):
        """Unplug using PLUMgrid IO Visor Driver

        Delete network device and to their respective
        connection to the Virtual Domain in PLUMgrid Platform.
        """
        iface_id = vif['id']
        dev = self.get_vif_devname(vif)
        try:
            utils.execute('ifc_ctl',
                          'gateway',
                          'ifdown',
                          dev,
                          'access_vm',
                          vif['network']['label'] + "_" + iface_id,
                          vif['address'],
                          run_as_root=True)
            utils.execute('ifc_ctl',
                          'gateway',
                          'del_port',
                          dev,
                          run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"),
                          instance=instance)
 def delete_device(self, dev):
     time.sleep(2)
     LOG.debug(dev)
     if cfg.CONF.libvirt.virt_type == 'lxc':
         linux_net.LinuxBridgeInterfaceDriver.remove_bridge(
                 self._get_br_name(dev))
     linux_net.delete_net_dev(dev)
Beispiel #6
0
    def unplug_iovisor(self, instance, vif):
        """Unplug using PLUMgrid IO Visor Driver

        Delete network device and to their respective
        connection to the Virtual Domain in PLUMgrid Platform.
        """
        super(LibvirtGenericVIFDriver, self).unplug(instance, vif)
        network, mapping = vif
        iface_id = mapping['vif_uuid']
        dev = self.get_vif_devname(mapping)
        try:
            utils.execute('ifc_ctl',
                          'gateway',
                          'ifdown',
                          dev,
                          'access_vm',
                          mapping['label'] + "_" + iface_id,
                          mapping['mac'],
                          run_as_root=True)
            utils.execute('ifc_ctl',
                          'gateway',
                          'del_port',
                          dev,
                          run_as_root=True)
            linux_net.delete_net_dev(dev)
        except exception.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
    def unplug(self, instance, vif):
        dev = self.get_vif_devname(vif)

        try:
            self._vrouter_client.delete_port(vif['id'])
            linux_net.delete_net_dev(dev)
        except (TApplicationException, processutils.ProcessExecutionError):
            LOG.exception(_LE("Failed while unplugging vif"),
                          instance=instance)
Beispiel #8
0
def _post_unplug_wiring_delete_veth(instance, vif):
    v1_name = get_vif_devname(vif)
    try:
        if _is_ovs_vif_port(vif):
            linux_net.delete_ovs_vif_port(vif['network']['bridge'], v1_name,
                                          True)
        else:
            linux_net.delete_net_dev(v1_name)
    except processutils.ProcessExecutionError:
        LOG.exception("Failed to delete veth for vif", vif=vif)
Beispiel #9
0
 def unplug_routed(self, instance, vif):
     """Unplug a routed virtual interface.
     """
     super(LibvirtGenericVIFDriver,
           self).unplug(instance, vif)
     dev = self.get_vif_devname(vif)
     try:
         linux_net.delete_net_dev(dev)
     except processutils.ProcessExecutionError:
         LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #10
0
    def unplug_vrouter(self, instance, vif):
        """Unplug Contrail's network port

        Unbind the vif from a Contrail virtual port.
        """
        dev = self.get_vif_devname(vif)
        try:
            nova.privsep.libvirt.unplug_contrail_vif(vif)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #11
0
    def unplug_vrouter(self, instance, vif):
        """Unplug Contrail's network port

        Unbind the vif from a Contrail virtual port.
        """
        dev = self.get_vif_devname(vif)
        cmd_args = "--oper=delete --uuid=%s" % (vif["id"])
        try:
            utils.execute("vrouter-port-control", cmd_args, run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"), instance=instance)
Beispiel #12
0
    def unplug_vrouter(self, instance, vif):
        """Unplug Contrail's network port

        Unbind the vif from a Contrail virtual port.
        """
        dev = self.get_vif_devname(vif)
        cmd_args = ("--oper=delete --uuid=%s" % (vif['id']))
        try:
            utils.execute('vrouter-port-control', cmd_args, run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #13
0
    def unplug_midonet(self, instance, vif):
        """Unplug from MidoNet network port

        Unbind the vif from a MidoNet virtual port.
        """
        dev = self.get_vif_devname(vif)
        port_id = vif['id']
        try:
            utils.execute('mm-ctl', '--unbind-port', port_id, run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #14
0
    def unplug_iovisor(self, instance, vif):
        """Unplug using PLUMgrid IO Visor Driver

        Delete network device and to their respective
        connection to the Virtual Domain in PLUMgrid Platform.
        """
        dev = self.get_vif_devname(vif)
        try:
            nova.privsep.libvirt.unplug_plumgrid_vif(dev)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #15
0
    def unplug_midonet(self, instance, vif):
        """Unplug from MidoNet network port

        Unbind the vif from a MidoNet virtual port.
        """
        dev = self.get_vif_devname(vif)
        port_id = vif['id']
        try:
            nova.privsep.libvirt.unplug_midonet_vif(port_id)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #16
0
    def unplug_midonet(self, instance, vif):
        """Unplug from MidoNet network port

        Unbind the vif from a MidoNet virtual port.
        """
        dev = self.get_vif_devname(vif)
        port_id = vif["id"]
        try:
            utils.execute("mm-ctl", "--unbind-port", port_id, run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"), instance=instance)
    def delete_device(self, dev):
        time.sleep(2)
        LOG.debug(dev)

        try:
            virt_type = cfg.CONF.libvirt.virt_type
        except cfg.NoSuchOptError:
            virt_type = cfg.CONF.libvirt_type

        if virt_type == 'lxc':
            linux_net.LinuxBridgeInterfaceDriver.remove_bridge(
                    self._get_br_name(dev))
        linux_net.delete_net_dev(dev)
Beispiel #18
0
    def unplug_midonet(self, instance, vif):
        """Unplug from MidoNet network port

        Unbind the vif from a MidoNet virtual port.
        """
        super(LibvirtGenericVIFDriver,
              self).unplug(instance, vif)
        dev = self.get_vif_devname(vif)
        port_id = vif['id']
        try:
            utils.execute('mm-ctl', '--unbind-port', port_id,
                          run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #19
0
    def delete_device(self, dev, timeout=None):
        if timeout is not None:
            time.sleep(timeout)
        LOG.debug(dev)

        try:
            virt_type = cfg.CONF.libvirt.virt_type
        except cfg.NoSuchOptError:
            virt_type = cfg.CONF.libvirt_type

        if virt_type == 'lxc':
            linux_net.LinuxBridgeInterfaceDriver.remove_bridge(
                    self._get_br_name(dev))
        if not CONF.contrail.use_userspace_vhost:
            linux_net.delete_net_dev(dev)
Beispiel #20
0
    def unplug_iovisor(self, instance, vif):
        """Unplug using PLUMgrid IO Visor Driver

        Delete network device and to their respective
        connection to the Virtual Domain in PLUMgrid Platform.
        """
        dev = self.get_vif_devname(vif)
        try:
            utils.execute('ifc_ctl', 'gateway', 'ifdown',
                          dev, run_as_root=True)
            utils.execute('ifc_ctl', 'gateway', 'del_port', dev,
                          run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"),
                          instance=instance)
Beispiel #21
0
    def unplug_iovisor(self, instance, vif):
        """Unplug vif from IOvisor

        Offboard an interface and deletes port from IOvisor
        """
        if_local_name = 'tap%s' % vif['id'][:11]
        iface_id = vif['id']
        try:
            utils.execute('ifc_ctl', 'gateway', 'ifdown',
                          if_local_name, 'access_vm',
                          vif['network']['label'] + "_" + iface_id,
                          vif['address'], run_as_root=True)
            utils.execute('ifc_ctl', 'gateway', 'del_port', if_local_name,
                          run_as_root=True)
            linux_net.delete_net_dev(if_local_name)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #22
0
    def unplug_iovisor(self, instance, vif):
        """Unplug vif from IOvisor

        Offboard an interface and deletes port from IOvisor
        """
        if_local_name = 'tap%s' % vif['id'][:11]
        iface_id = vif['id']
        try:
            utils.execute('ifc_ctl', 'gateway', 'ifdown',
                          if_local_name, 'access_vm',
                          vif['network']['label'] + "_" + iface_id,
                          vif['address'], run_as_root=True)
            utils.execute('ifc_ctl', 'gateway', 'del_port', if_local_name,
                          run_as_root=True)
            linux_net.delete_net_dev(if_local_name)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
Beispiel #23
0
    def unplug_ovs_hybrid(
            self, instance, vif, ovsport_info, portgroup_instance_mapping):
        """UnPlug using hybrid strategy

        Unhook port from OVS, unhook port from bridge, delete
        bridge, and delete both veth devices.
        """

        # now dirver use the configed nic eth0.100 instead
        ovs_nicport = ovsport_info['ovs_ethport']
        vlan_tag = str(portgroup_instance_mapping.vlan)
        nic_name = ovs_nicport + '.' + vlan_tag

        # remove the eth1 vlan config
        try:
            # try to delete the exists nic_name in whatever br
            utils.execute('vconfig', 'rem', nic_name, run_as_root=True)
        except Exception as exc:
            LOG.exception(exc, instance=instance)

        try:
            br_name = self.get_br_name(vif['id'])
            v1_name, v2_name = self.get_veth_pair_names(vif['id'])
            gbr_name = self.get_gbr_name(vif['id'])
            tap_name, taq_name = self.get_gveth_pair_names(vif['id'])

            if linux_net.device_exists(br_name):
                utils.execute('brctl', 'delif', br_name, v1_name,
                              run_as_root=True)
                utils.execute('brctl', 'delif', br_name, tap_name,
                              run_as_root=True)
                utils.execute('ip', 'link', 'set', br_name, 'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', br_name,
                              run_as_root=True)

            linux_net.delete_ovs_vif_port(self.get_bridge_name(vif),
                                          v2_name)

            if linux_net.device_exists(gbr_name):
                utils.execute('brctl', 'delif', gbr_name, taq_name,
                              run_as_root=True)
                utils.execute('ip', 'link', 'set', gbr_name, 'down',
                              run_as_root=True)
                utils.execute('brctl', 'delbr', gbr_name,
                              run_as_root=True)

            # delete veth peer
            linux_net.delete_net_dev(v1_name)
            linux_net.delete_net_dev(v2_name)
            linux_net.delete_net_dev(tap_name)
            linux_net.delete_net_dev(taq_name)
        except Exception as exc:
            LOG.exception(exc, instance=instance)
Beispiel #24
0
def _create_veth_pair(dev1_name, dev2_name, mtu=None):
    """Create a pair of veth devices with the specified names,
    deleting any previous devices with those names.
    """
    for dev in [dev1_name, dev2_name]:
        linux_net.delete_net_dev(dev)

    utils.execute('ip',
                  'link',
                  'add',
                  dev1_name,
                  'type',
                  'veth',
                  'peer',
                  'name',
                  dev2_name,
                  run_as_root=True)
    for dev in [dev1_name, dev2_name]:
        utils.execute('ip', 'link', 'set', dev, 'up', run_as_root=True)
        linux_net._set_device_mtu(dev, mtu)
Beispiel #25
0
    def unplug_iovisor(self, instance, vif):
        """Unplug using PLUMgrid IO Visor Driver

        Delete network device and to their respective
        connection to the Virtual Domain in PLUMgrid Platform.
        """
        super(LibvirtGenericVIFDriver,
              self).unplug(instance, vif)
        iface_id = vif['id']
        dev = self.get_vif_devname(vif)
        try:
            utils.execute('ifc_ctl', 'gateway', 'ifdown',
                          dev, 'access_vm',
                          vif['network']['label'] + "_" + iface_id,
                          vif['address'], run_as_root=True)
            utils.execute('ifc_ctl', 'gateway', 'del_port', dev,
                          run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_("Failed while unplugging vif"), instance=instance)
    def unplug(self, instance, vif):
        """Unplug the VIF from the network by deleting the port from
        the bridge."""
        LOG.debug(_('Unplug'))
        iface_id = vif['id']
        dev = self.get_vif_devname(vif)

        import socket
        from gen_py.instance_service import ttypes
        port = ttypes.Port(self._convert_to_bl(iface_id), 
                           self._convert_to_bl(instance['uuid']), 
                           dev, 
                           vif['network']['subnets'][0]['ips'][0]['address'],
                           self._convert_to_bl(vif['network']['id']),
                           vif['address'],
	                   instance['display_name'],
	                   instance['hostname'],
	                   instance['host'],
	                   self._convert_to_bl(instance['project_id']))

        self._agent_inform(port, iface_id, False)
        linux_net.delete_net_dev(dev)
    def unplug(self, instance, vif):
        """Unplug the VIF from the network by deleting the port from
        the bridge."""
        LOG.debug(_('Unplug'))
        iface_id = vif['id']
        dev = self.get_vif_devname(vif)

        import socket
        from gen_py.instance_service import ttypes
        port = ttypes.Port(self._convert_to_bl(iface_id), 
                           self._convert_to_bl(instance['uuid']), 
                           dev, 
                           vif['network']['subnets'][0]['ips'][0]['address'],
                           self._convert_to_bl(vif['network']['id']),
                           vif['address'],
	                   instance['display_name'],
	                   instance['hostname'],
	                   instance['host'],
	                   self._convert_to_bl(instance['project_id']))

        self._agent_inform(port, iface_id, False)
        linux_net.delete_net_dev(dev)
Beispiel #28
0
    def unplug_iovisor(self, instance, vif):
        """Unplug using PLUMgrid IO Visor Driver

        Delete network device and to their respective
        connection to the Virtual Domain in PLUMgrid Platform.
        """
        iface_id = vif["id"]
        dev = self.get_vif_devname(vif)
        try:
            utils.execute(
                "ifc_ctl",
                "gateway",
                "ifdown",
                dev,
                "access_vm",
                vif["network"]["label"] + "_" + iface_id,
                vif["address"],
                run_as_root=True,
            )
            utils.execute("ifc_ctl", "gateway", "del_port", dev, run_as_root=True)
            linux_net.delete_net_dev(dev)
        except processutils.ProcessExecutionError:
            LOG.exception(_LE("Failed while unplugging vif"), instance=instance)