Start, reload, halt now use middleware stacks
This commit is contained in:
parent
88587c3322
commit
642db533ee
|
@ -5,11 +5,9 @@ module Vagrant
|
|||
# all the necessary Vagrant libraries are loaded. Hopefully
|
||||
# in the future this will no longer be necessary with autoloading.
|
||||
def self.builtin!
|
||||
up = Builder.new do
|
||||
use VM::Import
|
||||
use VM::Persist
|
||||
use VM::MatchMACAddress
|
||||
use VM::CheckGuestAdditions
|
||||
# start - Starts a VM, assuming it already exists on the
|
||||
# environment.
|
||||
start = Builder.new do
|
||||
use VM::Customize
|
||||
use VM::ForwardPorts
|
||||
use VM::Provision
|
||||
|
@ -18,13 +16,42 @@ module Vagrant
|
|||
use VM::Boot
|
||||
end
|
||||
|
||||
destroy = Builder.new do
|
||||
register :start, start
|
||||
|
||||
# halt - Halts the VM, attempting gracefully but then forcing
|
||||
# a restart if fails.
|
||||
halt = Builder.new do
|
||||
use VM::Halt
|
||||
end
|
||||
|
||||
register :halt, halt
|
||||
|
||||
# reload - Halts then restarts the VM
|
||||
reload = Builder.new do
|
||||
use Action[:halt].mergeable
|
||||
use Action[:start].mergeable
|
||||
end
|
||||
|
||||
register :reload, reload
|
||||
|
||||
# up - Imports, prepares, then starts a fresh VM.
|
||||
up = Builder.new do
|
||||
use VM::Import
|
||||
use VM::Persist
|
||||
use VM::MatchMACAddress
|
||||
use VM::CheckGuestAdditions
|
||||
use Action[:start].mergeable
|
||||
end
|
||||
|
||||
register :up, up
|
||||
|
||||
# destroy - Halts, cleans up, and destroys an existing VM
|
||||
destroy = Builder.new do
|
||||
use Action[:halt].mergeable
|
||||
use VM::DestroyUnusedNetworkInterfaces
|
||||
use VM::Destroy
|
||||
end
|
||||
|
||||
register :up, up
|
||||
register :destroy, destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -106,15 +106,15 @@ module Vagrant
|
|||
def start
|
||||
return if @vm.running?
|
||||
|
||||
execute!(Actions::VM::Start)
|
||||
env.actions.run(:start)
|
||||
end
|
||||
|
||||
def halt(options=nil)
|
||||
execute!(Actions::VM::Halt, options)
|
||||
env.actions.run(:halt, options)
|
||||
end
|
||||
|
||||
def reload
|
||||
execute!(Actions::VM::Reload)
|
||||
env.actions.run(:reload)
|
||||
end
|
||||
|
||||
def provision
|
||||
|
|
|
@ -170,19 +170,14 @@ class VMTest < Test::Unit::TestCase
|
|||
|
||||
context "halting" do
|
||||
should "execute the halt action" do
|
||||
@vm.expects(:execute!).with(Vagrant::Actions::VM::Halt, nil).once
|
||||
@vm.halt
|
||||
end
|
||||
|
||||
should "force if specified" do
|
||||
@vm.expects(:execute!).with(Vagrant::Actions::VM::Halt, {:foo => :bar}).once
|
||||
@vm.env.actions.expects(:run).with(:halt, :foo => :bar).once
|
||||
@vm.halt({:foo => :bar})
|
||||
end
|
||||
end
|
||||
|
||||
context "reloading action" do
|
||||
should "execute the reload action" do
|
||||
@vm.expects(:execute!).with(Vagrant::Actions::VM::Reload).once
|
||||
@vm.env.actions.expects(:run).with(:reload).once
|
||||
@vm.reload
|
||||
end
|
||||
end
|
||||
|
@ -227,7 +222,7 @@ class VMTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "execute the start action" do
|
||||
@vm.expects(:execute!).once.with(Vagrant::Actions::VM::Start)
|
||||
@vm.env.actions.expects(:run).with(:start).once
|
||||
@vm.start
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue