load_vms. Broke so many things.
I've changed Vagrant::VM to be slightly more in line with what I imagined. However, doing this change has definitely broken _everything_. We now slowly must cobble back together based on this new API.
This commit is contained in:
parent
1921ce17e8
commit
b61d9a6d3d
|
@ -8,6 +8,7 @@ module Vagrant
|
|||
# be immutable.
|
||||
class Container
|
||||
attr_reader :global
|
||||
attr_reader :vms
|
||||
|
||||
# Initializes the configuration container.
|
||||
#
|
||||
|
@ -16,10 +17,12 @@ module Vagrant
|
|||
# @param [Array] vms Array of VM configurations.
|
||||
def initialize(global, vms)
|
||||
@global = global
|
||||
@vms = {}
|
||||
@vms = []
|
||||
@vm_configs = {}
|
||||
|
||||
vms.each do |vm_config|
|
||||
@vms[vm_config.vm.name] = vm_config
|
||||
@vms << vm_config.vm.name
|
||||
@vm_configs[vm_config.vm.name] = vm_config
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -27,7 +30,7 @@ module Vagrant
|
|||
# The values for this configuration are usually pertinent to a
|
||||
# single virtual machine and do not affect the system globally.
|
||||
def for_vm(name)
|
||||
@vms[name]
|
||||
@vm_configs[name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -484,15 +484,16 @@ module Vagrant
|
|||
|
||||
# Load the VM UUIDs from the local data store
|
||||
(local_data[:active] || {}).each do |name, uuid|
|
||||
result[name.to_sym] = Vagrant::VM.find(uuid, self, name.to_sym)
|
||||
vm = VirtualBox::VM.find(uuid)
|
||||
result[name.to_sym] = Vagrant::VM.new(name.to_sym,
|
||||
self,
|
||||
config.for_vm(name.to_s),
|
||||
vm)
|
||||
end
|
||||
|
||||
# For any VMs which aren't created, create a blank VM instance for
|
||||
# them
|
||||
all_keys = config.vm.defined_vm_keys
|
||||
all_keys = [DEFAULT_VM] if all_keys.empty?
|
||||
all_keys.each do |name|
|
||||
result[name] = Vagrant::VM.new(:name => name, :env => self) if !result.has_key?(name)
|
||||
# For any VMs which aren't created, create a blank VM instance for them.
|
||||
config.vms.each do |name|
|
||||
result[name] = Vagrant::VM.new(name, self, config.for_vm(name)) if !result.has_key?(name)
|
||||
end
|
||||
|
||||
result
|
||||
|
|
|
@ -7,42 +7,18 @@ module Vagrant
|
|||
attr_reader :env
|
||||
attr_reader :name
|
||||
attr_reader :vm
|
||||
attr_reader :config
|
||||
|
||||
class << self
|
||||
# Finds a virtual machine by a given UUID and either returns
|
||||
# a Vagrant::VM object or returns nil.
|
||||
def find(uuid, env=nil, name=nil)
|
||||
vm = VirtualBox::VM.find(uuid)
|
||||
new(:vm => vm, :env => env, :name => name)
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(opts=nil)
|
||||
defaults = {
|
||||
:vm => nil,
|
||||
:env => nil,
|
||||
:name => nil
|
||||
}
|
||||
|
||||
opts = defaults.merge(opts || {})
|
||||
|
||||
@vm = opts[:vm]
|
||||
@name = opts[:name]
|
||||
def initialize(name, env, config, vm=nil)
|
||||
@logger = Log4r::Logger.new("vagrant::vm")
|
||||
|
||||
if !opts[:env].nil?
|
||||
# We have an environment, so we create a new child environment
|
||||
# specifically for this VM. This step will load any custom
|
||||
# config and such.
|
||||
@env = Vagrant::Environment.new({
|
||||
:cwd => opts[:env].cwd,
|
||||
:parent => opts[:env],
|
||||
:vm => self
|
||||
}).load!
|
||||
@name = name
|
||||
@vm = vm
|
||||
@env = env
|
||||
@config = config
|
||||
|
||||
# Load the associated system.
|
||||
load_system!
|
||||
end
|
||||
# Load the associated system.
|
||||
load_system!
|
||||
|
||||
@loaded_system_distro = false
|
||||
end
|
||||
|
@ -53,7 +29,7 @@ module Vagrant
|
|||
#
|
||||
# **This method should never be called manually.**
|
||||
def load_system!(system=nil)
|
||||
system ||= env.config.vm.system
|
||||
system ||= config.vm.system
|
||||
@logger.info("Loading system: #{system}")
|
||||
|
||||
if system.is_a?(Class)
|
||||
|
|
Loading…
Reference in New Issue