Sha256: e6a353cd48c89a4e7bd49db044f17ec28ca4b59d6a001a91e1e2070680991eb8

Contents?: true

Size: 1.92 KB

Versions: 4

Compression:

Stored size: 1.92 KB

Contents

class TestLab
  class Container

    module Status

      # Container IP
      #
      # Returns the IP of the container.
      #
      # @return [String] The containers IP address.
      def ip
        TestLab::Utility.ip(self.primary_interface.address)
      end

      # Container CIDR
      #
      # Returns the CIDR of the container.
      #
      # @return [Integer] The containers CIDR address.
      def cidr
        TestLab::Utility.cidr(self.primary_interface.address)
      end

      # Container BIND PTR Record
      #
      # Returns a BIND reverse-DNS PTR record.
      #
      # @return [String] The containers ARPA PTR record.
      def ptr
        TestLab::Utility.ptr(self.primary_interface.address)
      end

      # Container FQDN
      #
      # Returns the FQDN for the container.
      #
      # @return [String] The containers FQDN.
      def fqdn
        self.domain ||= self.node.domain

        [self.id, self.domain].join('.')
      end

      # Container Status
      #
      # Returns a hash of status information for the container.
      #
      # @return [Hash] A hash of status information for the container.
      def status
        interfaces = self.interfaces.collect do |interface|
          "#{interface.network_id}:#{interface.name}:#{interface.ip}/#{interface.cidr}"
        end.join(', ')

        {
          :id => self.id,
          :clone => self.lxc_clone.exists?,
          :fqdn => self.fqdn,
          :state => self.state,
          :distro => self.distro,
          :release => self.release,
          :interfaces => interfaces,
          :provisioners => self.provisioners.map(&:to_s).collect{ |p| p.split('::').last }.join(','),
          :node_id => self.node.id
        }
      end

      # Container State
      #
      # What state the container is in.
      #
      # @return [Symbol] A symbol indicating the state of the container.
      def state
        self.lxc.state
      end

    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
testlab-1.2.0 lib/testlab/container/status.rb
testlab-1.1.0 lib/testlab/container/status.rb
testlab-1.0.1 lib/testlab/container/status.rb
testlab-1.0.0 lib/testlab/container/status.rb