Fix using filter() to meet python2,3

As mentioned in link[1], if we need filter() on python3,
Raplace filter(lambda obj: test(obj), data) with:
[obj for obj in data if test(obj)].

[1] https://wiki.openstack.org/wiki/Python3
TrivialFix.

Change-Id: Ic1ea289c89fad16bc7aa1db42faa9a6b686086d2
This commit is contained in:
Lu lei 2016-08-29 16:55:24 +08:00
parent c1a89c62ab
commit c12230a57c

View File

@ -65,8 +65,8 @@ def get_vir_network_dhcp_lease(conn, vm_name):
network = conn.networkLookupByName('vagrant-private-dhcp')
dhcp_leases = libvirt.virNetwork.DHCPLeases(network)
vm_dhcp_leases = filter(lambda lease: lease['mac'] == mac_address,
dhcp_leases)
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'),