2011-12-04 01:12:07 +00:00
|
|
|
# Enable logging if it is requested. We do this before
|
|
|
|
# anything else so that we can setup the output before
|
|
|
|
# any logging occurs.
|
2012-01-07 21:13:17 +00:00
|
|
|
if ENV["VAGRANT_LOG"] && ENV["VAGRANT_LOG"] != ""
|
2012-01-08 04:39:57 +00:00
|
|
|
# Require Log4r and define the levels we'll be using
|
2011-12-04 01:12:07 +00:00
|
|
|
require 'log4r'
|
2012-01-08 04:39:57 +00:00
|
|
|
require 'log4r/config'
|
|
|
|
Log4r.define_levels(*Log4r::Log4rConfig::LogLevels)
|
2012-01-07 21:13:17 +00:00
|
|
|
|
|
|
|
level = nil
|
|
|
|
begin
|
|
|
|
level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
|
|
|
|
rescue NameError
|
|
|
|
# This means that the logging constant wasn't found,
|
|
|
|
# which is fine. We just keep `level` as `nil`. But
|
|
|
|
# we tell the user.
|
2012-01-18 17:40:01 +00:00
|
|
|
level = nil
|
|
|
|
end
|
|
|
|
|
|
|
|
# Some constants, such as "true" resolve to booleans, so the
|
|
|
|
# above error checking doesn't catch it. This will check to make
|
|
|
|
# sure that the log level is an integer, as Log4r requires.
|
|
|
|
level = nil if !level.is_a?(Integer)
|
|
|
|
|
|
|
|
if !level
|
|
|
|
# We directly write to stderr here because the VagrantError system
|
|
|
|
# is not setup yet.
|
2012-01-08 03:23:03 +00:00
|
|
|
$stderr.puts "Invalid VAGRANT_LOG level is set: #{ENV["VAGRANT_LOG"]}"
|
2012-01-18 17:40:01 +00:00
|
|
|
$stderr.puts ""
|
|
|
|
$stderr.puts "Please use one of the standard log levels: debug, info, warn, or error"
|
|
|
|
exit 1
|
2012-01-07 21:13:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Set the logging level on all "vagrant" namespaced
|
|
|
|
# logs as long as we have a valid level.
|
|
|
|
if level
|
|
|
|
logger = Log4r::Logger.new("vagrant")
|
|
|
|
logger.outputters = Log4r::Outputter.stdout
|
|
|
|
logger.level = level
|
|
|
|
logger = nil
|
|
|
|
end
|
2011-12-04 01:12:07 +00:00
|
|
|
end
|
|
|
|
|
2010-09-04 02:25:48 +00:00
|
|
|
require 'pathname'
|
2011-12-19 02:14:20 +00:00
|
|
|
require 'childprocess'
|
2010-08-24 04:41:40 +00:00
|
|
|
require 'json'
|
2010-08-27 04:56:38 +00:00
|
|
|
require 'i18n'
|
2010-03-13 11:08:26 +00:00
|
|
|
|
2011-07-09 18:12:15 +00:00
|
|
|
# OpenSSL must be loaded here since when it is loaded via `autoload`
|
|
|
|
# there are issues with ciphers not being properly loaded.
|
|
|
|
require 'openssl'
|
|
|
|
|
2010-08-24 04:33:14 +00:00
|
|
|
module Vagrant
|
2011-01-07 09:12:16 +00:00
|
|
|
autoload :Action, 'vagrant/action'
|
2010-09-11 17:17:26 +00:00
|
|
|
autoload :Box, 'vagrant/box'
|
|
|
|
autoload :BoxCollection, 'vagrant/box_collection'
|
|
|
|
autoload :CLI, 'vagrant/cli'
|
2011-12-17 07:34:30 +00:00
|
|
|
autoload :Command, 'vagrant/command'
|
2012-01-06 08:56:09 +00:00
|
|
|
autoload :Communication, 'vagrant/communication'
|
2010-09-11 17:17:26 +00:00
|
|
|
autoload :Config, 'vagrant/config'
|
|
|
|
autoload :DataStore, 'vagrant/data_store'
|
2011-01-07 09:12:16 +00:00
|
|
|
autoload :Downloaders, 'vagrant/downloaders'
|
2011-12-19 02:14:20 +00:00
|
|
|
autoload :Driver, 'vagrant/driver'
|
2011-01-07 09:12:16 +00:00
|
|
|
autoload :Environment, 'vagrant/environment'
|
2010-09-11 17:17:26 +00:00
|
|
|
autoload :Errors, 'vagrant/errors'
|
2011-12-16 05:05:19 +00:00
|
|
|
autoload :Guest, 'vagrant/guest'
|
2011-01-07 09:12:16 +00:00
|
|
|
autoload :Hosts, 'vagrant/hosts'
|
2010-09-15 05:10:51 +00:00
|
|
|
autoload :Plugin, 'vagrant/plugin'
|
2011-12-15 06:49:14 +00:00
|
|
|
autoload :Provisioners, 'vagrant/provisioners'
|
2011-12-12 02:22:06 +00:00
|
|
|
autoload :Registry, 'vagrant/registry'
|
2011-07-09 18:12:15 +00:00
|
|
|
autoload :SSH, 'vagrant/ssh'
|
2010-09-15 15:19:38 +00:00
|
|
|
autoload :TestHelpers, 'vagrant/test_helpers'
|
2011-01-07 09:12:16 +00:00
|
|
|
autoload :UI, 'vagrant/ui'
|
2010-09-11 17:17:26 +00:00
|
|
|
autoload :Util, 'vagrant/util'
|
2011-01-07 09:12:16 +00:00
|
|
|
autoload :VM, 'vagrant/vm'
|
2010-08-24 17:27:36 +00:00
|
|
|
|
2010-08-24 18:18:29 +00:00
|
|
|
# The source root is the path to the root directory of
|
|
|
|
# the Vagrant gem.
|
|
|
|
def self.source_root
|
2010-09-04 02:25:48 +00:00
|
|
|
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
2010-08-24 04:33:14 +00:00
|
|
|
end
|
2011-12-12 07:22:44 +00:00
|
|
|
|
2011-12-17 17:14:05 +00:00
|
|
|
# Global registry of commands that are available via the CLI.
|
|
|
|
#
|
|
|
|
# This registry is used to look up the sub-commands that are available
|
|
|
|
# to Vagrant.
|
|
|
|
def self.commands
|
|
|
|
@commands ||= Registry.new
|
|
|
|
end
|
|
|
|
|
2011-12-16 04:32:33 +00:00
|
|
|
# Global registry of config keys that are available.
|
|
|
|
#
|
|
|
|
# This registry is used to look up the keys for `config` objects.
|
|
|
|
# For example, `config.vagrant` looks up the `:vagrant` config key
|
|
|
|
# for the configuration class to use.
|
|
|
|
def self.config_keys
|
|
|
|
@config_keys ||= Registry.new
|
|
|
|
end
|
|
|
|
|
2011-12-12 08:03:28 +00:00
|
|
|
# Global registry of available host classes and shortcut symbols
|
|
|
|
# associated with them.
|
|
|
|
#
|
|
|
|
# This registry is used to look up the shorcuts for `config.vagrant.host`,
|
|
|
|
# or to query all hosts for automatically detecting the host system.
|
|
|
|
# The registry is global to all of Vagrant.
|
2011-12-12 07:22:44 +00:00
|
|
|
def self.hosts
|
|
|
|
@hosts ||= Registry.new
|
|
|
|
end
|
2011-12-12 08:03:28 +00:00
|
|
|
|
|
|
|
# Global registry of available guest classes and shortcut symbols
|
|
|
|
# associated with them.
|
|
|
|
#
|
|
|
|
# This registry is used to look up the shortcuts for `config.vm.guest`.
|
|
|
|
def self.guests
|
|
|
|
@guests ||= Registry.new
|
|
|
|
end
|
2011-12-15 06:43:45 +00:00
|
|
|
|
|
|
|
# Global registry of provisioners.
|
|
|
|
#
|
|
|
|
# This registry is used to look up the provisioners provided for
|
|
|
|
# `config.vm.provision`.
|
|
|
|
def self.provisioners
|
|
|
|
@provisioners ||= Registry.new
|
|
|
|
end
|
2010-08-24 04:33:14 +00:00
|
|
|
end
|
|
|
|
|
2011-07-09 18:12:15 +00:00
|
|
|
# # Default I18n to load the en locale
|
2010-08-27 04:56:38 +00:00
|
|
|
I18n.load_path << File.expand_path("templates/locales/en.yml", Vagrant.source_root)
|
|
|
|
|
2011-12-17 17:14:05 +00:00
|
|
|
# Register the built-in commands
|
2011-12-18 03:53:57 +00:00
|
|
|
Vagrant.commands.register(:box) { Vagrant::Command::Box }
|
|
|
|
Vagrant.commands.register(:destroy) { Vagrant::Command::Destroy }
|
|
|
|
Vagrant.commands.register(:halt) { Vagrant::Command::Halt }
|
2011-12-18 05:06:00 +00:00
|
|
|
Vagrant.commands.register(:init) { Vagrant::Command::Init }
|
2011-12-18 03:53:57 +00:00
|
|
|
Vagrant.commands.register(:package) { Vagrant::Command::Package }
|
|
|
|
Vagrant.commands.register(:provision) { Vagrant::Command::Provision }
|
|
|
|
Vagrant.commands.register(:reload) { Vagrant::Command::Reload }
|
|
|
|
Vagrant.commands.register(:resume) { Vagrant::Command::Resume }
|
|
|
|
Vagrant.commands.register(:ssh) { Vagrant::Command::SSH }
|
2011-12-18 01:29:52 +00:00
|
|
|
Vagrant.commands.register(:"ssh-config") { Vagrant::Command::SSHConfig }
|
2011-12-18 03:53:57 +00:00
|
|
|
Vagrant.commands.register(:status) { Vagrant::Command::Status }
|
|
|
|
Vagrant.commands.register(:suspend) { Vagrant::Command::Suspend }
|
|
|
|
Vagrant.commands.register(:up) { Vagrant::Command::Up }
|
2011-12-17 17:14:05 +00:00
|
|
|
|
|
|
|
# Register the built-in config keys
|
2011-12-16 04:32:33 +00:00
|
|
|
Vagrant.config_keys.register(:vagrant) { Vagrant::Config::VagrantConfig }
|
|
|
|
Vagrant.config_keys.register(:ssh) { Vagrant::Config::SSHConfig }
|
|
|
|
Vagrant.config_keys.register(:nfs) { Vagrant::Config::NFSConfig }
|
|
|
|
Vagrant.config_keys.register(:vm) { Vagrant::Config::VMConfig }
|
|
|
|
Vagrant.config_keys.register(:package) { Vagrant::Config::PackageConfig }
|
|
|
|
|
2011-12-12 07:22:44 +00:00
|
|
|
# Register the built-in hosts
|
2011-12-12 08:03:28 +00:00
|
|
|
Vagrant.hosts.register(:arch) { Vagrant::Hosts::Arch }
|
2012-01-08 19:14:01 +00:00
|
|
|
Vagrant.hosts.register(:bsd) { Vagrant::Hosts::BSD }
|
2011-12-12 08:03:28 +00:00
|
|
|
Vagrant.hosts.register(:fedora) { Vagrant::Hosts::Fedora }
|
2012-01-08 19:14:01 +00:00
|
|
|
Vagrant.hosts.register(:freebsd) { Vagrant::Hosts::FreeBSD }
|
2011-12-12 08:03:28 +00:00
|
|
|
Vagrant.hosts.register(:linux) { Vagrant::Hosts::Linux }
|
2012-01-08 19:14:01 +00:00
|
|
|
Vagrant.hosts.register(:windows) { Vagrant::Hosts::Windows }
|
2011-12-12 08:03:28 +00:00
|
|
|
|
|
|
|
# Register the built-in guests
|
2011-12-16 05:05:19 +00:00
|
|
|
Vagrant.guests.register(:arch) { Vagrant::Guest::Arch }
|
|
|
|
Vagrant.guests.register(:debian) { Vagrant::Guest::Debian }
|
|
|
|
Vagrant.guests.register(:freebsd) { Vagrant::Guest::FreeBSD }
|
|
|
|
Vagrant.guests.register(:gentoo) { Vagrant::Guest::Gentoo }
|
|
|
|
Vagrant.guests.register(:linux) { Vagrant::Guest::Linux }
|
|
|
|
Vagrant.guests.register(:redhat) { Vagrant::Guest::Redhat }
|
|
|
|
Vagrant.guests.register(:solaris) { Vagrant::Guest::Solaris }
|
|
|
|
Vagrant.guests.register(:suse) { Vagrant::Guest::Suse }
|
|
|
|
Vagrant.guests.register(:ubuntu) { Vagrant::Guest::Ubuntu }
|
2011-12-12 07:24:23 +00:00
|
|
|
|
2011-12-15 06:43:45 +00:00
|
|
|
# Register the built-in provisioners
|
|
|
|
Vagrant.provisioners.register(:chef_solo) { Vagrant::Provisioners::ChefSolo }
|
|
|
|
Vagrant.provisioners.register(:chef_client) { Vagrant::Provisioners::ChefClient }
|
|
|
|
Vagrant.provisioners.register(:puppet) { Vagrant::Provisioners::Puppet }
|
|
|
|
Vagrant.provisioners.register(:puppet_server) { Vagrant::Provisioners::PuppetServer }
|
|
|
|
Vagrant.provisioners.register(:shell) { Vagrant::Provisioners::Shell }
|
|
|
|
|
2011-12-16 04:32:33 +00:00
|
|
|
# Register the built-in systems
|
2011-12-16 05:05:19 +00:00
|
|
|
Vagrant.config_keys.register(:freebsd) { Vagrant::Guest::FreeBSD::FreeBSDConfig }
|
|
|
|
Vagrant.config_keys.register(:linux) { Vagrant::Guest::Linux::LinuxConfig }
|
|
|
|
Vagrant.config_keys.register(:solaris) { Vagrant::Guest::Solaris::SolarisConfig }
|
2011-12-16 04:32:33 +00:00
|
|
|
|
2011-12-12 07:24:23 +00:00
|
|
|
# Load the things which must be loaded before anything else.
|
|
|
|
require 'vagrant/version'
|
|
|
|
Vagrant::Plugin.load!
|