Sha256: 69b7d4bef54198da9752552725cd93fdb9d0df8180845af0e9bedde5d424f0e0

Contents?: true

Size: 1.01 KB

Versions: 256

Compression:

Stored size: 1.01 KB

Contents

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

Version data entries

256 entries across 256 versions & 3 rubygems

Version Path
specinfra-2.91.0 lib/specinfra/backend/lxc.rb
specinfra-2.90.1 lib/specinfra/backend/lxc.rb
specinfra-2.90.0 lib/specinfra/backend/lxc.rb
specinfra-2.89.0 lib/specinfra/backend/lxc.rb
specinfra-2.88.2 lib/specinfra/backend/lxc.rb
specinfra-2.88.1 lib/specinfra/backend/lxc.rb
specinfra-2.88.0 lib/specinfra/backend/lxc.rb
specinfra-2.87.2 lib/specinfra/backend/lxc.rb
specinfra-2.87.1 lib/specinfra/backend/lxc.rb
specinfra-2.87.0 lib/specinfra/backend/lxc.rb
specinfra-2.86.0 lib/specinfra/backend/lxc.rb
specinfra-2.85.1 lib/specinfra/backend/lxc.rb
specinfra-2.85.0 lib/specinfra/backend/lxc.rb
specinfra-2.84.1 lib/specinfra/backend/lxc.rb
specinfra-2.84.0 lib/specinfra/backend/lxc.rb
specinfra-2.83.4 lib/specinfra/backend/lxc.rb
specinfra-2.83.3 lib/specinfra/backend/lxc.rb
specinfra-2.83.2 lib/specinfra/backend/lxc.rb
specinfra-2.83.1 lib/specinfra/backend/lxc.rb
specinfra-2.83.0 lib/specinfra/backend/lxc.rb