plugins/providers/hyperv/provider.rb in vagrant-unbundled-2.2.0.0 vs plugins/providers/hyperv/provider.rb in vagrant-unbundled-2.2.2.0
- old
+ new
@@ -36,10 +36,11 @@
@machine = machine
# This method will load in our driver, so we call it now to
# initialize it.
machine_id_changed
+ @logger = Log4r::Logger.new("vagrant::hyperv::provider")
end
def action(name)
# Attempt to get the action method from the Action class if it
# exists, otherwise return nil to show that we don't support the
@@ -81,19 +82,30 @@
def to_s
id = @machine.id.nil? ? "new" : @machine.id
"Hyper-V (#{id})"
end
+ # @return [Hash]
def ssh_info
# We can only SSH into a running machine
return nil if state.id != :running
# Read the IP of the machine using Hyper-V APIs
- network = @driver.read_guest_ip
- return nil if !network["ip"]
+ guest_ip = nil
+ begin
+ network_info = @driver.read_guest_ip
+ guest_ip = network_info["ip"]
+ rescue Errors::PowerShellError
+ @logger.warn("Failed to read guest IP.")
+ end
+
+ return nil if !guest_ip
+
+ @logger.debug("IP: #{guest_ip}")
+
{
- host: network["ip"],
+ host: guest_ip,
port: 22,
}
end
end
end