Sha256: d2f6024739138ad46db25fd2d1cdb08120dabe39fd6a64d3fb051223a79bac6a

Contents?: true

Size: 896 Bytes

Versions: 3

Compression:

Stored size: 896 Bytes

Contents

module Specinfra
  module Backend
    class Lxc < Exec
      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
      def build_command(cmd)
        cmd
      end

      def add_pre_command(cmd)
        cmd
      end

      def copy_file(from, to)
        begin
          FileUtils.cp(from, File.join(ct.config_item('lxc.rootfs'), to))
        rescue => e
          return false
        end
        true
      end

      def ct
        @ct ||= ::LXC::Container.new(RSpec.configuration.lxc)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
specinfra-2.0.0.beta4 lib/specinfra/backend/lxc.rb
specinfra-2.0.0.beta3 lib/specinfra/backend/lxc.rb
specinfra-2.0.0.beta2 lib/specinfra/backend/lxc.rb