Class: VagrantPlugins::ProviderLocal::Provider
- Inherits:
-
Object
- Object
- VagrantPlugins::ProviderLocal::Provider
- Defined in:
- lib/vagrant-local/provider.rb
Overview
This is a module to assist in managing a Host
Instance Method Summary collapse
-
#action(name) ⇒ Object
This should return an action callable for the given name.
- #driver ⇒ Object
-
#initialize(machine) ⇒ Provider
constructor
A new instance of Provider.
-
#machine_id_changed ⇒ Object
This method is called if the underying machine ID changes.
- #ssh_info ⇒ Object
- #state ⇒ Object
Constructor Details
permalink #initialize(machine) ⇒ Provider
Returns a new instance of Provider.
12 13 14 15 16 |
# File 'lib/vagrant-local/provider.rb', line 12 def initialize(machine) @logger = Log4r::Logger.new('vagrant::provider::local') @machine = machine super(machine) end |
Instance Method Details
permalink #action(name) ⇒ Object
This should return an action callable for the given name.
46 47 48 49 50 51 52 53 54 |
# File 'lib/vagrant-local/provider.rb', line 46 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 action_method = "action_#{name}" return Action.send(action_method) if Action.respond_to?(action_method) nil end |
permalink #driver ⇒ Object
[View source]
18 19 20 21 22 |
# File 'lib/vagrant-local/provider.rb', line 18 def driver return @driver if @driver @driver = Driver.new(@machine) end |
permalink #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.
62 63 64 |
# File 'lib/vagrant-local/provider.rb', line 62 def machine_id_changed nil end |
permalink #ssh_info ⇒ Object
[View source]
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/vagrant-local/provider.rb', line 24 def ssh_info # We just return nil if were not able to identify the VM's IP and # let Vagrant core deal with it like docker provider does return nil if state.id != :running return nil unless driver.get_ip_address passwordauth = 'passwordauth' ssh_info = { host: driver.get_ip_address, port: driver.sshport(@machine).to_s, password: driver.vagrantuserpass(@machine).to_s, username: driver.user(@machine), private_key_path: driver.userprivatekeypath(@machine).to_s, PasswordAuthentication: passwordauth } ssh_info unless ssh_info.nil? end |
permalink #state ⇒ Object
[View source]
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/vagrant-local/provider.rb', line 66 def state state_id = nil state_id = :not_created unless @machine.id state_id = driver.state if @machine.id && !state_id # This is a special pseudo-state so that we don't set the # NOT_CREATED_ID while we're setting up the machine. This avoids # clearing the data dir. state_id = :preparing if @machine.id == 'preparing' # Get the short and long description short = state_id.to_s.tr('_', ' ') # If we're not created, then specify the special ID flag state_id = Vagrant::MachineState::NOT_CREATED_ID if state_id == :not_created # Return the MachineState object Vagrant::MachineState.new(state_id, short, short) end |