Class: VagrantPlugins::OpenNebulaProvider::Action::ReadSSHInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/opennebula-provider/action/read_ssh_info.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ReadSSHInfo



5
6
7
8
# File 'lib/opennebula-provider/action/read_ssh_info.rb', line 5

def initialize(app, env)
  @app = app
  @logger = Log4r::Logger.new('vagrant::provider::opennebula::read_ssh_info')
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
# File 'lib/opennebula-provider/action/read_ssh_info.rb', line 10

def call(env)
  env[:machine_ssh_info] = read_ssh_info(env[:machine])
  @app.call(env)
end

#read_ssh_info(machine) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/opennebula-provider/action/read_ssh_info.rb', line 15

def read_ssh_info(machine)
  return nil if machine.id.nil?
  driver = machine.provider.driver

  host = driver.ssh_info(machine.id)
  { host: host, port: 22 } unless host.nil?
end