def update_vpp_vif_port(dev, mtu=None, interface_type=None, timeout=None):
    if not mtu:
        return
    vapi = VPPApi(LOG, 'nova_os_vif')
    _, _, sw_if_index = vapi.vhost_details_from_tag(
        dev.port_profile.interface_id)
    vapi.set_interface_mtu(sw_if_index, mtu)
Beispiel #2
0
    def get_vif_port_set(self):
        """get list of host port macs

        :param : None.
        """
        vapi = VPPApi(LOG, 'gbp-agent')
        vhtag = vapi.get_vhost_tag_dicts()
        uuid_filtered = {x.split('|')[0]: y for x, y in vhtag.items()}
        return uuid_filtered
    def unplug(self, device_name, bridge=None, namespace=None, prefix=None):
        """Unplug the interface."""

        tap_name = device_name.replace(prefix or self.DEV_NAME_PREFIX,
                                       lib_constants.VETH_DEVICE_PREFIX)
        device = ip_lib.IPDevice(tap_name)
        try:
            vapi = VPPApi(LOG, 'vpp_dhcp')
            vapi.delete_host_interface(str(tap_name).encode('utf-8'))
            device.link.delete()
            LOG.debug("Unplugged interface '%s'", device_name)
        except RuntimeError:
            LOG.error("Failed unplugging interface '%s'", device_name)
Beispiel #4
0
    def get_vif_port_by_id(self, tag):
        vapi = VPPApi(LOG, 'gbp-agent')
        port_name, mac, _ = vapi.vhost_details_from_tag(tag)
        # Create a fake port object for compatibility within
        # gbp agent.

        class Port(object):
            pass

        port_obj = Port()
        port_obj.vif_id = tag
        port_obj.vif_mac = mac
        port_obj.ofport = -1
        port_obj.port_name = port_name
        return port_obj
Beispiel #5
0
def _create_vpp_vif(dev, iface_id, mac, mtu,
                    instance_id, interface_type=None,
                    vhost_server_path=None):
    vapi = VPPApi(LOG, 'nova_os_vif')
    # iface_id is the port UUID as seen in neutron. Use this as the tag
    # on the interface which will be later used as the key for endpoint lookup
    mac_address = VPPApi.mac_to_bytes(mac)
    if interface_type == constants.VPP_VHOSTUSER_CLIENT_INTERFACE_TYPE:
        sw_if_index = vapi.create_vhost_user_if(
                        str(vhost_server_path).encode('utf-8'),
                        0, mac_address, iface_id)
    else:
        sw_if_index = vapi.create_vhost_user_if(
                        str(vhost_server_path).encode('utf-8'),
                        1, mac_address, iface_id)
    LOG.debug("sw_if_index:{}".format(sw_if_index))
    if mtu:
        vapi.set_interface_mtu(sw_if_index, [mtu, 0, 0, 0])
    # Default admin state  for port in VPP is down, so do admin-up here
    vapi.set_interface_state(sw_if_index, 1)
    return sw_if_index
    def plug_new(self,
                 network_id,
                 port_id,
                 device_name,
                 mac_address,
                 bridge=None,
                 namespace=None,
                 prefix=None,
                 mtu=None):
        """Plugin the interface."""
        ip = ip_lib.IPWrapper()

        # Enable agent to define the prefix
        tap_name = device_name.replace(prefix or self.DEV_NAME_PREFIX,
                                       lib_constants.VETH_DEVICE_PREFIX)
        # Create ns_veth in a namespace if one is configured.
        root_veth, ns_veth = ip.add_veth(tap_name,
                                         device_name,
                                         namespace2=namespace)
        root_veth.disable_ipv6()
        ns_veth.link.set_address(mac_address)
        if mtu:
            self.set_mtu(device_name, mtu, namespace=namespace, prefix=prefix)
        else:
            LOG.warning("No MTU configured for port %s", port_id)
        root_veth.link.set_up()
        # VPP section
        mac_address = vpp_api.mac_to_bytes(mac_address)

        vapi = VPPApi(LOG, 'vpp_dhcp')
        sw_if_index = vapi.create_host_interface(
            str(tap_name).encode('utf-8'), mac_address,
            str(port_id).encode('utf-8'))
        if mtu:
            vapi.set_interface_mtu(sw_if_index, mtu)
        vapi.set_interface_state(sw_if_index, '1')
Beispiel #7
0
 def check_bridge_status(self):
     vapi = VPPApi(LOG, 'gbp-agent')
     version = vapi.get_version()
     if (version['retval'] == 0) and version['version']:
         return constants.OVS_NORMAL
     return constants.OVS_DEAD
def delete_vpp_vif_port(dev, timeout=None, delete_netdev=True):
    vapi = VPPApi(LOG, 'nova_os_vif')
    vapi.delete_vhost_user_if(dev)
    return 0