Sha256: 894f9c6c06434a0752b5a564e1c41c5b46ee250be5e086a85eaf593da48002e9

Contents?: true

Size: 1.79 KB

Versions: 6

Compression:

Stored size: 1.79 KB

Contents

class TestLab
  class Network

    module Lifecycle

      # Network Setup
      def setup
        @ui.logger.debug { "Network Setup: #{self.id} " }

        (self.node.state != :running) and return false
        (self.state == :not_created) and return false

        please_wait(:ui => @ui, :message => format_object_action(self, 'Setup', :green)) do

          self.network_provisioners.each do |provisioner|
            @ui.logger.info { ">>>>> NETWORK PROVISIONER SETUP: #{provisioner} <<<<<" }
            p = provisioner.new(self.config, @ui)
            p.respond_to?(:on_network_setup) and p.on_network_setup(self)
          end

        end

        true
      end

      # Network Teardown
      def teardown
        @ui.logger.debug { "Network Teardown: #{self.id} " }

        (self.node.state != :running) and return false
        (self.state == :not_created) and return false

        please_wait(:ui => @ui, :message => format_object_action(self, 'Teardown', :red)) do

          self.network_provisioners.each do |provisioner|
            @ui.logger.info { ">>>>> NETWORK PROVISIONER TEARDOWN: #{provisioner} <<<<<" }
            p = provisioner.new(self.config, @ui)
            p.respond_to?(:on_network_teardown) and p.on_network_teardown(self)
          end

        end

        true
      end

      # Build the network
      def build
        self.create
        self.up
        self.setup

        true
      end

      # Demolish the network
      def demolish
        self.teardown
        self.down
        self.destroy

        true
      end

      # Returns all defined provisioners for this network's containers and the network iteself.
      def network_provisioners
        [self.provisioners, self.interfaces.map(&:container).map(&:provisioners)].flatten.compact.uniq
      end

    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
testlab-0.8.5 lib/testlab/network/lifecycle.rb
testlab-0.8.4 lib/testlab/network/lifecycle.rb
testlab-0.8.3 lib/testlab/network/lifecycle.rb
testlab-0.8.2 lib/testlab/network/lifecycle.rb
testlab-0.8.1 lib/testlab/network/lifecycle.rb
testlab-0.8.0 lib/testlab/network/lifecycle.rb