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()
newest_dhcp_lease.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录