Halt on destroy will not attempt graceful [closes GH-110]
This commit is contained in:
parent
7e9b75f939
commit
a0fa3755b5
|
@ -71,7 +71,7 @@ module Vagrant
|
|||
|
||||
# destroy - Halts, cleans up, and destroys an existing VM
|
||||
destroy = Builder.new do
|
||||
use Action[:halt]
|
||||
use Action[:halt], :force => true
|
||||
use VM::DestroyUnusedNetworkInterfaces
|
||||
use VM::Destroy
|
||||
end
|
||||
|
|
|
@ -4,13 +4,14 @@ module Vagrant
|
|||
class Halt
|
||||
include ExceptionCatcher
|
||||
|
||||
def initialize(app, env)
|
||||
def initialize(app, env, options=nil)
|
||||
@app = app
|
||||
env.merge!(options || {})
|
||||
end
|
||||
|
||||
def call(env)
|
||||
if env["vm"].vm.running?
|
||||
if !env["force"]
|
||||
if !env[:force]
|
||||
catch_action_exception(env) { env["vm"].system.halt }
|
||||
return if env.error?
|
||||
end
|
||||
|
|
|
@ -17,6 +17,13 @@ class HaltVMActionTest < Test::Unit::TestCase
|
|||
@instance = @klass.new(@app, @env)
|
||||
end
|
||||
|
||||
context "initializing" do
|
||||
should "merge in the given options" do
|
||||
@klass.new(@app, @env, :foo => :bar)
|
||||
assert_equal :bar, @env[:foo]
|
||||
end
|
||||
end
|
||||
|
||||
context "calling" do
|
||||
setup do
|
||||
@internal_vm.stubs(:running?).returns(true)
|
||||
|
@ -54,7 +61,7 @@ class HaltVMActionTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "not call halt on the system if forcing" do
|
||||
@env["force"] = true
|
||||
@env[:force] = true
|
||||
@vm.system.expects(:halt).never
|
||||
@instance.call(@env)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue