# Path: os_vif/internal/ip/api.py
# LOG = logging.getLogger(__name__)
# 
# Path: vif_plug_ovs/constants.py
# PLUGIN_NAME = 'ovs'
# OVS_VHOSTUSER_INTERFACE_TYPE = 'dpdkvhostuser'
# OVS_VHOSTUSER_CLIENT_INTERFACE_TYPE = 'dpdkvhostuserclient'
# OVS_VHOSTUSER_PREFIX = 'vhu'
# OVS_DATAPATH_SYSTEM = 'system'
# OVS_DATAPATH_NETDEV = 'netdev'
# PLATFORM_LINUX = 'linux2'
# PLATFORM_WIN32 = 'win32'
# OVS_DPDK_INTERFACE_TYPE = 'dpdk'
# DEAD_VLAN = 4095
# 
# Path: vif_plug_ovs/exception.py
# class AgentError(osv_exception.ExceptionBase):
# class MissingPortProfile(osv_exception.ExceptionBase):
# class WrongPortProfile(osv_exception.ExceptionBase):
# class RepresentorNotFound(osv_exception.ExceptionBase):
# class PciDeviceNotFoundById(osv_exception.ExceptionBase):
# 
# Path: vif_plug_ovs/privsep.py



import glob
import os
import re
import sys
from os_vif.internal.ip.api import ip as ip_lib
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import excutils
from vif_plug_ovs import constants
from vif_plug_ovs import exception
from vif_plug_ovs import privsep
    """

    address_str, pf = get_function_by_ifname(pf_ifname)
    if not address_str:
        return None
    match = PF_FUNC_RE.search(address_str)
    if match:
        return match.group(1)
    return None


def get_representor_port(pf_ifname, vf_num):
    """Get the representor netdevice which is corresponding to the VF.

    This method gets PF interface name and number of VF. It iterates over all
    the interfaces under the PF location and looks for interface that has the
    VF number in the phys_port_name. That interface is the representor for
    the requested VF.
    """

    pf_sw_id = None
    try:
        pf_sw_id = _get_phys_switch_id(pf_ifname)
    except (OSError, IOError):
        raise exception.RepresentorNotFound(ifname=pf_ifname, vf_num=vf_num)

    pf_subsystem_file = "/sys/class/net/%s/subsystem" % pf_ifname
    try:
        devices = os.listdir(pf_subsystem_file)
    except (OSError, IOError):

# Path: os_vif/internal/ip/api.py
# LOG = logging.getLogger(__name__)
# 
# Path: vif_plug_ovs/constants.py
# PLUGIN_NAME = 'ovs'
# OVS_VHOSTUSER_INTERFACE_TYPE = 'dpdkvhostuser'
# OVS_VHOSTUSER_CLIENT_INTERFACE_TYPE = 'dpdkvhostuserclient'
# OVS_VHOSTUSER_PREFIX = 'vhu'
# OVS_DATAPATH_SYSTEM = 'system'
# OVS_DATAPATH_NETDEV = 'netdev'
# PLATFORM_LINUX = 'linux2'
# PLATFORM_WIN32 = 'win32'
# OVS_DPDK_INTERFACE_TYPE = 'dpdk'
# DEAD_VLAN = 4095
# 
# Path: vif_plug_ovs/exception.py
# class AgentError(osv_exception.ExceptionBase):
# class MissingPortProfile(osv_exception.ExceptionBase):
# class WrongPortProfile(osv_exception.ExceptionBase):
# class RepresentorNotFound(osv_exception.ExceptionBase):
# class PciDeviceNotFoundById(osv_exception.ExceptionBase):
# 
# Path: vif_plug_ovs/privsep.py



# Path: vif_plug_ovs/linux_net.py
import glob
import os
import re
import sys
from os_vif.internal.ip.api import ip as ip_lib
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import excutils
from vif_plug_ovs import constants
from vif_plug_ovs import exception
from vif_plug_ovs import privsep

    """

    address_str, pf = get_function_by_ifname(pf_ifname)
    if not address_str:
        return None
    match = PF_FUNC_RE.search(address_str)
    if match:
        return match.group(1)
    return None


def get_representor_port(pf_ifname, vf_num):
    """Get the representor netdevice which is corresponding to the VF.

    This method gets PF interface name and number of VF. It iterates over all
    the interfaces under the PF location and looks for interface that has the
    VF number in the phys_port_name. That interface is the representor for
    the requested VF.
    """

    pf_sw_id = None
    try:
        pf_sw_id = _get_phys_switch_id(pf_ifname)
    except (OSError, IOError):
        raise exception.RepresentorNotFound(ifname=pf_ifname, vf_num=vf_num)

    pf_subsystem_file = "/sys/class/net/%s/subsystem" % pf_ifname
    try:
        devices = os.listdir(pf_subsystem_file)
    except (OSError, IOError):

        raise exception.RepresentorNotFound(ifname=pf_ifname, vf_num=vf_num)