/usr/lib/ruby/vendor_ruby/specinfra/backend/lxc.rb is in ruby-specinfra 2.35.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | module Specinfra
module Backend
class Lxc < Exec
def initialize(config = {})
super
begin
require 'lxc/extra' unless defined?(::LXC::Extra)
rescue LoadError
fail "LXC client library is not available. Try installing `lxc-extra' gem"
end
end
def run_command(cmd, opts={})
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
out, ret = ct.execute do
out = `#{cmd} 2>&1`
[out, $?.dup]
end
if @example
@example.metadata[:command] = cmd
@example.metadata[:stdout] = out
end
CommandResult.new :stdout => out, :exit_status => ret.exitstatus
end
def build_command(cmd)
cmd
end
def add_pre_command(cmd)
cmd
end
def send_file(from, to)
FileUtils.cp(from, File.join(ct.config_item('lxc.rootfs'), to))
end
def ct
@ct ||= ::LXC::Container.new(get_config(:lxc))
end
end
end
end
|