def neutron_to_osvif_vif_sriov(vif_plugin, os_port, subnets): """Converts Neutron port to VIF object for SRIOV containers. :param vif_plugin: name of the os-vif plugin to use (i.e. 'noop') :param os_port: openstack.network.v2.port.Port object :param subnets: subnet mapping as returned by PodSubnetsDriver.get_subnets :return: osv_vif VIFSriov object """ details = os_port.binding_vif_details or {} network = _make_vif_network(os_port, subnets) vlan_name = network.vlan if network.should_provide_vlan else '' vif = k_vif.VIFSriov( id=os_port.id, address=os_port.mac_address, network=network, has_traffic_filtering=details.get('port_filter', False), preserve_on_delete=False, active=_is_port_active(os_port), plugin=vif_plugin, mode='passthrough', vlan_name=vlan_name, vif_name=_get_vif_name(os_port), ) return vif
def neutron_to_osvif_vif_sriov(vif_plugin, neutron_port, subnets): """Converts Neutron port to VIF object for SRIOV containers. :param vif_plugin: name of the os-vif plugin to use (i.e. 'noop') :param neutron_port: dict containing port information as returned by neutron client's 'show_port' :param subnets: subnet mapping as returned by PodSubnetsDriver.get_subnets :return: osv_vif VIFSriov object """ details = neutron_port.get('binding:vif_details', {}) network = _make_vif_network(neutron_port, subnets) vlan_name = network.vlan if network.should_provide_vlan else '' vif = k_vif.VIFSriov( id=neutron_port['id'], address=neutron_port['mac_address'], network=network, has_traffic_filtering=details.get('port_filter', False), preserve_on_delete=False, active=_is_port_active(neutron_port), plugin=vif_plugin, mode='passthrough', vlan_name=vlan_name, vif_name=_get_vif_name(neutron_port), ) return vif