From c5e1a6d8c051981bc90ce6dd4bfe2f9b6d65afe6 Mon Sep 17 00:00:00 2001 From: Matt Wrock Date: Mon, 26 Sep 2016 14:07:11 -0700 Subject: [PATCH] use the cmd shell to check winrm availability --- plugins/communicators/winrm/communicator.rb | 2 +- .../plugins/communicators/winrm/communicator_test.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/communicators/winrm/communicator.rb b/plugins/communicators/winrm/communicator.rb index 78ba73879..8c7a292cf 100644 --- a/plugins/communicators/winrm/communicator.rb +++ b/plugins/communicators/winrm/communicator.rb @@ -104,7 +104,7 @@ module VagrantPlugins @logger.info("Checking whether WinRM is ready...") result = Timeout.timeout(@machine.config.winrm.timeout) do - shell(true).powershell("hostname") + shell(true).cmd("hostname") end @logger.info("WinRM is ready!") diff --git a/test/unit/plugins/communicators/winrm/communicator_test.rb b/test/unit/plugins/communicators/winrm/communicator_test.rb index 3e21242d9..d69185d86 100644 --- a/test/unit/plugins/communicators/winrm/communicator_test.rb +++ b/test/unit/plugins/communicators/winrm/communicator_test.rb @@ -45,7 +45,7 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do port: '22', }) # Makes ready? return true - allow(shell).to receive(:powershell).with("hostname").and_return({ exitcode: 0 }) + allow(shell).to receive(:cmd).with("hostname").and_return({ exitcode: 0 }) end it "retries ssh_info until ready" do @@ -57,22 +57,22 @@ describe VagrantPlugins::CommunicatorWinRM::Communicator do describe ".ready?" do it "returns true if hostname command executes without error" do - expect(shell).to receive(:powershell).with("hostname").and_return({ exitcode: 0 }) + expect(shell).to receive(:cmd).with("hostname").and_return({ exitcode: 0 }) expect(subject.ready?).to be_true end it "returns false if hostname command fails with a transient error" do - expect(shell).to receive(:powershell).with("hostname").and_raise(VagrantPlugins::CommunicatorWinRM::Errors::TransientError) + expect(shell).to receive(:cmd).with("hostname").and_raise(VagrantPlugins::CommunicatorWinRM::Errors::TransientError) expect(subject.ready?).to be_false end it "raises an error if hostname command fails with an unknown error" do - expect(shell).to receive(:powershell).with("hostname").and_raise(Vagrant::Errors::VagrantError) + expect(shell).to receive(:cmd).with("hostname").and_raise(Vagrant::Errors::VagrantError) expect { subject.ready? }.to raise_error(Vagrant::Errors::VagrantError) end it "raises timeout error when hostname command takes longer then winrm timeout" do - expect(shell).to receive(:powershell).with("hostname") do + expect(shell).to receive(:cmd).with("hostname") do sleep 2 # winrm.timeout = 1 end expect { subject.ready? }.to raise_error(Timeout::Error)