utils.py 文件源码

python
阅读 80 收藏 0 点赞 0 评论 0

项目:zun 作者: openstack 项目源码 文件源码
def get_function_by_ifname(ifname):
    """Get the function by the interface name

    Given the device name, returns the PCI address of a device
    and returns True if the address is in a physical function.
    """
    dev_path = "/sys/class/net/%s/device" % ifname
    sriov_totalvfs = 0
    if os.path.isdir(dev_path):
        try:
            # sriov_totalvfs contains the maximum possible VFs for this PF
            with open(os.path.join(dev_path, _SRIOV_TOTALVFS)) as fd:
                sriov_totalvfs = int(fd.read())
                return (os.readlink(dev_path).strip("./"),
                        sriov_totalvfs > 0)
        except (IOError, ValueError):
            return os.readlink(dev_path).strip("./"), False
    return None, False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号