Class: SpecInfra::Backend::Lxc
- Inherits:
-
Exec
- Object
- Base
- Exec
- SpecInfra::Backend::Lxc
show all
- Defined in:
- lib/specinfra/backend/lxc.rb
Instance Method Summary
collapse
Methods inherited from Exec
#check_executable, #check_monitored_by_monit, #check_mounted, #check_os, #check_readable, #check_routing_table, #check_running, #check_writable, #run_with_no_ruby_environment
Methods inherited from Base
#check_zero, #commands, #method_missing, #set_commands, #set_example
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class SpecInfra::Backend::Base
Instance Method Details
#add_pre_command(cmd) ⇒ Object
22
23
24
|
# File 'lib/specinfra/backend/lxc.rb', line 22
def add_pre_command(cmd)
cmd
end
|
#build_command(cmd) ⇒ Object
18
19
20
|
# File 'lib/specinfra/backend/lxc.rb', line 18
def build_command(cmd)
cmd
end
|
#copy_file(from, to) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/specinfra/backend/lxc.rb', line 26
def copy_file(from, to)
begin
FileUtils.cp(from, File.join(ct.config_item('lxc.rootfs'), to))
rescue => e
return false
end
true
end
|
#ct ⇒ Object
35
36
37
|
# File 'lib/specinfra/backend/lxc.rb', line 35
def ct
@ct ||= ::LXC::Container.new(RSpec.configuration.lxc)
end
|
#run_command(cmd, opts = {}) ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/specinfra/backend/lxc.rb', line 5
def run_command(cmd, opts={})
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
out, ret = ct.execute do
out = `#{cmd}`
[out, $?.dup]
end
if @example
@example.metadata[:command] = cmd
@example.metadata[:stdout] = out
end
CommandResult.new :stdout => out, :exit_status => ret.exitstatus
end
|