From cf5528b813c2ec0f953a71e9cd26a2ae78852331 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 6 Mar 2014 12:27:05 -0800 Subject: [PATCH] providers/hyperv: ssh_info doesn't need a dedicated action stack --- plugins/providers/hyperv/action.rb | 9 --------- plugins/providers/hyperv/provider.rb | 18 ++++++++++-------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/plugins/providers/hyperv/action.rb b/plugins/providers/hyperv/action.rb index 99800d918..5721749e6 100644 --- a/plugins/providers/hyperv/action.rb +++ b/plugins/providers/hyperv/action.rb @@ -161,14 +161,6 @@ module VagrantPlugins end end - def self.action_read_guest_ip - Vagrant::Action::Builder.new.tap do |b| - b.use ConfigValidate - b.use ReadGuestIP - end - end - - # The autoload farm action_root = Pathname.new(File.expand_path("../action", __FILE__)) autoload :DeleteVM, action_root.join("delete_vm") @@ -179,7 +171,6 @@ module VagrantPlugins autoload :StartInstance, action_root.join('start_instance') autoload :StopInstance, action_root.join('stop_instance') autoload :SuspendVM, action_root.join("suspend_vm") - autoload :ReadGuestIP, action_root.join('read_guest_ip') autoload :WaitForIPAddress, action_root.join("wait_for_ip_address") end end diff --git a/plugins/providers/hyperv/provider.rb b/plugins/providers/hyperv/provider.rb index 145bb6266..957ad6792 100644 --- a/plugins/providers/hyperv/provider.rb +++ b/plugins/providers/hyperv/provider.rb @@ -70,15 +70,17 @@ module VagrantPlugins end def ssh_info - # Run a custom action called "read_guest_ip" which does what it - # says and puts the resulting SSH info into the `:machine_ssh_info` - # key in the environment. - env = @machine.action("read_guest_ip") - if env[:machine_ssh_info] - env[:machine_ssh_info].merge!(:port => 22) - end + # We can only SSH into a running machine + return nil if state.id != :running - env[:machine_ssh_info] + # Read the IP of the machine using Hyper-V APIs + network = @driver.read_guest_ip + return nil if !network["ip"] + + { + host: network["ip"], + port: 22, + } end end end