fixes from @sethvargo comments.

This commit is contained in:
Matt Wrock 2015-06-05 00:11:06 -07:00
parent c60a020096
commit 1cd1033093
4 changed files with 13 additions and 14 deletions

View File

@ -45,16 +45,16 @@ module VagrantPlugins
raise Vagrant::Errors::VMNotCreatedError raise Vagrant::Errors::VMNotCreatedError
end end
if machine.config.vm.communicator != :winrm #|| !machine.provider.capability?(:winrm_info) if machine.config.vm.communicator != :winrm
raise VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady raise VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady
end end
if !options[:command].nil? if !options[:command].nil?
out_code = machine.communicate.execute options[:command] out_code = machine.communicate.execute(options[:command])
if out_code == 0 if out_code == 0
machine.ui.detail("Command: #{options[:command]} executed succesfully with output code #{out_code}.") machine.ui.detail("Command: #{options[:command]} executed succesfully with output code #{out_code}.")
end end
break next
end end
ps_info = VagrantPlugins::CommunicatorWinRM::Helper.winrm_info(machine) ps_info = VagrantPlugins::CommunicatorWinRM::Helper.winrm_info(machine)
@ -63,7 +63,7 @@ module VagrantPlugins
# Extra arguments if we have any # Extra arguments if we have any
ps_info[:extra_args] = options[:extra_args] ps_info[:extra_args] = options[:extra_args]
result = ready_ps_remoting_for machine, ps_info result = ready_ps_remoting_for(machine, ps_info)
machine.ui.detail( machine.ui.detail(
"Creating powershell session to #{ps_info[:host]}:#{ps_info[:port]}") "Creating powershell session to #{ps_info[:host]}:#{ps_info[:port]}")
@ -73,7 +73,7 @@ module VagrantPlugins
@env.host.capability(:ps_client, ps_info) @env.host.capability(:ps_client, ps_info)
ensure ensure
if !result["PreviousTrustedHosts"].nil? if !result["PreviousTrustedHosts"].nil?
reset_ps_remoting_for machine, ps_info reset_ps_remoting_for(machine, ps_info)
end end
end end
end end

View File

@ -7,12 +7,12 @@ module VagrantPlugins
class Plugin < Vagrant.plugin("2") class Plugin < Vagrant.plugin("2")
name "ps command" name "ps command"
description <<-DESC description <<-DESC
The ps command opens a remote powershell session to the The ps command opens a remote PowerShell session to the
machine if it supports powershell remoting. machine if it supports powershell remoting.
DESC DESC
command("ps") do command("ps") do
require File.expand_path("../command", __FILE__) require_relative "../command"
init! init!
Command Command
end end
@ -21,8 +21,7 @@ module VagrantPlugins
def self.init! def self.init!
return if defined?(@_init) return if defined?(@_init)
I18n.load_path << File.expand_path( I18n.load_path << File.expand_path("templates/locales/command_ps.yml", Vagrant.source_root)
"templates/locales/command_ps.yml", Vagrant.source_root)
I18n.reload! I18n.reload!
@_init = true @_init = true
end end

View File

@ -9,7 +9,7 @@ Vagrant::Util::SilenceWarnings.silence! do
require "winrm" require "winrm"
end end
require "winrm-fs/file_manager" require "winrm-fs"
module VagrantPlugins module VagrantPlugins
module CommunicatorWinRM module CommunicatorWinRM

View File

@ -1,16 +1,16 @@
en: en:
vagrant_ps: vagrant_ps:
detecting: |- detecting: |-
Detecting if a remote powershell connection can be made with the guest... Detecting if a remote PowerShell connection can be made with the guest...
reseting: |- reseting: |-
Reseting WinRM TrustedHosts to their original value. Reseting WinRM TrustedHosts to their original value.
errors: errors:
host_unsupported: |- host_unsupported: |-
Your host does not support powershell. A remote powershell connection Your host does not support PowerShell. A remote PowerShell connection
can only be made from a windows host. can only be made from a windows host.
ps_remoting_undetected: |- ps_remoting_undetected: |-
Unable to establish a remote powershell connection with the guest. Unable to establish a remote PowerShell connection with the guest.
Check if the firewall rules on the guest allow connections to the Check if the firewall rules on the guest allow connections to the
windows remote management service. Windows remote management service.