Power off during the package sequence if not already.
This commit is contained in:
parent
b96acce79f
commit
f45989d1d5
|
@ -77,6 +77,7 @@ module Vagrant
|
||||||
|
|
||||||
# package - Export and package the VM
|
# package - Export and package the VM
|
||||||
package = Builder.new do
|
package = Builder.new do
|
||||||
|
use Action[:halt]
|
||||||
use VM::Export
|
use VM::Export
|
||||||
use VM::Package
|
use VM::Package
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,8 @@ module Vagrant
|
||||||
def call(env)
|
def call(env)
|
||||||
@env = env
|
@env = env
|
||||||
|
|
||||||
|
return env.error!(:vm_power_off_to_package) if !@env["vm"].vm.powered_off?
|
||||||
|
|
||||||
setup_temp_dir
|
setup_temp_dir
|
||||||
export
|
export
|
||||||
|
|
||||||
|
|
|
@ -53,11 +53,6 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def package_vm(vm)
|
def package_vm(vm)
|
||||||
if !vm.powered_off?
|
|
||||||
error_and_exit(:vm_power_off_to_package)
|
|
||||||
return # for tests
|
|
||||||
end
|
|
||||||
|
|
||||||
vm.package(options)
|
vm.package(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@ class ExportVMActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
context "calling" do
|
context "calling" do
|
||||||
|
setup do
|
||||||
|
@internal_vm.stubs(:powered_off?).returns(true)
|
||||||
|
end
|
||||||
|
|
||||||
should "call the proper methods then continue chain" do
|
should "call the proper methods then continue chain" do
|
||||||
seq = sequence("seq")
|
seq = sequence("seq")
|
||||||
@instance.expects(:setup_temp_dir).in_sequence(seq)
|
@instance.expects(:setup_temp_dir).in_sequence(seq)
|
||||||
|
@ -23,6 +27,17 @@ class ExportVMActionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
@instance.call(@env)
|
@instance.call(@env)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "halt the chain if not powered off" do
|
||||||
|
@internal_vm.stubs(:powered_off?).returns(false)
|
||||||
|
@instance.expects(:setup_temp_dir).never
|
||||||
|
@instance.expects(:export).never
|
||||||
|
@app.expects(:call).with(@env).never
|
||||||
|
|
||||||
|
@instance.call(@env)
|
||||||
|
assert @env.error?
|
||||||
|
assert_equal :vm_power_off_to_package, @env.error.first
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "setting up the temporary directory" do
|
context "setting up the temporary directory" do
|
||||||
|
|
|
@ -81,18 +81,11 @@ class CommandsPackageTest < Test::Unit::TestCase
|
||||||
context "packaging a VM" do
|
context "packaging a VM" do
|
||||||
setup do
|
setup do
|
||||||
@vm = mock("vm")
|
@vm = mock("vm")
|
||||||
@vm.stubs(:powered_off?).returns(true)
|
|
||||||
|
|
||||||
@options = {}
|
@options = {}
|
||||||
@instance.stubs(:options).returns(@options)
|
@instance.stubs(:options).returns(@options)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "error and exit if VM is not powered off" do
|
|
||||||
@vm.stubs(:powered_off?).returns(false)
|
|
||||||
@instance.expects(:error_and_exit).with(:vm_power_off_to_package).once
|
|
||||||
@instance.package_vm(@vm)
|
|
||||||
end
|
|
||||||
|
|
||||||
should "package the VM with the proper arguments" do
|
should "package the VM with the proper arguments" do
|
||||||
@options[:output] = "foo.box"
|
@options[:output] = "foo.box"
|
||||||
@options[:include] = :bar
|
@options[:include] = :bar
|
||||||
|
|
|
@ -43,11 +43,13 @@ Gem::Specification.new do |s|
|
||||||
"lib/vagrant/action/vm/customize.rb",
|
"lib/vagrant/action/vm/customize.rb",
|
||||||
"lib/vagrant/action/vm/destroy.rb",
|
"lib/vagrant/action/vm/destroy.rb",
|
||||||
"lib/vagrant/action/vm/destroy_unused_network_interfaces.rb",
|
"lib/vagrant/action/vm/destroy_unused_network_interfaces.rb",
|
||||||
|
"lib/vagrant/action/vm/export.rb",
|
||||||
"lib/vagrant/action/vm/forward_ports.rb",
|
"lib/vagrant/action/vm/forward_ports.rb",
|
||||||
"lib/vagrant/action/vm/halt.rb",
|
"lib/vagrant/action/vm/halt.rb",
|
||||||
"lib/vagrant/action/vm/import.rb",
|
"lib/vagrant/action/vm/import.rb",
|
||||||
"lib/vagrant/action/vm/match_mac_address.rb",
|
"lib/vagrant/action/vm/match_mac_address.rb",
|
||||||
"lib/vagrant/action/vm/network.rb",
|
"lib/vagrant/action/vm/network.rb",
|
||||||
|
"lib/vagrant/action/vm/package.rb",
|
||||||
"lib/vagrant/action/vm/persist.rb",
|
"lib/vagrant/action/vm/persist.rb",
|
||||||
"lib/vagrant/action/vm/provision.rb",
|
"lib/vagrant/action/vm/provision.rb",
|
||||||
"lib/vagrant/action/vm/resume.rb",
|
"lib/vagrant/action/vm/resume.rb",
|
||||||
|
@ -141,11 +143,13 @@ Gem::Specification.new do |s|
|
||||||
"test/vagrant/action/vm/customize_test.rb",
|
"test/vagrant/action/vm/customize_test.rb",
|
||||||
"test/vagrant/action/vm/destroy_test.rb",
|
"test/vagrant/action/vm/destroy_test.rb",
|
||||||
"test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb",
|
"test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb",
|
||||||
|
"test/vagrant/action/vm/export_test.rb",
|
||||||
"test/vagrant/action/vm/forward_ports_test.rb",
|
"test/vagrant/action/vm/forward_ports_test.rb",
|
||||||
"test/vagrant/action/vm/halt_test.rb",
|
"test/vagrant/action/vm/halt_test.rb",
|
||||||
"test/vagrant/action/vm/import_test.rb",
|
"test/vagrant/action/vm/import_test.rb",
|
||||||
"test/vagrant/action/vm/match_mac_address_test.rb",
|
"test/vagrant/action/vm/match_mac_address_test.rb",
|
||||||
"test/vagrant/action/vm/network_test.rb",
|
"test/vagrant/action/vm/network_test.rb",
|
||||||
|
"test/vagrant/action/vm/package_test.rb",
|
||||||
"test/vagrant/action/vm/persist_test.rb",
|
"test/vagrant/action/vm/persist_test.rb",
|
||||||
"test/vagrant/action/vm/provision_test.rb",
|
"test/vagrant/action/vm/provision_test.rb",
|
||||||
"test/vagrant/action/vm/resume_test.rb",
|
"test/vagrant/action/vm/resume_test.rb",
|
||||||
|
@ -237,11 +241,13 @@ Gem::Specification.new do |s|
|
||||||
"test/vagrant/action/vm/customize_test.rb",
|
"test/vagrant/action/vm/customize_test.rb",
|
||||||
"test/vagrant/action/vm/destroy_test.rb",
|
"test/vagrant/action/vm/destroy_test.rb",
|
||||||
"test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb",
|
"test/vagrant/action/vm/destroy_unused_network_interfaces_test.rb",
|
||||||
|
"test/vagrant/action/vm/export_test.rb",
|
||||||
"test/vagrant/action/vm/forward_ports_test.rb",
|
"test/vagrant/action/vm/forward_ports_test.rb",
|
||||||
"test/vagrant/action/vm/halt_test.rb",
|
"test/vagrant/action/vm/halt_test.rb",
|
||||||
"test/vagrant/action/vm/import_test.rb",
|
"test/vagrant/action/vm/import_test.rb",
|
||||||
"test/vagrant/action/vm/match_mac_address_test.rb",
|
"test/vagrant/action/vm/match_mac_address_test.rb",
|
||||||
"test/vagrant/action/vm/network_test.rb",
|
"test/vagrant/action/vm/network_test.rb",
|
||||||
|
"test/vagrant/action/vm/package_test.rb",
|
||||||
"test/vagrant/action/vm/persist_test.rb",
|
"test/vagrant/action/vm/persist_test.rb",
|
||||||
"test/vagrant/action/vm/provision_test.rb",
|
"test/vagrant/action/vm/provision_test.rb",
|
||||||
"test/vagrant/action/vm/resume_test.rb",
|
"test/vagrant/action/vm/resume_test.rb",
|
||||||
|
|
Loading…
Reference in New Issue