Class: Vagrant::Plugin::V2::Guest
- Inherits:
-
Object
- Object
- Vagrant::Plugin::V2::Guest
- Includes:
- Util
- Defined in:
- lib/vagrant/plugin/v2/guest.rb
Overview
The base class for a guest. A guest represents an installed system within a machine that Vagrant manages. There are some portions of Vagrant which are OS-specific such as mountaing shared folders and halting the machine, and this abstraction allows the implementation for these to be seperate from the core of Vagrant.
Defined Under Namespace
Classes: BaseError
Instance Attribute Summary collapse
-
#vm ⇒ Object
readonly
The VM which this system is tied to.
Instance Method Summary collapse
-
#change_host_name(name) ⇒ Object
Called to change the hostname of the virtual machine.
-
#configure_networks(networks) ⇒ Object
Configures the given list of networks on the virtual machine.
-
#distro_dispatch ⇒ Object
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.
-
#halt ⇒ Object
Halt the machine.
-
#initialize(vm) ⇒ Guest
constructor
Initializes the system.
-
#mount_nfs(ip, folders) ⇒ Object
Mounts a shared folder via NFS.
-
#mount_shared_folder(name, guestpath, options) ⇒ Object
Mounts a shared folder.
Constructor Details
#initialize(vm) ⇒ Guest
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`.
22 23 24 |
# File 'lib/vagrant/plugin/v2/guest.rb', line 22 def initialize(vm) @vm = vm end |
Instance Attribute Details
#vm ⇒ Object (readonly)
The VM which this system is tied to.
17 18 19 |
# File 'lib/vagrant/plugin/v2/guest.rb', line 17 def vm @vm end |
Instance Method Details
#change_host_name(name) ⇒ Object
Called to change the hostname of the virtual machine.
86 87 88 |
# File 'lib/vagrant/plugin/v2/guest.rb', line 86 def change_host_name(name) raise BaseError, :_key => :unsupported_host_name end |
#configure_networks(networks) ⇒ Object
Configures the given list of networks on the virtual machine.
The networks parameter will be an array of hashes where the hashes represent the configuration of a network interface. The structure of the hash will be roughly the following:
:type => :static,
:ip => "192.168.33.10",
:netmask => "255.255.255.0",
:interface => 1
81 82 83 |
# File 'lib/vagrant/plugin/v2/guest.rb', line 81 def configure_networks(networks) raise BaseError, :_key => :unsupported_configure_networks end |
#distro_dispatch ⇒ Object
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.
If this method returns nil, then this instance is assumed to be the most specific guest implementation.
32 33 |
# File 'lib/vagrant/plugin/v2/guest.rb', line 32 def distro_dispatch end |
#halt ⇒ Object
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.
42 43 44 |
# File 'lib/vagrant/plugin/v2/guest.rb', line 42 def halt raise BaseError, :_key => :unsupported_halt end |
#mount_nfs(ip, folders) ⇒ Object
Mounts a shared folder via NFS. This assumes that the exports via the host are already done.
64 65 66 |
# File 'lib/vagrant/plugin/v2/guest.rb', line 64 def mount_nfs(ip, folders) raise BaseError, :_key => :unsupported_nfs end |
#mount_shared_folder(name, guestpath, options) ⇒ Object
Mounts a shared folder.
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`.
58 59 60 |
# File 'lib/vagrant/plugin/v2/guest.rb', line 58 def mount_shared_folder(name, guestpath, ) raise BaseError, :_key => :unsupported_shared_folder end |