Sha256: e162710bbc13bafe2b7f9fcd0873401bdc8d354e285bdbbf70c3e5c97e8dd018

Contents?: true

Size: 1.88 KB

Versions: 45

Compression:

Stored size: 1.88 KB

Contents

class TestLab
  class Container

    module Support

      # Returns arguments for lxc-create based on our distro
      #
      # @return [Array<String>] An array of arguments for lxc-create
      def create_args
        case self.distro.downcase
        when "ubuntu" then
          %W(-f /etc/lxc/#{self.id} -t #{self.distro} -- --release #{self.release} --arch #{self.arch})
        when "fedora" then
          %W(-f /etc/lxc/#{self.id} -t #{self.distro} -- --release #{self.release})
        end
      end

      # Returns arguments for lxc-start
      #
      # @return [Array<String>] An array of arguments for lxc-start
      def start_args
        arguments = Array.new

        unless self.aa_profile.nil?
          arguments << %W(-s lxc.aa_profile="#{self.aa_profile}")
        end

        unless self.cap_drop.nil?
          cap_drop = [self.cap_drop].flatten.compact.map(&:downcase).join(' ')
          arguments << %W(-s lxc.cap.drop="#{cap_drop}")
        end

        arguments << %W(-d -l DEBUG)

        arguments.flatten.compact
      end

      # Returns arguments for lxc-start-ephemeral
      #
      # @return [Array<String>] An array of arguments for lxc-start-ephemeral
      def clone_args
        arguments = Array.new

        arguments << %W(-o #{self.lxc_clone.name} -n #{self.lxc.name} -d)
        arguments << %W(--keep-data) if self.persist

        arguments.flatten.compact
      end

      # Attempt to detect the architecture of the node.  The value returned is
      # respective to the container distro.
      #
      # @return [String] The arch of the node in the context of the container
      #   distro
      def detect_arch
        case self.distro.downcase
        when "ubuntu" then
          ((self.node.arch =~ /x86_64/) ? "amd64" : "i386")
        when "fedora" then
          ((self.node.arch =~ /x86_64/) ? "amd64" : "i686")
        end
      end

    end

  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
testlab-1.22.4 lib/testlab/container/support.rb
testlab-1.22.3 lib/testlab/container/support.rb
testlab-1.22.2 lib/testlab/container/support.rb
testlab-1.22.1 lib/testlab/container/support.rb
testlab-1.22.0 lib/testlab/container/support.rb
testlab-1.21.1 lib/testlab/container/support.rb
testlab-1.21.0 lib/testlab/container/support.rb
testlab-1.20.6 lib/testlab/container/support.rb
testlab-1.20.5 lib/testlab/container/support.rb
testlab-1.20.4 lib/testlab/container/support.rb
testlab-1.20.3 lib/testlab/container/support.rb
testlab-1.20.2 lib/testlab/container/support.rb
testlab-1.20.1 lib/testlab/container/support.rb
testlab-1.20.0 lib/testlab/container/support.rb
testlab-1.19.0 lib/testlab/container/support.rb
testlab-1.18.1 lib/testlab/container/support.rb
testlab-1.18.0 lib/testlab/container/support.rb
testlab-1.17.0 lib/testlab/container/support.rb
testlab-1.16.1 lib/testlab/container/support.rb
testlab-1.16.0 lib/testlab/container/support.rb