From c6b0fae318c43a281873c7c5469547e52c81c83b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 8 Oct 2010 10:34:33 -0700 Subject: [PATCH] Load sub-VM configuration on first-pass, allowing box loading for sub-VMs. [closes GH-166] [closes GH-181] --- CHANGELOG.md | 2 ++ lib/vagrant/environment.rb | 2 +- test/vagrant/environment_test.rb | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33d300cbe..fdf067f3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.6.5 (unreleased) + - Properly load sub-VM configuration on first-pass of config loading. Solves + a LOT of problems with multi-VM. [GH-166] [GH-181] - Configuration now only validates on final Vagrantfile proc, so multi-VM validates correctly. - A nice error message is given if ".vagrant" is a directory and therefore diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 687c00fb6..fec905329 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -306,7 +306,7 @@ module Vagrant # If this environment is representing a sub-VM, then we push that # proc on as the last configuration. - if !first_run && vm + if vm subvm = parent.config.vm.defined_vms[vm.name] loader.queue << subvm.proc_stack if subvm end diff --git a/test/vagrant/environment_test.rb b/test/vagrant/environment_test.rb index 9769acd72..9ede33d4e 100644 --- a/test/vagrant/environment_test.rb +++ b/test/vagrant/environment_test.rb @@ -365,7 +365,10 @@ class EnvironmentTest < Test::Unit::TestCase end def create_box_vagrantfile - vagrantfile(vagrant_box("box"), 'config.package.name = "box.box"') + vagrantfile(vagrant_box("box"), <<-FILE) + config.package.name = "box.box" + config.vm.base_mac = "set" + FILE end def create_home_vagrantfile @@ -400,15 +403,18 @@ class EnvironmentTest < Test::Unit::TestCase should "load from a sub-vm configuration if environment represents a VM" do create_home_vagrantfile + create_box_vagrantfile vagrantfile(@env.root_path, <<-vf) config.package.name = "root.box" config.vm.define :web do |web| + web.vm.box = "box" web.package.name = "web.box" end vf assert_equal "root.box", @env.config.package.name assert_equal "web.box", @env.vms[:web].env.config.package.name + assert_equal "set", @env.vms[:web].env.config.vm.base_mac end should "reload the logger after executing" do