reintroduce sleep_timeout for guests that fail the :wait_for_reboot capability check
This commit is contained in:
parent
4e8062625c
commit
2c9e9e9ab8
|
@ -4,10 +4,10 @@ module VagrantPlugins
|
||||||
module ChangeHostName
|
module ChangeHostName
|
||||||
|
|
||||||
def self.change_host_name(machine, name)
|
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
|
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
|
# If the configured name matches the current name, then bail
|
||||||
# We cannot use %ComputerName% because it truncates at 15 chars
|
# 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")
|
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
|
# Don't continue until the machine has shutdown and rebooted
|
||||||
if machine.guest.capability?(:wait_for_reboot)
|
if machine.guest.capability?(:wait_for_reboot)
|
||||||
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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue