lib/vagrant-libvirt/driver.rb in vagrant-libvirt-0.6.3 vs lib/vagrant-libvirt/driver.rb in vagrant-libvirt-0.7.0

- old
+ new

@@ -59,11 +59,11 @@ # again. return @system_connection if @system_connection config = @machine.provider_config - @system_connection = Libvirt::open(config.system_uri) + @system_connection = Libvirt::open_read_only(config.system_uri) @system_connection end def get_domain(machine) begin @@ -96,20 +96,20 @@ get_domain_ipaddress(machine, domain) end def get_domain_ipaddress(machine, domain) - if @machine.provider_config.qemu_use_session - return get_ipaddress_from_system domain.mac - end - # attempt to get ip address from qemu agent if @machine.provider_config.qemu_use_agent == true @logger.info('Get IP via qemu agent') return get_ipaddress_from_qemu_agent(domain, machine.id) end + if @machine.provider_config.qemu_use_session + return get_ipaddress_from_system domain.mac + end + # Get IP address from dhcp leases table begin ip_address = get_ipaddress_from_domain(domain) rescue Fog::Errors::TimeoutError @logger.info('Timeout at waiting for an ip address for machine %s' % machine.name) @@ -166,22 +166,22 @@ end def get_ipaddress_from_qemu_agent(domain, machine_id) ip_address = nil addresses = nil - dom = system_connection.lookup_domain_by_uuid(machine_id) + libvirt_domain = connection.client.lookup_domain_by_uuid(machine_id) begin - response = dom.qemu_agent_command('{"execute":"guest-network-get-interfaces"}', timeout=10) + response = libvirt_domain.qemu_agent_command('{"execute":"guest-network-get-interfaces"}', timeout=10) @logger.debug("Got Response from qemu agent") @logger.debug(response) addresses = JSON.parse(response) rescue => e @logger.debug("Unable to receive IP via qemu agent: [%s]" % e.message) end unless addresses.nil? addresses["return"].each{ |interface| - if domain.mac == interface["hardware-address"] + if domain.mac.downcase == interface["hardware-address"].downcase @logger.debug("Found mathing interface: [%s]" % interface["name"]) if interface.has_key?("ip-addresses") interface["ip-addresses"].each{ |ip| # returning ipv6 addresses might break windows guests because # winrm cant handle connection, winrm fails with "invalid uri"