diff --git a/lib/vagrant/environment.rb b/lib/vagrant/environment.rb index 7a151502f..45518817e 100644 --- a/lib/vagrant/environment.rb +++ b/lib/vagrant/environment.rb @@ -418,20 +418,9 @@ module Vagrant def load_vms! result = {} - # Load the VM UUIDs from the local data store - (local_data[:active] || {}).each do |name, uuid| - vm = VirtualBox::VM.find(uuid) - result[name.to_sym] = Vagrant::VM.new(name.to_sym, - self, - config.for_vm(name.to_sym), - vm) - end - - # For any VMs which aren't created, create a blank VM instance for them. + # Load all the virtual machine instances. config.vms.each do |name| - if !result.has_key?(name) - result[name] = Vagrant::VM.new(name, self, config.for_vm(name)) - end + result[name] = Vagrant::VM.new(name, self, config.for_vm(name)) end result diff --git a/lib/vagrant/vm.rb b/lib/vagrant/vm.rb index 74a1b30d9..0f366510f 100644 --- a/lib/vagrant/vm.rb +++ b/lib/vagrant/vm.rb @@ -11,16 +11,20 @@ module Vagrant attr_reader :config attr_reader :driver - def initialize(name, env, config, vm=nil) + def initialize(name, env, config) @logger = Log4r::Logger.new("vagrant::vm") @name = name - @vm = vm + @vm = nil @env = env @config = config @box = env.boxes.find(config.vm.box) @driver = Driver::VirtualBox.new + # Look for the VM if it exists + active = env.local_data[:active] || {} + @vm = VirtualBox::VM.find(active[@name.to_s]) if active[@name.to_s] + # Load the associated guest. load_guest! @loaded_guest_distro = false