Class: Specinfra::Backend::Lxd

Inherits:
Exec
  • Object
show all
Defined in:
lib/specinfra/backend/lxd.rb

Overview

LXD transport

Instance Method Summary collapse

Methods inherited from Exec

#run_command, #send_directory

Methods inherited from Base

clear, #command, #get_config, #host_inventory, #initialize, instance, #os_info, #set_config, #set_example, #stderr_handler=, #stdout_handler=

Constructor Details

This class inherits a constructor from Specinfra::Backend::Base

Instance Method Details

#build_command(cmd) ⇒ Object



12
13
14
15
16
17
# File 'lib/specinfra/backend/lxd.rb', line 12

def build_command(cmd)
  lxc_cmd = %W[lxc exec #{instance}]
  lxc_cmd << '-t' if get_config(:interactive_shell)
  lxc_cmd << '--'
  (lxc_cmd << super(cmd)).join(' ')
end

#send_file(source, destination) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/specinfra/backend/lxd.rb', line 19

def send_file(source, destination)
  flags = %w[--create-dirs]
  if File.directory?(source)
    flags << '--recursive'
    destination = Pathname.new(destination).dirname.to_s
  end
  cmd = %W[lxc file push #{source} #{instance}#{destination}] + flags
  spawn_command(cmd.join(' '))
end