fog / fog-libvirt

libvirt provider for fog
MIT License
16 stars 42 forks source link

Use libvirt DHCP leases API #8

Closed danielshahaf closed 8 years ago

danielshahaf commented 9 years ago

Fog::Compute::Libvirt::Server#addresses runs an external shell command to determine the IP address of a VM that has a given MAC address. The implementation assumes libvirtd runs on localhost or can be SSHed to; it ignores other cases, such as a TCP transport. Please use the ruby-libvirt bindings' dhcp_leases method, to also support the case when libvirtd runs on a remote host, using a TCP transport.

The code should be something along these lines:

libvirt_conn = @client
libvirt_network = libvirt_conn.lookup_network_by_name('default')
libvirt_network.dhcp_leases('52:54:00:54:74:88')
danielshahaf commented 9 years ago

A few random bits of background:

domcleal commented 8 years ago

The dhcp_leases method does not appear in the latest ruby-libvirt release, 0.5.2; it's only in git master.

0.6.0 has been released now with the dhcp_leases API (https://www.redhat.com/archives/libvir-list/2015-November/msg00867.html).

dcbw commented 8 years ago

PR coming up. However, even ruby-libvirt 0.6.0 has a bug in the DHCP leases support that causes a crash. See https://www.redhat.com/archives/libvir-list/2016-January/msg00147.html for the fix.

dcbw commented 8 years ago

RFC PR in https://github.com/fog/fog-libvirt/pull/11