Guest `halt` implementations no longer depend on machine state
This commit is contained in:
parent
31448c4cd4
commit
0fc7cf7f02
|
@ -13,17 +13,6 @@ module VagrantPlugins
|
|||
|
||||
def halt
|
||||
vm.channel.sudo("shutdown -p now")
|
||||
|
||||
# Wait until the VM's state is actually powered off. If this doesn't
|
||||
# occur within a reasonable amount of time (15 seconds by default),
|
||||
# then simply return and allow Vagrant to kill the machine.
|
||||
count = 0
|
||||
while vm.state != :poweroff
|
||||
count += 1
|
||||
|
||||
return if count >= vm.config.freebsd.halt_timeout
|
||||
sleep vm.config.freebsd.halt_check_interval
|
||||
end
|
||||
end
|
||||
|
||||
# TODO: vboxsf is currently unsupported in FreeBSD, if you are able to
|
||||
|
|
|
@ -35,17 +35,6 @@ module VagrantPlugins
|
|||
|
||||
def halt
|
||||
@vm.communicate.sudo("shutdown -h now")
|
||||
|
||||
# Wait until the VM's state is actually powered off. If this doesn't
|
||||
# occur within a reasonable amount of time (15 seconds by default),
|
||||
# then simply return and allow Vagrant to kill the machine.
|
||||
count = 0
|
||||
while @vm.state != :poweroff
|
||||
count += 1
|
||||
|
||||
return if count >= @vm.config.linux.halt_timeout
|
||||
sleep @vm.config.linux.halt_check_interval
|
||||
end
|
||||
end
|
||||
|
||||
def mount_shared_folder(name, guestpath, options)
|
||||
|
|
|
@ -7,17 +7,6 @@ module VagrantPlugins
|
|||
class Guest < VagrantPlugins::GuestLinux::Guest
|
||||
def halt
|
||||
vm.channel.sudo("shutdown -p -h now")
|
||||
|
||||
# Wait until the VM's state is actually powered off. If this doesn't
|
||||
# occur within a reasonable amount of time then simply return which
|
||||
# will cause Vagrant to force kill the machine.
|
||||
count = 0
|
||||
while vm.state != :poweroff
|
||||
count += 1
|
||||
|
||||
return if count >= 30
|
||||
sleep 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -45,35 +45,7 @@ module VagrantPlugins
|
|||
#
|
||||
# does not exist in /etc/user_attr. TODO
|
||||
def halt
|
||||
# Wait until the VM's state is actually powered off. If this doesn't
|
||||
# occur within a reasonable amount of time (15 seconds by default),
|
||||
# then simply return and allow Vagrant to kill the machine.
|
||||
count = 0
|
||||
last_error = nil
|
||||
while vm.state != :poweroff
|
||||
begin
|
||||
vm.channel.execute("#{vm.config.solaris.suexec_cmd} /usr/sbin/poweroff")
|
||||
rescue IOError => e
|
||||
# Save the last error; if it's not shutdown in a reasonable amount
|
||||
# of attempts we will re-raise the error so it's not hidden for
|
||||
# all time
|
||||
last_error = e
|
||||
end
|
||||
|
||||
count += 1
|
||||
if count >= vm.config.solaris.halt_timeout
|
||||
# Check for last error and re-raise it
|
||||
if last_error != nil
|
||||
raise last_error
|
||||
else
|
||||
# Otherwise, just return
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
# Still opportunities remaining; sleep and loop
|
||||
sleep vm.config.solaris.halt_check_interval
|
||||
end # while
|
||||
end
|
||||
|
||||
def mount_shared_folder(name, guestpath, options)
|
||||
|
|
Loading…
Reference in New Issue