Lots more logging in with_target_vms
This commit is contained in:
parent
9257fe3d98
commit
526603dbbf
|
@ -70,6 +70,10 @@ module Vagrant
|
||||||
# @option options [Boolean] :single_target If true, then an
|
# @option options [Boolean] :single_target If true, then an
|
||||||
# exception will be raised if more than one target is found.
|
# exception will be raised if more than one target is found.
|
||||||
def with_target_vms(names=nil, options=nil)
|
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
|
# Using VMs requires a Vagrant environment to be properly setup
|
||||||
raise Errors::NoEnvironmentError if !@env.root_path
|
raise Errors::NoEnvironmentError if !@env.root_path
|
||||||
|
|
||||||
|
@ -88,6 +92,8 @@ module Vagrant
|
||||||
if names.length > 0
|
if names.length > 0
|
||||||
names.each do |name|
|
names.each do |name|
|
||||||
if pattern = name[/^\/(.+?)\/$/, 1]
|
if pattern = name[/^\/(.+?)\/$/, 1]
|
||||||
|
@logger.debug("Finding machines that match regex: #{pattern}")
|
||||||
|
|
||||||
# This is a regular expression name, so we convert to a regular
|
# This is a regular expression name, so we convert to a regular
|
||||||
# expression and allow that sort of matching.
|
# expression and allow that sort of matching.
|
||||||
regex = Regexp.new(pattern)
|
regex = Regexp.new(pattern)
|
||||||
|
@ -101,6 +107,7 @@ module Vagrant
|
||||||
raise Errors::VMNoMatchError if machines.empty?
|
raise Errors::VMNoMatchError if machines.empty?
|
||||||
else
|
else
|
||||||
# String name, just look for a specific VM
|
# String name, just look for a specific VM
|
||||||
|
@logger.debug("Finding machine that match name: #{name}")
|
||||||
machines << @env.machine(name.to_sym, provider)
|
machines << @env.machine(name.to_sym, provider)
|
||||||
raise Errors::VMNotFoundError, :name => name if !machines[0]
|
raise Errors::VMNotFoundError, :name => name if !machines[0]
|
||||||
end
|
end
|
||||||
|
@ -108,6 +115,7 @@ module Vagrant
|
||||||
else
|
else
|
||||||
# No name was given, so we return every VM in the order
|
# No name was given, so we return every VM in the order
|
||||||
# configured.
|
# configured.
|
||||||
|
@logger.debug("Loading all machines...")
|
||||||
machines = @env.machine_names.map do |machine_name|
|
machines = @env.machine_names.map do |machine_name|
|
||||||
@env.machine(machine_name, provider)
|
@env.machine(machine_name, provider)
|
||||||
end
|
end
|
||||||
|
@ -115,6 +123,7 @@ module Vagrant
|
||||||
|
|
||||||
# Make sure we're only working with one VM if single target
|
# Make sure we're only working with one VM if single target
|
||||||
if options[:single_target] && machines.length != 1
|
if options[:single_target] && machines.length != 1
|
||||||
|
@logger.debug("Using primary machine since single target")
|
||||||
primary = @env.primary_machine(provider)
|
primary = @env.primary_machine(provider)
|
||||||
raise Errors::MultiVMTargetRequired if !primary
|
raise Errors::MultiVMTargetRequired if !primary
|
||||||
machines = [primary]
|
machines = [primary]
|
||||||
|
@ -125,6 +134,7 @@ module Vagrant
|
||||||
|
|
||||||
# Go through each VM and yield it!
|
# Go through each VM and yield it!
|
||||||
machines.each do |machine|
|
machines.each do |machine|
|
||||||
|
@logger.info("With machine: #{machine.name} (#{machine.provider.inspect})")
|
||||||
yield machine
|
yield machine
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue