Class: Vagrant::Hosts::Base
- Inherits:
-
Object
- Object
- Vagrant::Hosts::Base
- Defined in:
- lib/vagrant/hosts/base.rb
Overview
Base class representing a host machine. These classes
define methods which may have host-specific (Mac OS X, Windows,
Linux, etc) behavior. The class is automatically determined by
default but may be explicitly set via config.vagrant.host
.
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
The Environment which this host belongs to.
Class Method Summary collapse
-
.detect ⇒ Class
Detects the proper host class for current platform and returns the class.
-
.load(env, klass) ⇒ Base
Loads the proper host for the given value.
Instance Method Summary collapse
-
#initialize(env) ⇒ Base
constructor
Initialzes a new host.
-
#nfs? ⇒ Boolean
Returns true of false denoting whether or not this host supports NFS shared folder setup.
-
#nfs_cleanup ⇒ Object
Cleans up the exports for the current VM.
-
#nfs_export(ip, folders) ⇒ Object
Exports the given hash of folders via NFS.
Constructor Details
#initialize(env) ⇒ Base
Initialzes a new host. This method shouldn't be called directly, typically, since it will be called by Environment#load!.
51 52 53 |
# File 'lib/vagrant/hosts/base.rb', line 51 def initialize(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
The Environment which this host belongs to.
9 10 11 |
# File 'lib/vagrant/hosts/base.rb', line 9 def env @env end |
Class Method Details
.detect ⇒ Class
Detects the proper host class for current platform and returns the class.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/vagrant/hosts/base.rb', line 29 def detect # More coming soon classes = { :darwin => BSD, :bsd => BSD, :linux => Linux } classes.each do |type, klass| return klass if Util::Platform.send("#{type}?") end nil rescue Exception nil end |
.load(env, klass) ⇒ Base
Loads the proper host for the given value. If the value is nil
or is the symbol :detect
, then the host class will be detected
using the RUBY_PLATFORM
constant.
19 20 21 22 23 |
# File 'lib/vagrant/hosts/base.rb', line 19 def load(env, klass) klass = detect if klass.nil? || klass == :detect return nil if !klass return klass.new(env) end |
Instance Method Details
#nfs? ⇒ Boolean
Returns true of false denoting whether or not this host supports NFS shared folder setup. This method ideally should verify that NFS is installed.
60 61 62 |
# File 'lib/vagrant/hosts/base.rb', line 60 def nfs? false end |
#nfs_cleanup ⇒ Object
Cleans up the exports for the current VM.
73 74 |
# File 'lib/vagrant/hosts/base.rb', line 73 def nfs_cleanup end |
#nfs_export(ip, folders) ⇒ Object
Exports the given hash of folders via NFS. This method will raise an Action::ActionException if anything goes wrong.
69 70 |
# File 'lib/vagrant/hosts/base.rb', line 69 def nfs_export(ip, folders) end |