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.
|
# be immutable.
|
||||||
class Container
|
class Container
|
||||||
attr_reader :global
|
attr_reader :global
|
||||||
|
attr_reader :vms
|
||||||
|
|
||||||
# Initializes the configuration container.
|
# Initializes the configuration container.
|
||||||
#
|
#
|
||||||
|
@ -16,10 +17,12 @@ module Vagrant
|
||||||
# @param [Array] vms Array of VM configurations.
|
# @param [Array] vms Array of VM configurations.
|
||||||
def initialize(global, vms)
|
def initialize(global, vms)
|
||||||
@global = global
|
@global = global
|
||||||
@vms = {}
|
@vms = []
|
||||||
|
@vm_configs = {}
|
||||||
|
|
||||||
vms.each do |vm_config|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -27,7 +30,7 @@ module Vagrant
|
||||||
# The values for this configuration are usually pertinent to a
|
# The values for this configuration are usually pertinent to a
|
||||||
# single virtual machine and do not affect the system globally.
|
# single virtual machine and do not affect the system globally.
|
||||||
def for_vm(name)
|
def for_vm(name)
|
||||||
@vms[name]
|
@vm_configs[name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -484,15 +484,16 @@ module Vagrant
|
||||||
|
|
||||||
# Load the VM UUIDs from the local data store
|
# Load the VM UUIDs from the local data store
|
||||||
(local_data[:active] || {}).each do |name, uuid|
|
(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
|
end
|
||||||
|
|
||||||
# For any VMs which aren't created, create a blank VM instance for
|
# For any VMs which aren't created, create a blank VM instance for them.
|
||||||
# them
|
config.vms.each do |name|
|
||||||
all_keys = config.vm.defined_vm_keys
|
result[name] = Vagrant::VM.new(name, self, config.for_vm(name)) if !result.has_key?(name)
|
||||||
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)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
|
|
|
@ -7,42 +7,18 @@ module Vagrant
|
||||||
attr_reader :env
|
attr_reader :env
|
||||||
attr_reader :name
|
attr_reader :name
|
||||||
attr_reader :vm
|
attr_reader :vm
|
||||||
|
attr_reader :config
|
||||||
|
|
||||||
class << self
|
def initialize(name, env, config, vm=nil)
|
||||||
# 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]
|
|
||||||
@logger = Log4r::Logger.new("vagrant::vm")
|
@logger = Log4r::Logger.new("vagrant::vm")
|
||||||
|
|
||||||
if !opts[:env].nil?
|
@name = name
|
||||||
# We have an environment, so we create a new child environment
|
@vm = vm
|
||||||
# specifically for this VM. This step will load any custom
|
@env = env
|
||||||
# config and such.
|
@config = config
|
||||||
@env = Vagrant::Environment.new({
|
|
||||||
:cwd => opts[:env].cwd,
|
|
||||||
:parent => opts[:env],
|
|
||||||
:vm => self
|
|
||||||
}).load!
|
|
||||||
|
|
||||||
# Load the associated system.
|
# Load the associated system.
|
||||||
load_system!
|
load_system!
|
||||||
end
|
|
||||||
|
|
||||||
@loaded_system_distro = false
|
@loaded_system_distro = false
|
||||||
end
|
end
|
||||||
|
@ -53,7 +29,7 @@ module Vagrant
|
||||||
#
|
#
|
||||||
# **This method should never be called manually.**
|
# **This method should never be called manually.**
|
||||||
def load_system!(system=nil)
|
def load_system!(system=nil)
|
||||||
system ||= env.config.vm.system
|
system ||= config.vm.system
|
||||||
@logger.info("Loading system: #{system}")
|
@logger.info("Loading system: #{system}")
|
||||||
|
|
||||||
if system.is_a?(Class)
|
if system.is_a?(Class)
|
||||||
|
|
Loading…
Reference in New Issue