Skip to content
Snippets Groups Projects
Commit 9895e98d authored by Michal Rostecki's avatar Michal Rostecki Committed by Swapnil Kulkarni (coolsvap)
Browse files

Use MAC address for looking for DHCP leases for Vagrant

Change-Id: If87e83f7a50c0341f4b1238310eb1469eea0f767
Closes-Bug: 1570739
parent 24b90f15
No related branches found
No related tags found
No related merge requests found
...@@ -59,10 +59,13 @@ def get_vir_network_dhcp_lease(conn, vm_name): ...@@ -59,10 +59,13 @@ def get_vir_network_dhcp_lease(conn, vm_name):
That's the current official way for getting DHCP leases and this That's the current official way for getting DHCP leases and this
information isn't stored anywhere else anymore. information isn't stored anywhere else anymore.
""" """
domain_name = 'vagrant_' + vm_name
mac_address = get_mac_address(conn, domain_name)
network = conn.networkLookupByName('vagrant-private-dhcp') network = conn.networkLookupByName('vagrant-private-dhcp')
dhcp_leases = libvirt.virNetwork.DHCPLeases(network) dhcp_leases = libvirt.virNetwork.DHCPLeases(network)
vm_dhcp_leases = filter(lambda lease: lease['hostname'] == vm_name, vm_dhcp_leases = filter(lambda lease: lease['mac'] == mac_address,
dhcp_leases) dhcp_leases)
newest_vm_dhcp_lease = sorted(vm_dhcp_leases, newest_vm_dhcp_lease = sorted(vm_dhcp_leases,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment