Merge pull request #2794 from tmatilai/cabability_host_name

core: reintroduce `name` attribute for the `Guest`
This commit is contained in:
Mitchell Hashimoto 2014-01-09 09:07:30 -08:00
commit 013a9ae779
2 changed files with 10 additions and 5 deletions

View File

@ -25,7 +25,8 @@ module Vagrant
# is a hash where the key is the name of the capability and the value
# is the class/module implementing it.
def initialize_capabilities!(host, hosts, capabilities, *args)
@cap_logger = Log4r::Logger.new("vagrant::capability_host::#{self.class}")
@cap_logger = Log4r::Logger.new(
"vagrant::capability_host::#{self.class.to_s.downcase}")
if host && !hosts[host]
raise Errors::CapabilityHostExplicitNotDetected, value: host.to_s
@ -113,7 +114,7 @@ module Vagrant
protected
def autodetect_capability_host(hosts, *args)
@cap_logger.info("Autodetecting guest for machine: #{@machine}")
@cap_logger.info("Autodetecting host type for #{args.inspect}")
# Get the mapping of hosts with the most parents. We start searching
# with the hosts with the most parents first.

View File

@ -22,7 +22,6 @@ module Vagrant
include CapabilityHost
def initialize(machine, guests, capabilities)
@logger = Log4r::Logger.new("vagrant::guest")
@capabilities = capabilities
@guests = guests
@machine = machine
@ -31,8 +30,6 @@ module Vagrant
# This will detect the proper guest OS for the machine and set up
# the class to actually execute capabilities.
def detect!
@logger.info("Detect guest for machine: #{@machine}")
guest_name = @machine.config.vm.guest
initialize_capabilities!(guest_name, @guests, @capabilities, @machine)
end
@ -45,5 +42,12 @@ module Vagrant
def ready?
!!capability_host_chain
end
# Returns the specified or detected guest type name
#
# @return [Symbol]
def name
capability_host_chain[0][0]
end
end
end