Class: Provider
- Inherits:
-
Object
- Object
- Provider
- Defined in:
- lib/provider.rb
Instance Method Summary collapse
-
#action(name) ⇒ Object
This should return an action callable for the given name.
-
#initialize(machine) ⇒ Provider
constructor
Initialize the provider to represent the given machine.
-
#machine_id_changed ⇒ Object
This method is called if the underying machine ID changes.
-
#ssh_info ⇒ Hash
This should return a hash of information that explains how to SSH into the machine.
-
#state ⇒ MachineState
This should return the state of the machine within this provider.
Constructor Details
#initialize(machine) ⇒ Provider
Initialize the provider to represent the given machine.
6 7 |
# File 'lib/provider.rb', line 6 def initialize(machine) end |
Instance Method Details
#action(name) ⇒ Object
This should return an action callable for the given name.
14 15 16 17 18 19 20 |
# File 'lib/provider.rb', line 14 def action(name) puts "#{name} was called" case name when :up then ->(a) {self.action :start} when :start then ->(a) {} end end |
#machine_id_changed ⇒ Object
This method is called if the underying machine ID changes. Providers can use this method to load in new data for the actual backing machine or to realize that the machine is now gone (the ID can become ‘nil`). No parameters are given, since the underlying machine is simply the machine instance given to this object. And no return value is necessary.
28 29 |
# File 'lib/provider.rb', line 28 def machine_id_changed end |
#ssh_info ⇒ Hash
This should return a hash of information that explains how to SSH into the machine. If the machine is not at a point where SSH is even possible, then ‘nil` should be returned.
The general structure of this returned hash should be the following:
{
:host => "1.2.3.4",
:port => "22",
:username => "mitchellh",
:private_key_path => "/path/to/my/key"
}
Note: Vagrant only supports private key based authentication, mainly for the reason that there is no easy way to exec into an ‘ssh` prompt with a password, whereas we can pass a private key via commandline.
52 53 54 |
# File 'lib/provider.rb', line 52 def ssh_info nil end |
#state ⇒ MachineState
This should return the state of the machine within this provider. The state must be an instance of MachineState. Please read the documentation of that class for more information.
61 62 63 |
# File 'lib/provider.rb', line 61 def state nil end |