start_script.py 文件源码

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

项目:fuel-ccp-entrypoint 作者: openstack 项目源码 文件源码
def get_ip_address(iface):
    """Get IP address of the interface connected to the network.

    If there is no such an interface, then localhost is returned.
    """

    if iface not in netifaces.interfaces():
        LOG.warning("Can't find interface '%s' in the host list of interfaces",
                    iface)
        return '127.0.0.1'

    address_family = netifaces.AF_INET

    if address_family not in netifaces.ifaddresses(iface):
        LOG.warning("Interface '%s' doesnt configured with ipv4 address",
                    iface)
        return '127.0.0.1'

    for ifaddress in netifaces.ifaddresses(iface)[address_family]:
        if 'addr' in ifaddress:
            return ifaddress['addr']
        else:
            LOG.warning("Can't find ip addr for interface '%s'", iface)
            return '127.0.0.1'
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号