Module: Vagrant

Defined in:
lib/vagrant/errors.rb,
lib/vagrant.rb,
lib/vagrant/ui.rb,
lib/vagrant/box.rb,
lib/vagrant/cli.rb,
lib/vagrant/easy.rb,
lib/vagrant/util.rb,
lib/vagrant/hosts.rb,
lib/vagrant/config.rb,
lib/vagrant/plugin.rb,
lib/vagrant/action.rb,
lib/vagrant/version.rb,
lib/vagrant/machine.rb,
lib/vagrant/registry.rb,
lib/vagrant/util/ssh.rb,
lib/vagrant/plugin/v2.rb,
lib/vagrant/plugin/v1.rb,
lib/vagrant/config/v2.rb,
lib/vagrant/config/v1.rb,
lib/vagrant/util/busy.rb,
lib/vagrant/downloaders.rb,
lib/vagrant/environment.rb,
lib/vagrant/util/counter.rb,
lib/vagrant/test_helpers.rb,
lib/vagrant/action/runner.rb,
lib/vagrant/util/platform.rb,
lib/vagrant/config/loader.rb,
lib/vagrant/action/warden.rb,
lib/vagrant/config/v1/root.rb,
lib/vagrant/plugin/v1/host.rb,
lib/vagrant/config/v2/root.rb,
lib/vagrant/box_collection.rb,
lib/vagrant/action/builder.rb,
lib/vagrant/util/retryable.rb,
lib/vagrant/util/file_mode.rb,
lib/vagrant/plugin/v2/host.rb,
lib/vagrant/util/safe_exec.rb,
lib/vagrant/util/safe_puts.rb,
lib/vagrant/plugin/v1/guest.rb,
lib/vagrant/util/subprocess.rb,
lib/vagrant/plugin/v2/guest.rb,
lib/vagrant/easy/operations.rb,
lib/vagrant/util/network_ip.rb,
lib/vagrant/easy/command_api.rb,
lib/vagrant/plugin/v2/config.rb,
lib/vagrant/config/v1/loader.rb,
lib/vagrant/config/v2/loader.rb,
lib/vagrant/plugin/v2/errors.rb,
lib/vagrant/plugin/v1/plugin.rb,
lib/vagrant/config/container.rb,
lib/vagrant/plugin/v2/plugin.rb,
lib/vagrant/plugin/v1/config.rb,
lib/vagrant/downloaders/base.rb,
lib/vagrant/downloaders/http.rb,
lib/vagrant/downloaders/file.rb,
lib/vagrant/plugin/v1/errors.rb,
lib/vagrant/easy/command_base.rb,
lib/vagrant/util/is_port_open.rb,
lib/vagrant/plugin/v2/command.rb,
lib/vagrant/plugin/v2/manager.rb,
lib/vagrant/plugin/v1/command.rb,
lib/vagrant/plugin/v1/manager.rb,
lib/vagrant/plugin/v1/provider.rb,
lib/vagrant/action/environment.rb,
lib/vagrant/plugin/v2/provider.rb,
lib/vagrant/action/builtin/call.rb,
lib/vagrant/config/version_base.rb,
lib/vagrant/plugin/v2/components.rb,
lib/vagrant/plugin/v2/provisioner.rb,
lib/vagrant/config/error_recorder.rb,
lib/vagrant/plugin/v1/provisioner.rb,
lib/vagrant/plugin/v2/communicator.rb,
lib/vagrant/action/builtin/ssh_run.rb,
lib/vagrant/action/general/package.rb,
lib/vagrant/action/builtin/box_add.rb,
lib/vagrant/action/builtin/env_set.rb,
lib/vagrant/action/builtin/confirm.rb,
lib/vagrant/util/template_renderer.rb,
lib/vagrant/plugin/v1/communicator.rb,
lib/vagrant/action/general/validate.rb,
lib/vagrant/action/builtin/ssh_exec.rb,
lib/vagrant/util/stacked_proc_runner.rb,
lib/vagrant/action/builtin/provision.rb,
lib/vagrant/util/line_ending_helpers.rb,
lib/vagrant/util/scoped_hash_override.rb,
lib/vagrant/util/ansi_escape_code_remover.rb,
lib/vagrant/util/hash_with_indifferent_access.rb

