Fix some small issues with up, down, and halt with the latest refactor.
This commit is contained in:
parent
455a44cc5d
commit
6f287aa17a
|
@ -5,7 +5,7 @@ module Vagrant
|
||||||
def prepare
|
def prepare
|
||||||
# The true as the 2nd parameter always forces the shutdown so its
|
# The true as the 2nd parameter always forces the shutdown so its
|
||||||
# fast (since we're destroying anyways)
|
# fast (since we're destroying anyways)
|
||||||
@runner.add_action(Halt, true) if @runner.vm.running?
|
@runner.add_action(Halt, :force => true) if @runner.vm.running?
|
||||||
@runner.add_action(Destroy)
|
@runner.add_action(Destroy)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def force?
|
||||||
|
!!options[:force]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,13 +8,18 @@ module Vagrant
|
||||||
steps = [Boot]
|
steps = [Boot]
|
||||||
if !@runner.vm || !@runner.vm.saved?
|
if !@runner.vm || !@runner.vm.saved?
|
||||||
steps.unshift([Customize, ForwardPorts, SharedFolders])
|
steps.unshift([Customize, ForwardPorts, SharedFolders])
|
||||||
steps << Provision if !@runner.env.config.vm.provisioner.nil? && options[:provision]
|
steps << Provision if provision?
|
||||||
end
|
end
|
||||||
|
|
||||||
steps.flatten.each do |action_klass|
|
steps.flatten.each do |action_klass|
|
||||||
@runner.add_action(action_klass, options)
|
@runner.add_action(action_klass, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def provision?
|
||||||
|
enabled = options[:provision].nil? ? true : options[:provision]
|
||||||
|
!@runner.env.config.vm.provisioner.nil? && enabled
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ class DownActionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
should "add the halt action if the VM is running" do
|
should "add the halt action if the VM is running" do
|
||||||
@vm.expects(:running?).returns(true)
|
@vm.expects(:running?).returns(true)
|
||||||
setup_action_expectations([[Vagrant::Actions::VM::Halt, true], Vagrant::Actions::VM::Destroy])
|
setup_action_expectations([[Vagrant::Actions::VM::Halt, {:force => true}], Vagrant::Actions::VM::Destroy])
|
||||||
@action.prepare
|
@action.prepare
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,6 +6,18 @@ class HaltActionTest < Test::Unit::TestCase
|
||||||
@runner.stubs(:system).returns(linux_system(@vm))
|
@runner.stubs(:system).returns(linux_system(@vm))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "force?" do
|
||||||
|
should "not force by default" do
|
||||||
|
@action.options[:force] = nil
|
||||||
|
assert !@action.force?
|
||||||
|
end
|
||||||
|
|
||||||
|
should "force if specified" do
|
||||||
|
@action.options[:force] = true
|
||||||
|
assert @action.force?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "executing" do
|
context "executing" do
|
||||||
setup do
|
setup do
|
||||||
@vm.stubs(:running?).returns(true)
|
@vm.stubs(:running?).returns(true)
|
||||||
|
|
|
@ -52,4 +52,22 @@ class StartActionTest < Test::Unit::TestCase
|
||||||
@action.prepare
|
@action.prepare
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "provision?" do
|
||||||
|
should "return false if no provisioner is set" do
|
||||||
|
@vm.env.config.vm.provisioner = nil
|
||||||
|
assert !@action.provision?
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return true if a provisioner is set" do
|
||||||
|
@vm.env.config.vm.provisioner = :chef_solo
|
||||||
|
assert @action.provision?
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return false if provisioning is specifically disabled" do
|
||||||
|
@vm.env.config.vm.provisioner = :chef_solo
|
||||||
|
@action.options[:provision] = false
|
||||||
|
assert !@action.provision?
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue