Change config.vm.system to config.vm.guest. Rename internals.

This commit is contained in:
Mitchell Hashimoto 2011-12-15 20:55:16 -08:00
parent eda286b476
commit 5fe50c8b5d
11 changed files with 51 additions and 50 deletions

View File

@ -4,6 +4,8 @@
to make debugging issues easier. To enable logging, set the VAGRANT_LOG to make debugging issues easier. To enable logging, set the VAGRANT_LOG
environmental variable to the log level you wish to see. By default, environmental variable to the log level you wish to see. By default,
logging is silent. logging is silent.
- `system` renamed to `guest` throughout the source. Any `config.vm.system`
configurations must be changed to `config.vm.guest`
- Linux uses `shutdown -h` instead of `halt` to hopefully more consistently - Linux uses `shutdown -h` instead of `halt` to hopefully more consistently
power off the system. [GH-575] power off the system. [GH-575]
- Tweaks to SSH to hopefully be more reliable in coming up. - Tweaks to SSH to hopefully be more reliable in coming up.

View File

@ -18,7 +18,7 @@ Vagrant::Config.run do |config|
config.vm.base_mac = nil config.vm.base_mac = nil
config.vm.forward_port("ssh", 22, 2222, :auto => true) config.vm.forward_port("ssh", 22, 2222, :auto => true)
config.vm.boot_mode = "vrdp" config.vm.boot_mode = "vrdp"
config.vm.system = :linux config.vm.guest = :linux
# Share the root folder. This can then be overridden by # Share the root folder. This can then be overridden by
# other Vagrantfiles, if they wish. # other Vagrantfiles, if they wish.

View File

@ -9,7 +9,7 @@ module Vagrant
def call(env) def call(env)
if env[:vm].created? && env[:vm].vm.running? if env[:vm].created? && env[:vm].vm.running?
env[:vm].system.halt if !env["force"] env[:vm].guest.halt if !env["force"]
if env[:vm].vm.state(true) != :powered_off if env[:vm].vm.state(true) != :powered_off
env[:ui].info I18n.t("vagrant.actions.vm.halt.force") env[:ui].info I18n.t("vagrant.actions.vm.halt.force")

View File

@ -12,7 +12,7 @@ module Vagrant
host_name = env[:vm].config.vm.host_name host_name = env[:vm].config.vm.host_name
if !host_name.nil? if !host_name.nil?
env[:ui].info I18n.t("vagrant.actions.vm.host_name.setting") env[:ui].info I18n.t("vagrant.actions.vm.host_name.setting")
env[:vm].system.change_host_name(host_name) env[:vm].guest.change_host_name(host_name)
end end
end end
end end

View File

@ -29,12 +29,12 @@ module Vagrant
# Prepare for new networks... # Prepare for new networks...
options = @env[:vm].config.vm.network_options.compact options = @env[:vm].config.vm.network_options.compact
options.each do |network_options| options.each do |network_options|
@env["vm"].system.prepare_host_only_network(network_options) @env["vm"].guest.prepare_host_only_network(network_options)
end end
# Then enable the networks... # Then enable the networks...
options.each do |network_options| options.each do |network_options|
@env["vm"].system.enable_host_only_network(network_options) @env["vm"].guest.enable_host_only_network(network_options)
end end
end end
end end

View File

@ -116,7 +116,7 @@ module Vagrant
# Only mount the folders which have a guest path specified # Only mount the folders which have a guest path specified
am_folders = folders.select { |name, folder| folder[:guestpath] } am_folders = folders.select { |name, folder| folder[:guestpath] }
am_folders = Hash[*am_folders.flatten] if am_folders.is_a?(Array) am_folders = Hash[*am_folders.flatten] if am_folders.is_a?(Array)
@env[:vm].system.mount_nfs(host_ip, Hash[am_folders]) @env[:vm].guest.mount_nfs(host_ip, Hash[am_folders])
end end
# Returns the IP address of the first host only network adapter # Returns the IP address of the first host only network adapter

View File

@ -74,7 +74,7 @@ module Vagrant
group = data[:group] || @env[:vm].config.ssh.username group = data[:group] || @env[:vm].config.ssh.username
# Mount the actual folder # Mount the actual folder
@env[:vm].system.mount_shared_folder(ssh, name, data[:guestpath], owner, group) @env[:vm].guest.mount_shared_folder(ssh, name, data[:guestpath], owner, group)
else else
# If no guest path is specified, then automounting is disabled # If no guest path is specified, then automounting is disabled
@env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry", @env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry",

View File

@ -17,7 +17,7 @@ module Vagrant
attr_reader :shared_folders attr_reader :shared_folders
attr_reader :network_options attr_reader :network_options
attr_reader :provisioners attr_reader :provisioners
attr_accessor :system attr_accessor :guest
def initialize def initialize
@forwarded_ports = {} @forwarded_ports = {}

View File