Overview

This file contains all the errors that the V1 plugin interface may throw.

Defined Under Namespace

Modules: Action, Config, Downloaders, Easy, Errors, Hosts, Plugin, TestHelpers, UI, Util Classes: Box, BoxCollection, CLI, Environment, Machine, Registry

Constant Summary

PLUGIN_COMPONENTS =

These are the various plugin versions and their components in a lazy loaded Hash-like structure.

Registry.new.tap do |c|
  c.register(:1")                  { Plugin::V1::Plugin }
  c.register([:1", :command])      { Plugin::V1::Command }
  c.register([:1", :communicator]) { Plugin::V1::Communicator }
  c.register([:1", :config])       { Plugin::V1::Config }
  c.register([:1", :guest])        { Plugin::V1::Guest }
  c.register([:1", :host])         { Plugin::V1::Host }
  c.register([:1", :provider])     { Plugin::V1::Provider }
  c.register([:1", :provisioner])  { Plugin::V1::Provisioner }

  c.register(:2")                  { Plugin::V2::Plugin }
  c.register([:2", :command])      { Plugin::V2::Command }
  c.register([:2", :communicator]) { Plugin::V2::Communicator }
  c.register([:2", :config])       { Plugin::V2::Config }
  c.register([:2", :guest])        { Plugin::V2::Guest }
  c.register([:2", :host])         { Plugin::V2::Host }
  c.register([:2", :provider])     { Plugin::V2::Provider }
  c.register([:2", :provisioner])  { Plugin::V2::Provisioner }
end
VERSION =

This will always be up to date with the current version of Vagrant, since it is used to generate the gemspec and is also the source of the version for vagrant -v

"1.1.0.dev"

Class Method Summary (collapse)

Class Method Details

+ (Object) configure(version, &block)

Configure a Vagrant environment. The version specifies the version of the configuration that is expected by the block. The block, based on that version, configures the environment.

Note that the block isn't run immediately. Instead, the configuration block is stored until later, and is run when an environment is loaded.

Parameters:

  • version (String)

    Version of the configuration



119
120
121
# File 'lib/vagrant.rb', line 119

def self.configure(version, &block)
  Config.run(version, &block)
end

+ (Class) plugin(version, component = nil)

Returns a superclass to use when creating a plugin for Vagrant. Given a specific version, this returns a proper superclass to use to register plugins for that version.

Optionally, if you give a specific component, then it will return the proper superclass for that component as well.

Plugins and plugin components should subclass the classes returned by this method. This method lets Vagrant core control these superclasses and change them over time without affecting plugins. For example, if the V1 superclass happens to be "Vagrant::V1," future versions of Vagrant may move it to "Vagrant::Plugins::V1" and plugins will not be affected.

Returns:

  • (Class)

Raises:

  • (ArgumentError)


138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/vagrant.rb', line 138

def self.plugin(version, component=nil)
  # Build up the key and return a result
  key    = version.to_sym
  key    = [key, component.to_sym] if component
  result = PLUGIN_COMPONENTS.get(key)

  # If we found our component then we return that
  return result if result

  # If we didn't find a result, then raise an exception, depending
  # on if we got a component or not.
  raise ArgumentError, "Plugin superclass not found for version/component: " +
    "#{version} #{component}"
end

+ (Object) require_plugin(name)

This should be used instead of Ruby's built-in require in order to load a Vagrant plugin. This will load the given plugin by first doing a normal require, giving a nice error message if things go wrong, and second by verifying that a Vagrant plugin was actually defined in the process.

Parameters:

  • name (String)

    Name of the plugin to load.



160
161
162
163
164
165
166
167
# File 'lib/vagrant.rb', line 160

def self.require_plugin(name)
  # Attempt the normal require
  begin
    require name
  rescue LoadError
    raise Errors::PluginLoadError, :plugin => name
  end
end

+ (Object) source_root

The source root is the path to the root directory of the Vagrant gem.



107
108
109
# File 'lib/vagrant.rb', line 107

def self.source_root
  @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
end