Initial up action. Not hooked up yet to the vagrant-up bin though
This commit is contained in:
parent
1753d97d45
commit
9438b3b01e
|
@ -0,0 +1,36 @@
|
||||||
|
module Vagrant
|
||||||
|
module Actions
|
||||||
|
class Up < Base
|
||||||
|
def prepare
|
||||||
|
# Up is a "meta-action" so it really just queues up a bunch
|
||||||
|
# of other actions in its place:
|
||||||
|
[Import, ForwardPorts, SharedFolders, Start].each do |action_klass|
|
||||||
|
@vm.actions << action_klass
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: Move hard drive
|
||||||
|
end
|
||||||
|
|
||||||
|
def collect_shared_folders
|
||||||
|
# The root shared folder for the project
|
||||||
|
["vagrant-root", Env.root_path, Vagrant.config.vm.project_directory]
|
||||||
|
end
|
||||||
|
|
||||||
|
def before_boot
|
||||||
|
persist
|
||||||
|
setup_mac_address
|
||||||
|
end
|
||||||
|
|
||||||
|
def persist
|
||||||
|
logger.info "Persisting the VM UUID (#{@vm.vm.uuid})..."
|
||||||
|
Env.persist_vm(@vm.vm)
|
||||||
|
end
|
||||||
|
|
||||||
|
def setup_mac_address
|
||||||
|
logger.info "Matching MAC addresses..."
|
||||||
|
@vm.vm.nics.first.macaddress = Vagrant.config[:vm][:base_mac]
|
||||||
|
@vm.vm.save(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,42 @@
|
||||||
|
require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
|
||||||
|
|
||||||
|
class UpActionTest < Test::Unit::TestCase
|
||||||
|
setup do
|
||||||
|
@mock_vm, @vm, @import = mock_action(Vagrant::Actions::Up)
|
||||||
|
mock_config
|
||||||
|
end
|
||||||
|
|
||||||
|
context "callbacks" do
|
||||||
|
should "call persist and mac address setup before boot" 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
|
||||||
|
end
|
||||||
|
|
||||||
|
should "setup the root directory shared folder" do
|
||||||
|
expected = ["vagrant-root", Vagrant::Env.root_path, Vagrant.config.vm.project_directory]
|
||||||
|
assert_equal expected, @action.collect_shared_folders
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "persisting" do
|
||||||
|
should "persist the VM with Env" do
|
||||||
|
@vm.stubs(:uuid)
|
||||||
|
Vagrant::Env.expects(:persist_vm).with(@vm).once
|
||||||
|
@action.persist
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "setting up MAC address" do
|
||||||
|
should "match the mac address with the base" do
|
||||||
|
nic = mock("nic")
|
||||||
|
nic.expects(:macaddress=).once
|
||||||
|
|
||||||
|
@vm.expects(:nics).returns([nic]).once
|
||||||
|
@vm.expects(:save).with(true).once
|
||||||
|
|
||||||
|
@action.setup_mac_address
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue