Sha256: 425377bab0a80465ba93a913bed83a52b573869d571e74b471dcc9b73dc261aa

Contents?: true

Size: 1.94 KB

Versions: 6

Compression:

Stored size: 1.94 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).to_i
      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.labfile.config[: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

6 entries across 6 versions & 1 rubygems

Version Path
testlab-0.6.5 lib/testlab/container/status.rb
testlab-0.6.4 lib/testlab/container/status.rb
testlab-0.6.3 lib/testlab/container/status.rb
testlab-0.6.2 lib/testlab/container/status.rb
testlab-0.6.1 lib/testlab/container/status.rb
testlab-0.6.0 lib/testlab/container/status.rb