def port_bind(endpoint_id, port, subnets, network=None, vm_port=None, segmentation_id=None): """Binds the Neutron port to the network interface on the host. :param endpoint_id: the ID of the endpoint as string :param port: the container Neutron port dictionary as returned by python-neutronclient :param subnets: an iterable of all the Neutron subnets which the endpoint is trying to join :param network: the Neutron network which the endpoint is trying to join :param vm_port: the Nova instance port dictionary, as returned by python-neutronclient. Container is running inside this instance (either ipvlan/macvlan or a subport) :param segmentation_id: ID of the segment for container traffic isolation) :returns: the tuple of the names of the veth pair and the tuple of stdout and stderr returned by processutils.execute invoked with the executable script for binding :raises: kuryr.common.exceptions.VethCreationFailure, processutils.ProcessExecutionError """ ip = utils.get_ipdb() port_id = port['id'] _, devname = utils.get_veth_pair_names(port_id) link_iface = nested.get_link_iface(vm_port) mtu = utils.get_mtu_from_network(network) with ip.create(ifname=devname, kind=KIND, link=ip.interfaces[link_iface], mode=IPVLAN_MODE_L2) as container_iface: utils._configure_container_iface( container_iface, subnets, fixed_ips=port.get(utils.FIXED_IP_KEY), mtu=mtu) return None, devname, ('', None)
def port_bind(endpoint_id, port, subnets, network=None, vm_port=None, segmentation_id=None, **kwargs): """Binds the Neutron port to the network interface on the host. :param endpoint_id: the ID of the endpoint as string :param port: the container Neutron port dictionary as returned by python-neutronclient :param subnets: an iterable of all the Neutron subnets which the endpoint is trying to join :param network: the Neutron network which the endpoint is trying to join :param vm_port: the Nova instance port dictionary, as returned by python-neutronclient. Container port under binding is running inside this instance (either ipvlan/macvlan or a subport) :param segmentation_id: ID of the segment for container traffic isolation) :param kwargs: Additional driver-specific arguments :returns: the tuple of the names of the veth pair and the tuple of stdout and stderr returned by processutils.execute invoked with the executable script for binding :raises: kuryr.common.exceptions.VethCreationFailure, processutils.ProcessExecutionError """ ip = utils.get_ipdb() port_id = port['id'] host_ifname, container_ifname = utils.get_veth_pair_names(port_id) mtu = utils.get_mtu_from_network(network) try: with ip.create(ifname=host_ifname, kind=KIND, reuse=True, peer=container_ifname) as host_veth: if not utils.is_up(host_veth): host_veth.up() with ip.interfaces[container_ifname] as container_veth: utils._configure_container_iface( container_veth, subnets, fixed_ips=port.get(utils.FIXED_IP_KEY), mtu=mtu, hwaddr=port[utils.MAC_ADDRESS_KEY].lower()) except pyroute2.CreateException: raise exceptions.VethCreationFailure( 'Virtual device creation failed.') except pyroute2.CommitException: raise exceptions.VethCreationFailure( 'Could not configure the container virtual device networking.') try: stdout, stderr = _configure_host_iface( host_ifname, endpoint_id, port_id, port['network_id'], port.get('project_id') or port['tenant_id'], port[utils.MAC_ADDRESS_KEY], kind=port.get(constants.VIF_TYPE_KEY), details=port.get(constants.VIF_DETAILS_KEY)) except Exception: with excutils.save_and_reraise_exception(): utils.remove_device(host_ifname) return host_ifname, container_ifname, (stdout, stderr)
def port_bind(endpoint_id, port, subnets, network=None, vm_port=None, segmentation_id=None): """Binds the Neutron port to the network interface on the host. :param endpoint_id: the ID of the endpoint as string :param port: the container Neutron port dictionary as returned by python-neutronclient :param subnets: an iterable of all the Neutron subnets which the endpoint is trying to join :param network: the Neutron network which the endpoint is trying to join :param vm_port: the Nova instance dictionary, as returned by python-neutronclient. Container port under binding is running inside this instance (either ipvlan/macvlan or a subport) :param segmentation_id: ID of the segment for container traffic isolation) :returns: the tuple of the names of the veth pair and the tuple of stdout and stderr returned by processutils.execute invoked with the executable script for binding :raises: kuryr.common.exceptions.VethCreationFailure, processutils.ProcessExecutionError """ ip = utils.get_ipdb() port_id = port['id'] host_ifname, container_ifname = utils.get_veth_pair_names(port_id) mtu = utils.get_mtu_from_network(network) try: with ip.create(ifname=host_ifname, kind=KIND, reuse=True, peer=container_ifname) as host_veth: if not utils.is_up(host_veth): host_veth.up() with ip.interfaces[container_ifname] as container_veth: utils._configure_container_iface( container_veth, subnets, fixed_ips=port.get(utils.FIXED_IP_KEY), mtu=mtu, hwaddr=port[utils.MAC_ADDRESS_KEY].lower()) except pyroute2.CreateException: raise exceptions.VethCreationFailure( 'Virtual device creation failed.') except pyroute2.CommitException: raise exceptions.VethCreationFailure( 'Could not configure the container virtual device networking.') try: stdout, stderr = _configure_host_iface( host_ifname, endpoint_id, port_id, port['network_id'], port.get('project_id') or port['tenant_id'], port[utils.MAC_ADDRESS_KEY], kind=port.get(constants.VIF_TYPE_KEY), details=port.get(constants.VIF_DETAILS_KEY)) except Exception: with excutils.save_and_reraise_exception(): utils.remove_device(host_ifname) return host_ifname, container_ifname, (stdout, stderr)