From 40b9254d5a939c965f42ca6cd8f59bd974b5c7e5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 10 Dec 2011 16:07:28 -0800 Subject: [PATCH] Environment reloading works --- BRANCH_TODO | 2 -- lib/vagrant/action/vm/check_box.rb | 9 +++------ lib/vagrant/environment.rb | 6 ++++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/BRANCH_TODO b/BRANCH_TODO index d6290448c..b0252d4c3 100644 --- a/BRANCH_TODO +++ b/BRANCH_TODO @@ -1,7 +1,5 @@ This is a TODO file for only this branch (config-overhaul) -* Reloading configuration for VMs (see check_box.rb) - * Only allow one kind of vagrantfile to be loaded (i.e. if both Vagrantfile and vagrantfile exist, throw an error) * Nicer error if can't setup home directory diff --git a/lib/vagrant/action/vm/check_box.rb b/lib/vagrant/action/vm/check_box.rb index 9c6480157..aac2452d1 100644 --- a/lib/vagrant/action/vm/check_box.rb +++ b/lib/vagrant/action/vm/check_box.rb @@ -20,12 +20,9 @@ module Vagrant env[:box_collection].add(box_name, box_url) env[:box_collection].reload! - # Reload the configuration for all our VMs, since this box - # may be used for other VMs. - # TODO: This doesn't work properly - env[:vm].env.vms.each do |name, vm| - vm.env.reload_config! - end + # Reload the environment and set the VM to be the new loaded VM. + env[:vm].env.reload! + env[:vm] = env[:vm].env.vms[env[:vm].name] end @app.call(env) diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 721985738..b08c36f62 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -163,7 +163,7 @@ module Vagrant # # @return [Array] def vms_ordered - @vms_enum ||= config.vm.defined_vm_keys.map { |name| @vms[name] } + @vms_enum ||= config.global.vm.defined_vm_keys.map { |name| @vms[name] } end # Returns the primary VM associated with this environment. This @@ -356,9 +356,11 @@ module Vagrant end # Reloads the configuration of this environment. - def reload_config! + def reload! @config = nil + @vms = nil load_config! + load_vms! self end