Start moving guest configuration out into plugins

This commit is contained in:
Mitchell Hashimoto 2012-04-18 17:38:20 -07:00
parent a23fee4848
commit dd459170dd
12 changed files with 83 additions and 78 deletions

View File

@ -115,15 +115,6 @@ module Vagrant
@commands ||= Registry.new
end
# 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
# Global registry of available host classes and shortcut symbols
# associated with them.
#
@ -183,13 +174,6 @@ Vagrant.commands.register(:status) { Vagrant::Command::Status }
Vagrant.commands.register(:suspend) { Vagrant::Command::Suspend }
Vagrant.commands.register(:up) { Vagrant::Command::Up }
# Register the built-in config keys
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 }
# Register the built-in hosts
Vagrant.hosts.register(:arch) { Vagrant::Hosts::Arch }
Vagrant.hosts.register(:bsd) { Vagrant::Hosts::BSD }
@ -219,8 +203,3 @@ Vagrant.provisioners.register(:chef_client) { Vagrant::Provisioners::ChefClien
Vagrant.provisioners.register(:puppet) { Vagrant::Provisioners::Puppet }
Vagrant.provisioners.register(:puppet_server) { Vagrant::Provisioners::PuppetServer }
Vagrant.provisioners.register(:shell) { Vagrant::Provisioners::Shell }
# Register the built-in systems
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 }

View File

@ -6,20 +6,6 @@ module Vagrant
#
# Contributed by Kenneth Vestergaard <kvs@binarysolutions.dk>
class FreeBSD < Base
# A custom config class which will be made accessible via `config.freebsd`
# This is not necessary for all system implementers, of course. However,
# generally, Vagrant tries to make almost every aspect of its execution
# configurable, and this assists that goal.
class FreeBSDConfig < Vagrant::Config::Base
attr_accessor :halt_timeout
attr_accessor :halt_check_interval
def initialize
@halt_timeout = 30
@halt_check_interval = 1
end
end
# Here for whenever it may be used.
class FreeBSDError < Errors::VagrantError
error_namespace("vagrant.guest.freebsd")

View File

@ -1,7 +1,6 @@
require 'log4r'
require 'vagrant/guest/linux/error'
require 'vagrant/guest/linux/config'
module Vagrant
module Guest

View File

@ -1,19 +0,0 @@
module Vagrant
module Guest
class Linux < Vagrant::Guest::Base
# A custom config class which will be made accessible via `config.linux`
# This is not necessary for all system implementers, of course. However,
# generally, Vagrant tries to make almost every aspect of its execution
# configurable, and this assists that goal.
class LinuxConfig < Vagrant::Config::Base
attr_accessor :halt_timeout
attr_accessor :halt_check_interval
def initialize
@halt_timeout = 30
@halt_check_interval = 1
end
end
end
end
end

View File

@ -4,25 +4,6 @@ module Vagrant
#
# Contributed by Blake Irvin <b.irvin@modcloth.com>
class Solaris < Base
# A custom config class which will be made accessible via `config.solaris`
# This is not necessary for all system implementers, of course. However,
# generally, Vagrant tries to make almost every aspect of its execution
# configurable, and this assists that goal.
class SolarisConfig < Vagrant::Config::Base
attr_accessor :halt_timeout
attr_accessor :halt_check_interval
# This sets the command to use to execute items as a superuser. sudo is default
attr_accessor :suexec_cmd
attr_accessor :device
def initialize
@halt_timeout = 30
@halt_check_interval = 1
@suexec_cmd = 'sudo'
@device = "e1000g"
end
end
# Here for whenever it may be used.
class SolarisError < Errors::VagrantError
error_namespace("vagrant.guest.solaris")

View File

@ -0,0 +1,13 @@
module VagrantPlugins
module GuestFreeBSD
class Config < Vagrant::Config::Base
attr_accessor :halt_timeout
attr_accessor :halt_check_interval
def initialize
@halt_timeout = 30
@halt_check_interval = 1
end
end
end
end

View File

@ -0,0 +1,13 @@
require "vagrant"
module VagrantPlugins
module GuestFreeBSD
autoload :Config, File.expand_path("../config", __FILE__)
class Plugin < Vagrant.plugin("1")
name "FreeBSD guest"
description "FreeBSD guest support."
config("freebsd") { Config }
end
end
end

View File

@ -0,0 +1,13 @@
module VagrantPlugins
module GuestLinux
class Config < Vagrant::Config::Base
attr_accessor :halt_timeout
attr_accessor :halt_check_interval
def initialize
@halt_timeout = 30
@halt_check_interval = 1
end
end
end
end

View File

@ -0,0 +1,13 @@
require "vagrant"
module VagrantPlugins
module GuestLinux
autoload :Config, File.expand_path("../config", __FILE__)
class Plugin < Vagrant.plugin("1")
name "Linux guest."
description "Linux guest support."
config("linux") { Config }
end
end
end

View File

@ -0,0 +1,18 @@
module VagrantPlugins
module GuestSolaris
class Config < Vagrant::Config::Base
attr_accessor :halt_timeout
attr_accessor :halt_check_interval
# This sets the command to use to execute items as a superuser. sudo is default
attr_accessor :suexec_cmd
attr_accessor :device
def initialize
@halt_timeout = 30
@halt_check_interval = 1
@suexec_cmd = 'sudo'
@device = "e1000g"
end
end
end
end

View File

@ -0,0 +1,13 @@
require "vagrant"
module VagrantPlugins
module GuestSolaris
autoload :Config, File.expand_path("../config", __FILE__)
class Plugin < Vagrant.plugin("1")
name "Solaris guest."
description "Solaris guest support."
config("solaris") { Config }
end
end
end

View File

@ -9,10 +9,6 @@ describe Vagrant do
described_class.commands.should be_a(Vagrant::Registry)
end
it "has a registry for config keys" do
described_class.config_keys.should be_a(Vagrant::Registry)
end
it "has a registry for hosts" do
described_class.hosts.should be_a(Vagrant::Registry)
end