Module Expr Str Import alias Import alias Import alias Import alias Import alias identifier Import alias ClassDef bases NameLoad body Pass decorator_list ClassDef bases NameLoad body Pass decorator_list FunctionDef arguments args NameParam defaults body FunctionDef arguments args defaults vararg kwarg body Assign NameStore Call AttributeLoad NameLoad attr Str Return Call NameLoad NameLoad NameLoad NameLoad decorator_list Call AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore Call NameLoad Lambda arguments args NameParam defaults CompareEq SubscriptLoad NameLoad Index Str NameLoad NameLoad Assign NameStore SubscriptLoad SubscriptLoad Call NameLoad NameLoad keyword Call AttributeLoad NameLoad attr Str keyword NameLoad Index Num Index Str Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str If BoolOpOr CompareIs NameLoad NameLoad CompareNotEq Call AttributeLoad NameLoad attr Str Str body Continue Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Return NameLoad Raise Call NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore BinOpAdd Str NameLoad Assign NameStore Call NameLoad NameLoad NameLoad With Call NameLoad Str NameStore body Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword Str For NameStore NameLoad body Assign TupleStore NameStore NameStore NameStore SubscriptLoad NameLoad Slice Num Num If UnaryOpNot BoolOpAnd CompareEq NameLoad NameLoad CompareEq NameLoad NameLoad body Continue Return NameLoad Raise Call NameLoad decorator_list NameLoad FunctionDef arguments args defaults body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str keyword Str Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore AttributeLoad NameLoad attr If CompareGtE Call AttributeLoad NameLoad attr Num body Assign NameStore Call NameLoad NameLoad orelse Assign NameStore Call NameLoad NameLoad Print NameLoad decorator_list If CompareEq NameLoad Str body Expr Call NameLoad
N/A N/A 
Command-line utility to get the IP address from the newest DHCP lease.

It's written for using with vagrant-hostmanager and vagrant-libvirt plugins.
Vagrant-hostmanager by default fetches only IP addresses from eth0 interfaces
on VM-s. Therefore, the first purpose of this utility is to be able to fetch
the address also from the other interfaces.

Libvirt/virsh only lists all DHCP leases for the given network with timestamps.
DHCP leases have their expiration time, but are not cleaned up after destroying
VM. If someone destroys and sets up the VM with the same hostname, we have
many DHCP leases for the same hostname and we have to look up for timestamp.
That's the second purpose of this script.
 N/A argparse N/A csv N/A functools N/A operator N/A xml.etree.ElementTree etree N/A libvirt NoPrivateDHCPInterfaceException N/A Exception N/A N/A N/A NoDHCPLeaseException N/A Exception N/A N/A N/A libvirt_conn N/A N/A f N/A N/A wrapper N/A N/A N/A args kwargs N/A N/A conn N/A N/A libvirt openReadOnly qemu:///system N/A N/A f conn args kwargs N/A N/A N/A functools wraps f N/A wrapper N/A get_vir_network_dhcp_lease N/A N/A conn vm_name N/A N/A N/A Libvirt since 1.2.6 version provides DHCPLeases method in virNetwork.

    That's the current official way for getting DHCP leases and this
    information isn't stored anywhere else anymore.
     N/A network N/A N/A conn networkLookupByName vagrant-private-dhcp N/A dhcp_leases N/A N/A N/A libvirt virNetwork DHCPLeases network N/A vm_dhcp_leases N/A filter N/A N/A N/A lease N/A N/A N/A lease N/A hostname vm_name dhcp_leases N/A newest_vm_dhcp_lease N/A N/A N/A sorted vm_dhcp_leases key N/A N/A operator itemgetter expirytime reverse True N/A 0 N/A ipaddr N/A newest_vm_dhcp_lease N/A libvirt_conn get_mac_address N/A N/A conn domain_name N/A N/A N/A Get MAC address from domain XML. N/A domain N/A N/A conn lookupByName domain_name N/A domain_xml N/A N/A domain XMLDesc N/A domain_tree N/A N/A etree fromstring domain_xml N/A devices N/A N/A domain_tree find devices N/A interfaces N/A N/A devices iterfind interface N/A interface interfaces N/A N/A source N/A N/A interface find source N/A N/A N/A source None N/A N/A N/A source get network vagrant-private-dhcp N/A N/A N/A mac_element N/A N/A interface find mac N/A mac_address N/A N/A mac_element get address N/A mac_address N/A N/A NoPrivateDHCPInterfaceException N/A get_dnsmasq_dhcp_lease N/A N/A conn vm_name N/A N/A N/A In libvirt under 1.2.6 DHCP leases are stored in file.

    There is no API for DHCP leases yet.
     N/A domain_name N/A vagrant_ vm_name N/A mac_address N/A get_mac_address conn domain_name N/A N/A open /var/lib/libvirt/dnsmasq/vagrant-private-dhcp.leases leases_file N/A N/A reader N/A N/A csv reader leases_file delimiter N/A row reader N/A N/A N/A lease_mac lease_ip lease_vm_name N/A row N/A 1 4 N/A N/A N/A N/A lease_mac mac_address N/A lease_vm_name vm_name N/A N/A N/A lease_ip N/A N/A NoDHCPLeaseException N/A libvirt_conn main N/A N/A N/A N/A N/A parser N/A N/A argparse ArgumentParser N/A N/A N/A parser add_argument vm_name help Name of the virtual machine N/A args N/A N/A parser parse_args N/A vm_name N/A args vm_name N/A N/A N/A N/A libvirt getVersion 1002006 N/A N/A newest_dhcp_lease N/A get_vir_network_dhcp_lease vm_name N/A N/A newest_dhcp_lease N/A get_dnsmasq_dhcp_lease vm_name N/A newest_dhcp_lease N/A N/A N/A __name__ __main__ N/A N/A N/A main