Add reboot output to guest capability

This commit is contained in:
Chris Roberts 2019-02-01 15:47:02 -08:00
parent dfe9762210
commit ade5370db3
3 changed files with 31 additions and 5 deletions

View File

@ -21,6 +21,8 @@ module VagrantPlugins
@logger.debug("A reboot is already in progress") @logger.debug("A reboot is already in progress")
end end
machine.ui.info(I18n.t("vagrant.guests.capabilities.rebooting"))
@logger.debug("Waiting for machine to finish rebooting") @logger.debug("Waiting for machine to finish rebooting")
wait_remaining = MAX_REBOOT_RETRY_DURATION wait_remaining = MAX_REBOOT_RETRY_DURATION

View File

@ -1922,6 +1922,14 @@ en:
path of the shared folder must be located on a file system with path of the shared folder must be located on a file system with
DrvFs type. Host path: %{path} DrvFs type. Host path: %{path}
#-------------------------------------------------------------------------------
# Translations for guests
#-------------------------------------------------------------------------------
guests:
capabilities:
rebooting: |-
Waiting for machine to reboot...
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Translations for commands. e.g. `vagrant x` # Translations for commands. e.g. `vagrant x`
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------

View File

@ -8,9 +8,10 @@ describe "VagrantPlugins::GuestWindows::Cap::Reboot" do
end end
let(:vm) { double("vm") } let(:vm) { double("vm") }
let(:config) { double("config") } let(:config) { double("config") }
let(:machine) { double("machine") } let(:machine) { double("machine", ui: ui) }
let(:guest) { double("guest") } let(:guest) { double("guest") }
let(:communicator) { double("communicator") } let(:communicator) { double("communicator") }
let(:ui) { double("ui") }
before do before do
allow(machine).to receive(:communicate).and_return(communicator) allow(machine).to receive(:communicate).and_return(communicator)
@ -18,6 +19,7 @@ describe "VagrantPlugins::GuestWindows::Cap::Reboot" do
allow(machine.guest).to receive(:ready?).and_return(true) allow(machine.guest).to receive(:ready?).and_return(true)
allow(machine).to receive(:config).and_return(config) allow(machine).to receive(:config).and_return(config)
allow(config).to receive(:vm).and_return(vm) allow(config).to receive(:vm).and_return(vm)
allow(ui).to receive(:info)
end end
describe ".reboot" do describe ".reboot" do
@ -26,13 +28,27 @@ describe "VagrantPlugins::GuestWindows::Cap::Reboot" do
end end
it "reboots the vm" do it "reboots the vm" do
allow(communicator).to receive(:execute)
expect(communicator).to receive(:test).with(/# Function/, { error_check: false, shell: :powershell }).and_return(0)
expect(communicator).to receive(:execute).with(/shutdown/, { shell: :powershell }).and_return(0)
expect(described_class).to receive(:wait_for_reboot)
described_class.reboot(machine)
end
context "user output" do
before do
allow(communicator).to receive(:execute) allow(communicator).to receive(:execute)
allow(described_class).to receive(:wait_for_reboot)
end
expect(communicator).to receive(:test).with(/# Function/, { error_check: false, shell: :powershell }).and_return(0) after { described_class.reboot(machine) }
expect(communicator).to receive(:execute).with(/shutdown/, { shell: :powershell }).and_return(0)
expect(described_class).to receive(:wait_for_reboot)
described_class.reboot(machine) it "sends message to user that guest is rebooting" do
expect(communicator).to receive(:test).and_return(true)
expect(ui).to receive(:info)
end
end end
end end