Beispiel #1
0
    def plug(self, vif, instance_info):
        if not hasattr(vif, "port_profile"):
            raise exception.MissingPortProfile()
        if not isinstance(vif.port_profile,
                          objects.vif.VIFPortProfileOpenVSwitch):
            raise exception.WrongPortProfile(
                profile=vif.port_profile.__class__.__name__)

        if isinstance(vif, objects.vif.VIFOpenVSwitch):
            if sys.platform != constants.PLATFORM_WIN32:
                linux_net.ensure_ovs_bridge(vif.network.bridge,
                    self._get_vif_datapath_type(vif),
                    timeout=self.config.ovs_vsctl_timeout,
                    ovsdb_connection=self.config.ovsdb_connection)
            else:
                self._plug_vif_windows(vif, instance_info)
        elif isinstance(vif, objects.vif.VIFBridge):
            if sys.platform != constants.PLATFORM_WIN32:
                self._plug_bridge(vif, instance_info)
            else:
                self._plug_vif_windows(vif, instance_info)
        elif isinstance(vif, objects.vif.VIFVHostUser):
            self._plug_vhostuser(vif, instance_info)
        elif isinstance(vif, objects.vif.VIFHostDevice):
            self._plug_vf_passthrough(vif, instance_info)
Beispiel #2
0
    def _get_representor(self, vif):
        if isinstance(vif, obj.vif.VIFHostDevice):
            pci_addr = vif.dev_address
        elif 'datapath_offload' in vif.port_profile \
             and hasattr(vif.port_profile, 'datapath_offload') \
             and isinstance(vif.port_profile.datapath_offload,
                            obj.vif.DatapathOffloadRepresentor):
            pci_addr = vif.port_profile.datapath_offload.representor_address
        elif 'representor_address' in vif.port_profile \
             and hasattr(vif.port_profile, 'representor_address'):
            pci_addr = vif.port_profile.representor_address
        else:
            # TODO(jangutter): New exception is needed
            raise exception.WrongPortProfile(
                profile=vif.port_profile.__class__.__name__)
        vf_num = linux_net.get_vf_num_by_pci_address(pci_addr)
        pf_ifname = linux_net.get_ifname_by_pci_address(pci_addr,
                                                        pf_interface=True,
                                                        switchdev=True)
        representor = linux_net.get_representor_port(pf_ifname, vf_num)

        return {
            'address': pci_addr,
            'name': representor,
            'pfname': pf_ifname,
            'vfno': vf_num
        }
Beispiel #3
0
 def plug(self, vif, instance_info):
     if not hasattr(vif, "port_profile"):
         raise exception.MissingPortProfile()
     if not isinstance(vif.port_profile, VIFPortProfileOVSRepresentor):
         raise exception.WrongPortProfile(
             profile=vif.port_profile.__class__.__name__)
     if isinstance(vif, objects.vif.VIFHostDevice):
         self._plug_agilio_passthrough(vif, instance_info)
     elif isinstance(vif, objects.vif.VIFVHostUser):
         self._plug_agilio_forwarder(vif, instance_info)
Beispiel #4
0
 def unplug(self, vif, instance_info):
     if not hasattr(vif, "port_profile"):
         raise exception.MissingPortProfile()
     if not isinstance(vif.port_profile, VIFPortProfileOpenVSwitch):
         raise exception.WrongPortProfile(
             profile=vif.port_profile.__class__.__name__)
     representor = self._get_representor(vif)
     if isinstance(vif, obj.vif.VIFHostDevice):
         self._unplug_representor(vif, representor)
     elif isinstance(vif, obj.vif.VIFVHostUser):
         self._unplug_representor(vif, representor)
         self._unplug_forwarder(vif, representor)
Beispiel #5
0
    def unplug(self, vif, instance_info):
        if not hasattr(vif, "port_profile"):
            raise exception.MissingPortProfile()
        if not isinstance(vif.port_profile,
                          objects.vif.VIFPortProfileOpenVSwitch):
            raise exception.WrongPortProfile(
                profile=vif.port_profile.__class__.__name__)

        if isinstance(vif, objects.vif.VIFOpenVSwitch):
            if sys.platform == constants.PLATFORM_WIN32:
                self._unplug_vif_windows(vif, instance_info)
        elif isinstance(vif, objects.vif.VIFBridge):
            if sys.platform != constants.PLATFORM_WIN32:
                self._unplug_bridge(vif, instance_info)
            else:
                self._unplug_vif_windows(vif, instance_info)
        elif isinstance(vif, objects.vif.VIFVHostUser):
            self._unplug_vhostuser(vif, instance_info)
Beispiel #6
0
    def plug(self, vif, instance_info):
        if not hasattr(vif, "port_profile"):
            raise exception.MissingPortProfile()
        if not isinstance(vif.port_profile,
                          objects.vif.VIFPortProfileOpenVSwitch):
            raise exception.WrongPortProfile(
                profile=vif.port_profile.__class__.__name__)

        if isinstance(vif, objects.vif.VIFOpenVSwitch):
            if sys.platform != constants.PLATFORM_WIN32:
                linux_net.ensure_ovs_bridge(vif.network.bridge,
                                            constants.OVS_DATAPATH_SYSTEM)
            else:
                self._plug_vif_windows(vif, instance_info)
        elif isinstance(vif, objects.vif.VIFBridge):
            if sys.platform != constants.PLATFORM_WIN32:
                self._plug_bridge(vif, instance_info)
            else:
                self._plug_vif_windows(vif, instance_info)
        elif isinstance(vif, objects.vif.VIFVHostUser):
            self._plug_vhostuser(vif, instance_info)