From 2c9e9e9ab83e9b15c34deadecd225da6dc293e2e Mon Sep 17 00:00:00 2001 From: ajpaul Date: Fri, 16 Mar 2018 13:53:27 -0400 Subject: [PATCH] reintroduce sleep_timeout for guests that fail the :wait_for_reboot capability check --- plugins/guests/windows/cap/change_host_name.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/guests/windows/cap/change_host_name.rb b/plugins/guests/windows/cap/change_host_name.rb index f33e2e84c..979627dc0 100644 --- a/plugins/guests/windows/cap/change_host_name.rb +++ b/plugins/guests/windows/cap/change_host_name.rb @@ -4,10 +4,10 @@ module VagrantPlugins module ChangeHostName def self.change_host_name(machine, name) - change_host_name_and_wait(machine, name) + change_host_name_and_wait(machine, name, machine.config.vm.graceful_halt_timeout) end - def self.change_host_name_and_wait(machine, name) + def self.change_host_name_and_wait(machine, name, sleep_timeout) # If the configured name matches the current name, then bail # We cannot use %ComputerName% because it truncates at 15 chars return if machine.communicate.test("if ([System.Net.Dns]::GetHostName() -eq '#{name}') { exit 0 } exit 1") @@ -30,6 +30,9 @@ module VagrantPlugins # Don't continue until the machine has shutdown and rebooted if machine.guest.capability?(:wait_for_reboot) machine.guest.capability(:wait_for_reboot) + else + # use graceful_halt_timeout only if guest cannot wait for reboot + sleep(sleep_timeout) end end end