@libvirt_conn
def get_vir_network_dhcp_lease(conn, vm_name):
 domain_name = ('vagrant_' + vm_name)
 mac_address = get_mac_address(conn, domain_name)
 network = conn.networkLookupByName('vagrant-private-dhcp')
 dhcp_leases = libvirt.virNetwork.DHCPLeases(network)
 vm_dhcp_leases = [lease for lease in dhcp_leases if (lease['mac'] == mac_address)]
 newest_vm_dhcp_lease = sorted(vm_dhcp_leases, key=operator.itemgetter('expirytime'), reverse=True)[0]['ipaddr']
 return newest_vm_dhcp_lease

@ libvirt_conn def get_vir_network_dhcp_lease ( conn , vm_name ) : domain_name = ( 'vagrant_' + vm_name ) mac_address = get_mac_address ( conn , domain_name ) network = conn . networkLookupByName ( 'vagrant-private-dhcp' ) dhcp_leases = libvirt . virNetwork . DHCPLeases ( network ) vm_dhcp_leases = [ lease for lease in dhcp_leases if ( lease [ 'mac' ] == mac_address ) ] newest_vm_dhcp_lease = sorted ( vm_dhcp_leases , key = operator . itemgetter ( 'expirytime' ) , reverse = True ) [ 0 ] [ 'ipaddr' ] return newest_vm_dhcp_lease
libvirt since 1 .