Module: Kitchen::Driver::Lxd::HostLocator

Included in:
Kitchen::Driver::Lxd
Defined in:
lib/kitchen/driver/lxd/host_locator.rb

Instance Method Summary collapse

Instance Method Details

#can_rest?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/kitchen/driver/lxd/host_locator.rb', line 23

def can_rest?
  config[:server] && !config[:server].empty?
end

#driverObject



8
9
10
# File 'lib/kitchen/driver/lxd/host_locator.rb', line 8

def driver
  @driver ||= nx_driver
end

#host_addressObject



27
28
29
# File 'lib/kitchen/driver/lxd/host_locator.rb', line 27

def host_address
  "https://#{config[:server]}:#{config[:port]}"
end

#nx_driverObject



12
13
14
15
# File 'lib/kitchen/driver/lxd/host_locator.rb', line 12

def nx_driver
  return ::NexusSW::LXD::Driver::CLI.new(::NexusSW::LXD::Transport::Local.new) unless can_rest?
  ::NexusSW::LXD::Driver::Rest.new(host_address, config[:rest_options])
end

#nx_transport(state) ⇒ Object



17
18
19
20
21
# File 'lib/kitchen/driver/lxd/host_locator.rb', line 17

def nx_transport(state)
  driver.transport_for(state[:container_name]).tap do |transport|
    transport.user state[:username] if state.key? :username
  end
end