diff --git a/lib/fog/compute/models/libvirt/server.rb b/lib/fog/compute/models/libvirt/server.rb index e0dd0e1d4..190c4c277 100644 --- a/lib/fog/compute/models/libvirt/server.rb +++ b/lib/fog/compute/models/libvirt/server.rb @@ -14,7 +14,7 @@ module Fog include Fog::Compute::LibvirtUtil - identity :uuid + identity :id, :aliases => 'uuid' attribute :cpus attribute :os_type @@ -261,7 +261,7 @@ module Fog # Check if another ip_command string was provided ip_command=options[:ip_command].nil? ? "grep #{mac} /var/log/arpwatch.log |cut -d ':' -f 4-| cut -d ' ' -f 4" : options[:ip_command] - ipaddress=nil + ip_address=nil if @connection.uri.ssh_enabled? @@ -283,17 +283,17 @@ module Fog begin result=Fog::SSH.new(host, user, ssh_options).run(ip_command) rescue Errno::ECONNREFUSED - raise Fog::Errors::Error.new("Connection was refused to host #{host} to retrieve the ipaddress for #{mac}") + raise Fog::Errors::Error.new("Connection was refused to host #{host} to retrieve the ip_address for #{mac}") rescue Net::SSH::AuthenticationFailed raise Fog::Errors::Error.new("Error authenticating over ssh to host #{host} and user #{user}") end #TODO: We currently just retrieve the ip address through the ip_command - #TODO: We need to check if that Ipaddress is still valid for that mac-address + #TODO: We need to check if that ip_address is still valid for that mac-address # Check for a clean exit code if result.first.status == 0 - ipaddress=result.first.stdout.strip + ip_address=result.first.stdout.strip else # We got a failure executing the command raise Fog::Errors::Error.new("The command #{ip_command} failed to execute with a clean exit code") @@ -305,38 +305,35 @@ module Fog raise Fog::Errors::Error.new("TlS remote transport is not currently supported, only ssh") end + # Execute the ip_command locally IO.popen("#{ip_command}") do |p| p.each_line do |l| - ipaddress=+l + ip_address=+l end status=Process.waitpid2(p.pid)[1].exitstatus if status!=0 raise Fog::Errors::Error.new("The command #{ip_command} failed to execute with a clean exit code") end end - # TODO for locat execute - #No ssh just do it locally - #cat /var/log/daemon.log|grep "52:54:00:52:f6:22"| - # or local execute arp -an to get the ip (as a last resort) end - if ipaddress=="" + if ip_address=="" #The grep didn't find an ip address result" - ipaddress=nil + ip_address=nil else # To be sure that the command didn't return another random string # We check if the result is an actual ip-address # otherwise we return nil - unless ipaddress=~/^(\d{1,3}\.){3}\d{1,3}$/ + unless ip_address=~/^(\d{1,3}\.){3}\d{1,3}$/ raise Fog::Errors::Error.new( "The command #{ip_command} failed to execute with a clean exit code\n"+ - "Result was: #{ipaddress}\n" + "Result was: #{ip_address}\n" ) end end - return { :public => [ipaddress], :private => [ipaddress]} + return { :public => [ip_address], :private => [ip_address]} end def private_ip_address @@ -472,6 +469,7 @@ module Fog @raw = new_raw raw_attributes = { + :id => new_raw.uuid, :uuid => new_raw.uuid, :name => new_raw.name, :memory_size => new_raw.info.max_mem,