示例#1
0
 def _plug_vf_passthrough(self, vif, instance_info):
     linux_net.ensure_ovs_bridge(vif.network.bridge,
                                 constants.OVS_DATAPATH_SYSTEM)
     pci_slot = vif.dev_address
     pf_ifname = linux_net.get_ifname_by_pci_address(pci_slot,
                                                     pf_interface=True,
                                                     switchdev=True)
     vf_num = linux_net.get_vf_num_by_pci_address(pci_slot)
     representor = linux_net.get_representor_port(pf_ifname, vf_num)
     linux_net.set_interface_state(representor, 'up')
     self._create_vif_port(vif, representor, instance_info)
示例#2
0
 def _unplug_vf_passthrough(self, vif, instance_info):
     """Remove port from OVS."""
     pci_slot = vif.dev_address
     pf_ifname = linux_net.get_ifname_by_pci_address(pci_slot,
                                                     pf_interface=True,
                                                     switchdev=True)
     vf_num = linux_net.get_vf_num_by_pci_address(pci_slot)
     representor = linux_net.get_representor_port(pf_ifname, vf_num)
     # The representor interface can't be deleted because it bind the
     # SR-IOV VF, therefore we just need to remove it from the ovs bridge
     # and set the status to down
     linux_net.delete_ovs_vif_port(vif.network.bridge,
                                   representor,
                                   delete_netdev=False)
     linux_net.set_interface_state(representor, 'down')
示例#3
0
    def _unplug_vf(self, vif):
        """Remove port from OVS."""
        datapath = self._get_vif_datapath_type(vif)
        if datapath == constants.OVS_DATAPATH_SYSTEM:
            pci_slot = vif.dev_address
            pf_ifname = linux_net.get_ifname_by_pci_address(
                pci_slot, pf_interface=True, switchdev=True)
            vf_num = linux_net.get_vf_num_by_pci_address(pci_slot)
            representor = linux_net.get_representor_port(pf_ifname, vf_num)
        else:
            representor = linux_net.get_dpdk_representor_port_name(
                vif.id)

        # The representor interface can't be deleted because it bind the
        # SR-IOV VF, therefore we just need to remove it from the ovs bridge
        # and set the status to down
        self.ovsdb.delete_ovs_vif_port(
            vif.network.bridge, representor, delete_netdev=False)
        if datapath == constants.OVS_DATAPATH_SYSTEM:
            linux_net.set_interface_state(representor, 'down')
示例#4
0
文件: ovs.py 项目: cheng1li/os-vif
 def _plug_vf(self, vif, instance_info):
     datapath = self._get_vif_datapath_type(vif)
     self.ovsdb.ensure_ovs_bridge(vif.network.bridge, datapath)
     pci_slot = vif.dev_address
     vf_num = linux_net.get_vf_num_by_pci_address(pci_slot)
     args = []
     kwargs = {}
     if datapath == constants.OVS_DATAPATH_SYSTEM:
         pf_ifname = linux_net.get_ifname_by_pci_address(
             pci_slot, pf_interface=True, switchdev=True)
         representor = linux_net.get_representor_port(pf_ifname, vf_num)
         linux_net.set_interface_state(representor, 'up')
         args = [vif, representor, instance_info]
     else:
         representor = linux_net.get_dpdk_representor_port_name(
             vif.id)
         pf_pci = linux_net.get_pf_pci_from_vf(pci_slot)
         args = [vif, representor, instance_info]
         kwargs = {'interface_type': constants.OVS_DPDK_INTERFACE_TYPE,
                   'pf_pci': pf_pci,
                   'vf_num': vf_num}
     self._create_vif_port(*args, **kwargs)
示例#5
0
 def _plug_representor(self, vif, instance_info, representor):
     datapath = self._get_vif_datapath_type(vif)
     self.ovsdb.ensure_ovs_bridge(vif.network.bridge, datapath)
     linux_net.set_interface_state(representor['name'], 'up')
     self._create_vif_port(vif, representor['name'], instance_info)
示例#6
0
 def _unplug_representor(self, vif, representor):
     self.ovsdb.delete_ovs_vif_port(vif.network.bridge,
                                    representor['name'],
                                    delete_netdev=False)
     linux_net.set_interface_state(representor['name'], 'down')