Class: Vagrant::Systems::Base

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/vagrant/systems/base.rb

Overview

The base class for a "system." A system represents an installed operating system on a given box. There are some portions of Vagrant which are fairly OS-specific (such as mounting shared folders) and while the number is few, this abstraction allows more obscure operating systems to be installed without having to directly modify Vagrant internals.

Subclasses of the system base class are expected to implement all the methods. These methods are described in the comments above their definition.

This is by no means a complete specification. The methods required by systems can and will change at any time. Any changes will be noted on release notes.

Direct Known Subclasses

FreeBSD, Linux, Solaris

Defined Under Namespace

Classes: BaseError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vm) ⇒ Base

Initializes the system. Any subclasses MUST make sure this method is called on the parent. Therefore, if a subclass overrides initialize, then you must call super.



30
31
32
# File 'lib/vagrant/systems/base.rb', line 30

def initialize(vm)
  @vm = vm
end

Instance Attribute Details

#vmObject (readonly)

The VM which this system is tied to.



25
26
27
# File 'lib/vagrant/systems/base.rb', line 25

def vm
  @vm
end

Instance Method Details

#change_host_name(name) ⇒ Object

Raises:



82
83
84
# File 'lib/vagrant/systems/base.rb', line 82

def change_host_name(name)
  raise BaseError, :_key => :unsupported_host_name
end

#distro_dispatchObject

This method is automatically called when the system is available (when Vagrant can successfully SSH into the machine) to give the system a chance to determine the distro and return a distro-specific system.

Warning: If a return value which subclasses from Vagrant::Systems::Base is returned, Vagrant will use it as the new system instance for the class.



41
# File 'lib/vagrant/systems/base.rb', line 41

def distro_dispatch; end

#enable_host_only_network(net_options) ⇒ Object

Setup the system by adding a new host only network. This method should configure and bring up the interface for the given options.

Parameters:

  • net_options (Hash)

    The options for the network.



80
# File 'lib/vagrant/systems/base.rb', line 80

def enable_host_only_network(net_options); end

#haltObject

Halt the machine. This method should gracefully shut down the operating system. This method will cause vagrant halt and associated commands to block, meaning that if the machine doesn't halt in a reasonable amount of time, this method should just return.

If when this method returns, the machine's state isn't "powered_off," Vagrant will proceed to forcefully shut the machine down.



50
# File 'lib/vagrant/systems/base.rb', line 50

def halt; end

#mount_nfs(ip, folders) ⇒ Object

Mounts a shared folder via NFS. This assumes that the exports via the host are already done.



67
# File 'lib/vagrant/systems/base.rb', line 67

def mount_nfs(ip, folders); end

#mount_shared_folder(ssh, name, guestpath) ⇒ Object

Mounts a shared folder. This method is called by the shared folder action with an open SSH session (passed in as ssh). This method should create, mount, and properly set permissions on the shared folder. This method should also properly adhere to any configuration values such as shared_folder_uid on config.vm.

Parameters:

  • ssh (Object)

    The Net::SSH session.

  • name (String)

    The name of the shared folder.

  • guestpath (String)

    The path on the machine which the user wants the folder mounted.



63
# File 'lib/vagrant/systems/base.rb', line 63

def mount_shared_folder(ssh, name, guestpath); end

#prepare_host_only_network(net_options = nil) ⇒ Object

Prepares the system for host only networks. This is called once prior to any enable_host_only_network calls.

Raises:



71
72
73
# File 'lib/vagrant/systems/base.rb', line 71

def prepare_host_only_network(net_options=nil)
  raise BaseError, :_key => :unsupported_host_only
end