def neutron_to_osvif_vif_ovs(vif_plugin, neutron_port, subnets): """Converts Neutron port to VIF object for os-vif 'ovs' plugin. :param vif_plugin: name of the os-vif plugin to use (i.e. 'ovs') :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: os-vif VIF object """ profile = osv_vif.VIFPortProfileOpenVSwitch( interface_id=neutron_port['id']) details = neutron_port.get('binding:vif_details', {}) ovs_bridge = details.get('bridge_name', config.CONF.neutron_defaults.ovs_bridge) if not ovs_bridge: raise oslo_cfg.RequiredOptError('ovs_bridge', 'neutron_defaults') network = _make_vif_network(neutron_port, subnets) network.bridge = ovs_bridge if details.get('ovs_hybrid_plug'): vif = osv_vif.VIFBridge( 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), port_profile=profile, plugin=vif_plugin, vif_name=_get_vif_name(neutron_port), bridge_name=_get_ovs_hybrid_bridge_name(neutron_port)) else: vif = osv_vif.VIFOpenVSwitch(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), port_profile=profile, plugin=vif_plugin, vif_name=_get_vif_name(neutron_port), bridge_name=network.bridge) return vif
def neutron_to_osvif_vif_ovs(vif_plugin, os_port, subnets): """Converts Neutron port to VIF object for os-vif 'ovs' plugin. :param vif_plugin: name of the os-vif plugin to use (i.e. 'ovs') :param os_port: openstack.network.v2.port.Port object :param subnets: subnet mapping as returned by PodSubnetsDriver.get_subnets :return: os-vif VIF object """ profile = osv_vif.VIFPortProfileOpenVSwitch(interface_id=os_port.id) details = os_port.binding_vif_details or {} ovs_bridge = details.get('bridge_name', config.CONF.neutron_defaults.ovs_bridge) if not ovs_bridge: raise oslo_cfg.RequiredOptError('ovs_bridge', 'neutron_defaults') network = _make_vif_network(os_port, subnets) network.bridge = ovs_bridge if details.get('ovs_hybrid_plug'): vif = osv_vif.VIFBridge( 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), port_profile=profile, plugin=vif_plugin, vif_name=_get_vif_name(os_port), bridge_name=_get_ovs_hybrid_bridge_name(os_port)) else: vif = osv_vif.VIFOpenVSwitch(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), port_profile=profile, plugin=vif_plugin, vif_name=_get_vif_name(os_port), bridge_name=network.bridge) return vif
def neutron_to_osvif_vif_ovs(vif_plugin, os_port, subnets): """Converts Neutron port to VIF object for os-vif 'ovs' plugin. :param vif_plugin: name of the os-vif plugin to use (i.e. 'ovs') :param os_port: openstack.network.v2.port.Port object :param subnets: subnet mapping as returned by PodSubnetsDriver.get_subnets :return: os-vif VIF object """ profile = osv_vif.VIFPortProfileOpenVSwitch(interface_id=os_port.id) details = os_port.binding_vif_details or {} ovs_bridge = details.get('bridge_name', config.CONF.neutron_defaults.ovs_bridge) if not ovs_bridge: raise oslo_cfg.RequiredOptError('ovs_bridge', 'neutron_defaults') network = _make_vif_network(os_port, subnets) network.bridge = ovs_bridge vhostuser_mode = details.get('vhostuser_mode', False) LOG.debug('Detected vhostuser_mode=%s for port %s', vhostuser_mode, os_port.id) if vhostuser_mode: # TODO(a.perevalov) obtain path to mount point from pod's mountVolumes vhostuser_mount_point = (config.CONF.vhostuser.mount_point) if not vhostuser_mount_point: raise oslo_cfg.RequiredOptError('vhostuser_mount_point', 'neutron_defaults') vif_name = _get_vhu_vif_name(os_port.id) vif = osv_vif.VIFVHostUser( 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), port_profile=profile, plugin='ovs', path=os.path.join(vhostuser_mount_point, vif_name), mode=vhostuser_mode, vif_name=vif_name, bridge_name=network.bridge) elif details.get('ovs_hybrid_plug'): vif = osv_vif.VIFBridge( 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), port_profile=profile, plugin=vif_plugin, vif_name=_get_vif_name(os_port), bridge_name=_get_ovs_hybrid_bridge_name(os_port)) else: vif = osv_vif.VIFOpenVSwitch( 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), port_profile=profile, plugin=vif_plugin, vif_name=_get_vif_name(os_port), bridge_name=network.bridge) return vif