newest_dhcp_lease.py 文件源码

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

项目:kolla-kubernetes-personal 作者: rthallisey 项目源码 文件源码
def get_mac_address(conn, domain_name):
    """Get MAC address from domain XML."""
    domain = conn.lookupByName(domain_name)
    domain_xml = domain.XMLDesc()
    domain_tree = etree.fromstring(domain_xml)
    devices = domain_tree.find('devices')
    interfaces = devices.iterfind('interface')

    for interface in interfaces:
        source = interface.find('source')
        if source is None or source.get('network') != 'vagrant-private-dhcp':
            continue
        mac_element = interface.find('mac')
        mac_address = mac_element.get('address')
        return mac_address

    raise NoPrivateDHCPInterfaceException()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号