@ -324,6 +324,11 @@ module Vagrant
error_key(:failed_to_boot, "vagrant.actions.vm.boot") error_key(:failed_to_boot, "vagrant.actions.vm.boot")
end end
class VMGuestError < VagrantError
status_code(39)
error_namespace("vagrant.errors.guest")
end
class VMImportFailure < VagrantError class VMImportFailure < VagrantError
status_code(28) status_code(28)
error_key(:failure, "vagrant.actions.vm.import") error_key(:failure, "vagrant.actions.vm.import")
@ -353,10 +358,5 @@ module Vagrant
status_code(24) status_code(24)
error_key(:power_off, "vagrant.actions.vm.export") error_key(:power_off, "vagrant.actions.vm.export")
end end
class VMSystemError < VagrantError
status_code(39)
error_namespace("vagrant.errors.system")
end
end end
end end

View File

@ -19,44 +19,43 @@ module Vagrant
@config = config @config = config
@box = env.boxes.find(config.vm.box) @box = env.boxes.find(config.vm.box)
# Load the associated system. # Load the associated guest.
load_system! load_guest!
@loaded_guest_distro = false
@loaded_system_distro = false
end end
# Loads the system associated with the VM. The system class is # Loads the guest associated with the VM. The guest class is
# responsible for OS-specific functionality. More information # responsible for OS-specific functionality. More information
# can be found by reading the documentation on {Vagrant::Systems::Base}. # can be found by reading the documentation on {Vagrant::Guest::Base}.
# #
# **This method should never be called manually.** # **This method should never be called manually.**
def load_system!(system=nil) def load_guest!(guest=nil)
system ||= config.vm.system guest ||= config.vm.guest
@logger.info("Loading system: #{system}") @logger.info("Loading guest: #{guest}")
if system.is_a?(Class) if guest.is_a?(Class)
raise Errors::VMSystemError, :_key => :invalid_class, :system => system.to_s if !(system <= Systems::Base) raise Errors::VMGuestError, :_key => :invalid_class, :system => guest.to_s if !(guest <= Systems::Base)
@system = system.new(self) @guest = guest.new(self)
elsif system.is_a?(Symbol) elsif guest.is_a?(Symbol)
system_klass = Vagrant.guests.get(system) guest_klass = Vagrant.guests.get(guest)
raise Errors::VMSystemError, :_key => :unknown_type, :system => system.to_s if !system_klass raise Errors::VMGuestError, :_key => :unknown_type, :system => guest.to_s if !guest_klass
@system = system_klass.new(self) @guest = guest_klass.new(self)
else else
raise Errors::VMSystemError, :unspecified raise Errors::VMGuestError, :unspecified
end end
end end
# Returns the system for this VM, loading the distro of the system if # Returns the guest for this VM, loading the distro of the system if
# we can. # we can.
def system def guest
if !@loaded_system_distro && created? && vm.running? if !@loaded_guest_distro && created? && vm.running?
# Load the system distro for the first time # Load the guest distro for the first time
result = @system.distro_dispatch result = @guest.distro_dispatch
load_system!(result) load_guest!(result)
@loaded_system_distro = true @loaded_guest_distro = true
end end
@system @guest
end end
# Access the {Vagrant::SSH} object associated with this VM. # Access the {Vagrant::SSH} object associated with this VM.

View File

@ -43,6 +43,18 @@ en:
may run at any given time to avoid problems with VirtualBox inconsistencies may run at any given time to avoid problems with VirtualBox inconsistencies
occurring. Please wait for the other instance of Vagrant to end and then occurring. Please wait for the other instance of Vagrant to end and then
try again. try again.
guest:
invalid_class: |-
The specified system does not inherit from `Vagrant::Systems::Base`. The
specified system class must inherit from this class.
The specified system class was: %{system}
unknown_type: |-
The specified system type is unknown: %{system}. Please change this
to a proper value.
unspecified: |-
A VM system type must be specified! This is done via the `config.vm.system`
configuration value. Please read the documentation online for more information.
home_dir_not_accessible: |- home_dir_not_accessible: |-
The home directory you specified is not accessible. The home The home directory you specified is not accessible. The home
directory that Vagrant uses must be both readable and writable. directory that Vagrant uses must be both readable and writable.
@ -103,18 +115,6 @@ en:
http://vagrantup.com/docs/getting-started/setup/windows.html http://vagrantup.com/docs/getting-started/setup/windows.html
system:
invalid_class: |-
The specified system does not inherit from `Vagrant::Systems::Base`. The
specified system class must inherit from this class.
The specified system class was: %{system}
unknown_type: |-
The specified system type is unknown: %{system}. Please change this
to a proper value.
unspecified: |-
A VM system type must be specified! This is done via the `config.vm.system`
configuration value. Please read the documentation online for more information.
vagrantfile_syntax_error: |- vagrantfile_syntax_error: |-
There is a syntax error in the following Vagrantfile. The syntax error There is a syntax error in the following Vagrantfile. The syntax error
message is reproduced below for convenience: message is reproduced below for convenience: