lib/vagrant/environment.rb in vagrant-0.6.8 vs lib/vagrant/environment.rb in vagrant-0.6.9
- old
+ new
@@ -29,13 +29,21 @@
class << self
# Verifies that VirtualBox is installed and that the version of
# VirtualBox installed is high enough.
def check_virtualbox!
version = VirtualBox.version
- raise Errors::VirtualBoxNotDetected.new if version.nil?
- raise Errors::VirtualBoxInvalidVersion.new(:version => version.to_s) if version.to_f < 3.2
- raise Errors::VirtualBoxInvalidOSE.new(:version => version.to_s) if version.to_s.downcase.include?("ose")
+ raise Errors::VirtualBoxNotDetected if version.nil?
+ raise Errors::VirtualBoxInvalidVersion, :version => version.to_s if version.to_f < 3.2
+ raise Errors::VirtualBoxInvalidOSE, :version => version.to_s if version.to_s.downcase.include?("ose")
+ rescue Errors::VirtualBoxNotDetected
+ # On 64-bit Windows, show a special error. This error is a subclass
+ # of VirtualBoxNotDetected, so libraries which use Vagrant can just
+ # rescue VirtualBoxNotDetected.
+ raise Errors::VirtualBoxNotDetected_Win64 if Util::Platform.windows? && Util::Platform.bit64?
+
+ # Otherwise, reraise the old error
+ raise
end
end
# Initializes a new environment with the given options. The options
# is a hash where the main available key is `cwd`, which defines where
@@ -124,17 +132,25 @@
boxes.find(config.vm.box)
end
# Returns the VMs associated with this environment.
#
- # @return [Array<VM>]
+ # @return [Hash<Symbol,VM>]
def vms
return parent.vms if parent
load! if !loaded?
@vms ||= load_vms!
end
+ # Returns the VMs associated with this environment, in the order
+ # that they were defined.
+ #
+ # @return [Array<VM>]
+ def vms_ordered
+ @vms_enum ||= config.vm.defined_vm_keys.map {|name| @vms[name]}
+ end
+
# Returns the primary VM associated with this environment. This
# method is only applicable for multi-VM environments. This can
# potentially be nil if no primary VM is specified.
#
# @return [VM]
@@ -350,10 +366,10 @@
result[name.to_sym] = Vagrant::VM.find(uuid, self, name.to_sym)
end
# For any VMs which aren't created, create a blank VM instance for
# them
- all_keys = config.vm.defined_vms.keys
+ 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)
end