class Specinfra::Backend::Lxc
Public Class Methods
new(config = {})
click to toggle source
Calls superclass method
Specinfra::Backend::Base::new
# File lib/specinfra/backend/lxc.rb, line 4 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
Public Instance Methods
add_pre_command(cmd)
click to toggle source
# File lib/specinfra/backend/lxc.rb, line 32 def add_pre_command(cmd) cmd end
build_command(cmd)
click to toggle source
# File lib/specinfra/backend/lxc.rb, line 28 def build_command(cmd) cmd end
ct()
click to toggle source
# File lib/specinfra/backend/lxc.rb, line 40 def ct @ct ||= ::LXC::Container.new(get_config(:lxc)) end
run_command(cmd, opts={})
click to toggle source
# File lib/specinfra/backend/lxc.rb, line 14 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
send_file(from, to)
click to toggle source
# File lib/specinfra/backend/lxc.rb, line 36 def send_file(from, to) FileUtils.cp(from, File.join(ct.config_item('lxc.rootfs'), to)) end