Sha256: bc0b3cace54ae76043299861cc1879dbce5f47b6c5cc38c04a18dd27b46b0609

Contents?: true

Size: 1.84 KB

Versions: 5

Compression:

Stored size: 1.84 KB

Contents

class TestLab

  # Network Error Class
  class NetworkError < TestLabError; end

  # Network Class
  #
  # @author Zachary Patten <zachary AT jovelabs DOT com>
  class Network < ZTK::DSL::Base
    STATUS_KEYS   = %w(id node_id state interface network netmask broadcast provisioners).map(&:to_sym)

    # Sub-Modules
    autoload :Actions,      'testlab/network/actions'
    autoload :Bind,         'testlab/network/bind'
    autoload :ClassMethods, 'testlab/network/class_methods'
    autoload :Provision,    'testlab/network/provision'
    autoload :Status,       'testlab/network/status'

    include TestLab::Network::Actions
    include TestLab::Network::Bind
    include TestLab::Network::Provision
    include TestLab::Network::Status

    extend  TestLab::Network::ClassMethods

    include TestLab::Support::Lifecycle

    include TestLab::Utility::Misc

    # Associations and Attributes
    belongs_to  :node,          :class_name => 'TestLab::Node'
    has_many    :interfaces,    :class_name => 'TestLab::Interface'

    attribute   :provisioners,  :default => Array.new
    attribute   :config,        :default => Hash.new

    attribute   :address
    attribute   :bridge

    # Execution priority; set the order in which the object should execute when
    # performing parallel operations; a higher value priority equates to more
    # precedence.  Objects with identical priority values will execute in
    # parallel.
    attribute   :priority,       :default => 0


    def initialize(*args)
      @ui = TestLab.ui

      @ui.logger.debug { "Loading Network" }
      super(*args)
      @ui.logger.debug { "Network '#{self.id}' Loaded" }
    end

    class << self

      def priority_groups
        self.all.map(&:priority).sort.uniq.reverse
      end

      def by_priority(priority)
        self.all.select{ |n| n.priority == priority }
      end

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
testlab-1.22.4 lib/testlab/network.rb
testlab-1.22.3 lib/testlab/network.rb
testlab-1.22.2 lib/testlab/network.rb
testlab-1.22.1 lib/testlab/network.rb
testlab-1.22.0 lib/testlab/network.rb