diff --git a/lib/vagrant/config/vm.rb b/lib/vagrant/config/vm.rb index 8a4b9e249..4b9d5174b 100644 --- a/lib/vagrant/config/vm.rb +++ b/lib/vagrant/config/vm.rb @@ -1,3 +1,5 @@ +require 'vagrant/config/vm/sub_vm' + module Vagrant class Config class VMConfig < Base @@ -21,16 +23,6 @@ module Vagrant attr_writer :shared_folder_gid attr_accessor :system - # Represents a SubVM. This class is only used here in the VMs - # hash. - class SubVM - include Util::StackedProcRunner - - def options - @options ||= {} - end - end - def initialize @forwarded_ports = {} @shared_folders = {} @@ -95,11 +87,17 @@ module Vagrant end def define(name, options=nil, &block) + name = name.to_sym options ||= {} + + # Add the name to the array of VM keys. This array is used to + # preserve the order in which VMs are defined. defined_vm_keys << name - defined_vms[name.to_sym] ||= SubVM.new - defined_vms[name.to_sym].options.merge!(options) - defined_vms[name.to_sym].push_proc(&block) + + # Add the SubVM to the hash of defined VMs + defined_vms[name] ||= SubVM.new + defined_vms[name].options.merge!(options) + defined_vms[name].push_proc(&block) end def validate(errors) diff --git a/lib/vagrant/config/vm/sub_vm.rb b/lib/vagrant/config/vm/sub_vm.rb new file mode 100644 index 000000000..413a6986e --- /dev/null +++ b/lib/vagrant/config/vm/sub_vm.rb @@ -0,0 +1,17 @@ +module Vagrant + class Config + class VMConfig < Base + # Represents a single sub-VM in a multi-VM environment. + class SubVM + include Util::StackedProcRunner + + attr_reader :options + + def initialize + @options = {} + end + end + end + end +end +