Added before/after callbacks around import to stabilize persisting of VM UUID.
This commit is contained in:
parent
11f4876b9d
commit
6a79c4268b
|
@ -2,8 +2,12 @@ module Vagrant
|
|||
module Actions
|
||||
class Import < Base
|
||||
def execute!
|
||||
@vm.invoke_callback(:before_import)
|
||||
|
||||
logger.info "Importing base VM (#{Vagrant.config[:vm][:base]})..."
|
||||
@vm.vm = VirtualBox::VM.import(File.expand_path(Vagrant.config[:vm][:base]))
|
||||
|
||||
@vm.invoke_callback(:after_import)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,7 @@ module Vagrant
|
|||
["vagrant-root", Env.root_path, Vagrant.config.vm.project_directory]
|
||||
end
|
||||
|
||||
def before_boot
|
||||
def after_import
|
||||
persist
|
||||
setup_mac_address
|
||||
end
|
||||
|
|
|
@ -60,6 +60,7 @@ class Test::Unit::TestCase
|
|||
@mock_vm = mock("vm")
|
||||
@mock_vm.stubs(:vm).returns(@vm)
|
||||
@mock_vm.stubs(:vm=)
|
||||
@mock_vm.stubs(:invoke_callback)
|
||||
@action = action_klass.new(@mock_vm)
|
||||
|
||||
[@mock_vm, @vm, @action]
|
||||
|
|
|
@ -7,6 +7,14 @@ class ImportActionTest < Test::Unit::TestCase
|
|||
VirtualBox::VM.stubs(:import)
|
||||
end
|
||||
|
||||
should "invoke before/after callbacks around the import" do
|
||||
callback_seq = sequence("callback_seq")
|
||||
@mock_vm.expects(:invoke_callback).with(:before_import).once.in_sequence(callback_seq)
|
||||
VirtualBox::VM.expects(:import).once.in_sequence(callback_seq)
|
||||
@mock_vm.expects(:invoke_callback).with(:after_import).once.in_sequence(callback_seq)
|
||||
@import.execute!
|
||||
end
|
||||
|
||||
should "call import on VirtualBox::VM with the proper base" do
|
||||
VirtualBox::VM.expects(:import).once
|
||||
@import.execute!
|
||||
|
|
|
@ -7,11 +7,11 @@ class UpActionTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
context "callbacks" do
|
||||
should "call persist and mac address setup before boot" do
|
||||
should "call persist and mac address setup after import" do
|
||||
boot_seq = sequence("boot")
|
||||
@action.expects(:persist).once.in_sequence(boot_seq)
|
||||
@action.expects(:setup_mac_address).once.in_sequence(boot_seq)
|
||||
@action.before_boot
|
||||
@action.after_import
|
||||
end
|
||||
|
||||
should "setup the root directory shared folder" do
|
||||
|
|
Loading…
Reference in New Issue