class VagrantPlugins::VSphere::Action::GetSshInfo

Public Class Methods

new(app, _env) click to toggle source
# File lib/vSphere/action/get_ssh_info.rb, line 10
def initialize(app, _env)
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# File lib/vSphere/action/get_ssh_info.rb, line 14
def call(env)
  env[:machine_ssh_info] = get_ssh_info(env[:vSphere_connection], env[:machine])

  @app.call env
end

Private Instance Methods

get_ssh_info(connection, machine) click to toggle source
# File lib/vSphere/action/get_ssh_info.rb, line 22
def get_ssh_info(connection, machine)
  return nil if machine.id.nil?

  vm = get_vm_by_uuid connection, machine

  return nil if vm.nil?
  return nil if vm.guest.ipAddress.nil? || vm.guest.ipAddress.empty?
  {
    host: vm.guest.ipAddress,
    port: 22
  }
end