Sha256: 2d703bad24f3e781824c3e3aa1b37c182892ea1f5b889e237a3315d26df9c000

Contents?: true

Size: 1.84 KB

Versions: 11

Compression:

Stored size: 1.84 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,
          :fqdn => self.fqdn,
          :state => self.state,
          :distro => self.distro,
          :release => self.release,
          :interfaces => interfaces,
          :provisioner => self.provisioner,
          :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

11 entries across 11 versions & 1 rubygems

Version Path
testlab-0.4.8 lib/testlab/container/status.rb
testlab-0.4.7 lib/testlab/container/status.rb
testlab-0.4.6 lib/testlab/container/status.rb
testlab-0.4.5 lib/testlab/container/status.rb
testlab-0.4.4 lib/testlab/container/status.rb
testlab-0.4.3 lib/testlab/container/status.rb
testlab-0.4.2 lib/testlab/container/status.rb
testlab-0.4.1 lib/testlab/container/status.rb
testlab-0.4.0 lib/testlab/container/status.rb
testlab-0.3.1 lib/testlab/container/status.rb
testlab-0.3.0 lib/testlab/container/status.rb