Class: VagrantPlugins::Qubes::Action::Address

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-qubes/action/address.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, _env, multi) ⇒ Address

Returns a new instance of Address.



7
8
9
10
11
# File 'lib/vagrant-qubes/action/address.rb', line 7

def initialize(app, _env, multi)
  @app = app
  @logger = Log4r::Logger.new('vagrant_qubes::action::address')
  @multi = multi
end

Instance Method Details

#address(env) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vagrant-qubes/action/address.rb', line 18

def address(env)
  @logger.info('vagrant-qubes, address: start...')

  # Get config.
  machine = env[:machine]
  config = env[:machine].provider_config

  # return nil if machine is down.
  return nil if machine.state.id != :running

  ssh_info = machine.ssh_info
  return nil if !ssh_info

  if @multi == true
    env[:ui].info ssh_info[:host]
  else
    env[:ui].info ssh_info[:host]
  end
end

#call(env) ⇒ Object



13
14
15
16
# File 'lib/vagrant-qubes/action/address.rb', line 13

def call(env)
  address(env)
  @app.call(env)
end