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
|
# all the necessary Vagrant libraries are loaded. Hopefully
|
||||||
# in the future this will no longer be necessary with autoloading.
|
# in the future this will no longer be necessary with autoloading.
|
||||||
def self.builtin!
|
def self.builtin!
|
||||||
up = Builder.new do
|
# start - Starts a VM, assuming it already exists on the
|
||||||
use VM::Import
|
# environment.
|
||||||
use VM::Persist
|
start = Builder.new do
|
||||||
use VM::MatchMACAddress
|
|
||||||
use VM::CheckGuestAdditions
|
|
||||||
use VM::Customize
|
use VM::Customize
|
||||||
use VM::ForwardPorts
|
use VM::ForwardPorts
|
||||||
use VM::Provision
|
use VM::Provision
|
||||||
|
@ -18,13 +16,42 @@ module Vagrant
|
||||||
use VM::Boot
|
use VM::Boot
|
||||||
end
|
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
|
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::DestroyUnusedNetworkInterfaces
|
||||||
use VM::Destroy
|
use VM::Destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
register :up, up
|
|
||||||
register :destroy, destroy
|
register :destroy, destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,15 +106,15 @@ module Vagrant
|
||||||
def start
|
def start
|
||||||
return if @vm.running?
|
return if @vm.running?
|
||||||
|
|
||||||
execute!(Actions::VM::Start)
|
env.actions.run(:start)
|
||||||
end
|
end
|
||||||
|
|
||||||
def halt(options=nil)
|
def halt(options=nil)
|
||||||
execute!(Actions::VM::Halt, options)
|
env.actions.run(:halt, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
def reload
|
def reload
|
||||||
execute!(Actions::VM::Reload)
|
env.actions.run(:reload)
|
||||||
end
|
end
|
||||||
|
|
||||||
def provision
|
def provision
|
||||||
|
|
|
@ -170,19 +170,14 @@ class VMTest < Test::Unit::TestCase
|
||||||
|
|
||||||
context "halting" do
|
context "halting" do
|
||||||
should "execute the halt action" do
|
should "execute the halt action" do
|
||||||
@vm.expects(:execute!).with(Vagrant::Actions::VM::Halt, nil).once
|
@vm.env.actions.expects(:run).with(:halt, :foo => :bar).once
|
||||||
@vm.halt
|
|
||||||
end
|
|
||||||
|
|
||||||
should "force if specified" do
|
|
||||||
@vm.expects(:execute!).with(Vagrant::Actions::VM::Halt, {:foo => :bar}).once
|
|
||||||
@vm.halt({:foo => :bar})
|
@vm.halt({:foo => :bar})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "reloading action" do
|
context "reloading action" do
|
||||||
should "execute the reload 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
|
@vm.reload
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -227,7 +222,7 @@ class VMTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "execute the start action" do
|
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
|
@vm.start
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue