Load VirtualBox VM in the VM class
This commit is contained in:
parent
9debf5abe9
commit
2de7a1424d
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue