Class: VagrantPlugins::SecuredCloud::SecuredCloudProvider
- Inherits:
-
Object
- Object
- VagrantPlugins::SecuredCloud::SecuredCloudProvider
- Defined in:
- lib/secured-cloud-vagrant/provider.rb
Instance Method Summary collapse
- #action(name) ⇒ Object
-
#initialize(machine) ⇒ SecuredCloudProvider
constructor
A new instance of SecuredCloudProvider.
-
#machine_id_changed ⇒ Object
This method is called if the underlying machine ID changes.
-
#ssh_info ⇒ Hash
This should return a hash of information that explains how to SSH into the machine.
-
#state ⇒ Object
This should return the state of the machine within this provider.
Constructor Details
#initialize(machine) ⇒ SecuredCloudProvider
Returns a new instance of SecuredCloudProvider.
7 8 9 |
# File 'lib/secured-cloud-vagrant/provider.rb', line 7 def initialize(machine) @machine = machine end |
Instance Method Details
#action(name) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/secured-cloud-vagrant/provider.rb', line 12 def action(name) # Attempt to get the action method from the Action class if it # exists, otherwise return nil to show that we don't support the # given action. return Action.send(name) if Action.respond_to?(name) nil end |
#machine_id_changed ⇒ Object
This method is called if the underlying 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.
27 28 |
# File 'lib/secured-cloud-vagrant/provider.rb', line 27 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.
51 52 53 54 |
# File 'lib/secured-cloud-vagrant/provider.rb', line 51 def ssh_info env = @machine.action(:read_ssh_info) env[:vm_conn_info] end |
#state ⇒ Object
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.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/secured-cloud-vagrant/provider.rb', line 59 def state env = @machine.action("read_machine_state") vm_name = (env[:vm_name].nil? || env[:vm_name].empty?) ? env[:machine].provider_config.vm.name : env[:vm_name] state = (env[:machine_state].nil?) ? :unknown : env[:machine_state] short_desc = I18n.t("secured_cloud_vagrant.states.#{state}.short") long_desc = I18n.t("secured_cloud_vagrant.states.#{state}.long", :vm_name => vm_name) Vagrant::MachineState.new(state, short_desc, long_desc) end |