class Vagrant::Plugin::V2::Manager

This class maintains a list of all the registered plugins as well as provides methods that allow querying all registered components of those plugins as a single unit.

Attributes

registered[R]

Public Class Methods

new() click to toggle source
# File lib/vagrant/plugin/v2/manager.rb, line 12
def initialize
  @logger = Log4r::Logger.new("vagrant::plugin::v2::manager")
  @registered = []
end

Public Instance Methods

action_hooks(hook_name) click to toggle source

This returns all the action hooks.

@return [Array]

# File lib/vagrant/plugin/v2/manager.rb, line 20
def action_hooks(hook_name)
  result = []

  @registered.each do |plugin|
    result += plugin.components.action_hooks[Plugin::ALL_ACTIONS]
    result += plugin.components.action_hooks[hook_name]
  end

  result
end
commands() click to toggle source

This returns all the registered commands.

@return [Registry<Symbol, Array<Proc, Hash>>]

# File lib/vagrant/plugin/v2/manager.rb, line 34
def commands
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.components.commands)
    end
  end
end
communicators() click to toggle source

This returns all the registered communicators.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 45
def communicators
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.communicator)
    end
  end
end
config() click to toggle source

This returns all the registered configuration classes.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 56
def config
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.components.configs[:top])
    end
  end
end
guest_capabilities() click to toggle source

This returns all the registered guest capabilities.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 78
def guest_capabilities
  results = Hash.new { |h, k| h[k] = Registry.new }

  @registered.each do |plugin|
    plugin.components.guest_capabilities.each do |guest, caps|
      results[guest].merge!(caps)
    end
  end

  results
end
guests() click to toggle source

This returns all the registered guests.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 67
def guests
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.components.guests)
    end
  end
end
host_capabilities() click to toggle source

This returns all the registered host capabilities.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 104
def host_capabilities
  results = Hash.new { |h, k| h[k] = Registry.new }

  @registered.each do |plugin|
    plugin.components.host_capabilities.each do |host, caps|
      results[host].merge!(caps)
    end
  end

  results
end
hosts() click to toggle source

This returns all the registered guests.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 93
def hosts
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.components.hosts)
    end
  end
end
provider_capabilities() click to toggle source

This returns all the registered provider capabilities.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 130
def provider_capabilities
  results = Hash.new { |h, k| h[k] = Registry.new }

  @registered.each do |plugin|
    plugin.components.provider_capabilities.each do |provider, caps|
      results[provider].merge!(caps)
    end
  end

  results
end
provider_configs() click to toggle source

This returns all the config classes for the various providers.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 145
def provider_configs
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.components.configs[:provider])
    end
  end
end
providers() click to toggle source

This returns all registered providers.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 119
def providers
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.components.providers)
    end
  end
end
provisioner_configs() click to toggle source

This returns all the config classes for the various provisioners.

@return [Registry]

# File lib/vagrant/plugin/v2/manager.rb, line 156
def provisioner_configs
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.components.configs[:provisioner])
    end
  end
end
provisioners() click to toggle source

This returns all registered provisioners.

@return [Hash]

# File lib/vagrant/plugin/v2/manager.rb, line 167
def provisioners
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.provisioner)
    end
  end
end
register(plugin) click to toggle source

This registers a plugin. This should NEVER be called by the public and should only be called from within Vagrant. Vagrant will automatically register V2 plugins when a name is set on the plugin.

# File lib/vagrant/plugin/v2/manager.rb, line 190
def register(plugin)
  if !@registered.include?(plugin)
    @logger.info("Registered plugin: #{plugin.name}")
    @registered << plugin
  end
end
reset!() click to toggle source

This clears out all the registered plugins. This is only used by unit tests and should not be called directly.

# File lib/vagrant/plugin/v2/manager.rb, line 199
def reset!
  @registered.clear
end
synced_folders() click to toggle source

This returns all synced folder implementations.

@return [Registry]

# File lib/vagrant/plugin/v2/manager.rb, line 178
def synced_folders
  Registry.new.tap do |result|
    @registered.each do |plugin|
      result.merge!(plugin.components.synced_folders)
    end
  end
end
unregister(plugin) click to toggle source

This unregisters a plugin so that its components will no longer be used. Note that this should only be used for testing purposes.

# File lib/vagrant/plugin/v2/manager.rb, line 205
def unregister(plugin)
  if @registered.include?(plugin)
    @logger.info("Unregistered: #{plugin.name}")
    @registered.delete(plugin)
  end
end