From 526603dbbf653fd29eadabedec33e45a1006ba12 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 29 Dec 2012 18:34:11 -1000 Subject: [PATCH] Lots more logging in with_target_vms --- lib/vagrant/plugin/v2/command.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/vagrant/plugin/v2/command.rb b/lib/vagrant/plugin/v2/command.rb index 509073056..34c7af1bc 100644 --- a/lib/vagrant/plugin/v2/command.rb +++ b/lib/vagrant/plugin/v2/command.rb @@ -70,6 +70,10 @@ module Vagrant # @option options [Boolean] :single_target If true, then an # exception will be raised if more than one target is found. def with_target_vms(names=nil, options=nil) + @logger.debug("Getting target VMs for command. Arguments:") + @logger.debug(" -- names: #{names.inspect}") + @logger.debug(" -- options: #{options.inspect}") + # Using VMs requires a Vagrant environment to be properly setup raise Errors::NoEnvironmentError if !@env.root_path @@ -88,6 +92,8 @@ module Vagrant if names.length > 0 names.each do |name| if pattern = name[/^\/(.+?)\/$/, 1] + @logger.debug("Finding machines that match regex: #{pattern}") + # This is a regular expression name, so we convert to a regular # expression and allow that sort of matching. regex = Regexp.new(pattern) @@ -101,6 +107,7 @@ module Vagrant raise Errors::VMNoMatchError if machines.empty? else # String name, just look for a specific VM + @logger.debug("Finding machine that match name: #{name}") machines << @env.machine(name.to_sym, provider) raise Errors::VMNotFoundError, :name => name if !machines[0] end @@ -108,6 +115,7 @@ module Vagrant else # No name was given, so we return every VM in the order # configured. + @logger.debug("Loading all machines...") machines = @env.machine_names.map do |machine_name| @env.machine(machine_name, provider) end @@ -115,6 +123,7 @@ module Vagrant # Make sure we're only working with one VM if single target if options[:single_target] && machines.length != 1 + @logger.debug("Using primary machine since single target") primary = @env.primary_machine(provider) raise Errors::MultiVMTargetRequired if !primary machines = [primary] @@ -125,6 +134,7 @@ module Vagrant # Go through each VM and yield it! machines.each do |machine| + @logger.info("With machine: #{machine.name} (#{machine.provider.inspect})") yield machine end end