Sha256: 1b7f7d04eed5d31a0eaa72ff483dc27b79b7389585747fcae24a5f45713529f5

Contents?: true

Size: 1.67 KB

Versions: 13

Compression:

Stored size: 1.67 KB

Contents

class TestLab
  class Node

    module Lifecycle

      # Iterates an array of arrays calling the specified method on all the
      # collections of objects
      def call_collections(collections, method_name)
        collections.each do |collection|
          call_methods(collection, method_name)
        end
      end

      # Calls the specified method on all the objects supplied
      def call_methods(objects, method_name)
        objects.each do |object|
          if object.respond_to?(method_name)
            object.send(method_name)
          end
        end
      end

      # Bootstrap the node
      def node_setup
        node_setup_template = File.join(self.class.template_dir, 'node-setup.erb')
        self.ssh.bootstrap(ZTK::Template.render(node_setup_template))
      end

      # Setup the node.
      def setup
        @ui.logger.debug { "Node Setup: #{self.id} " }

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

          node_setup

          if self.components.include?('resolv')
            build_resolv_conf
          end

          if self.components.include?('bind')
            bind_setup
          end
        end

        call_collections([self.networks, self.containers], :setup)

        if self.components.include?('bind')
          bind_reload
        end

        true
      end

      # Teardown the node.
      def teardown
        @ui.logger.debug { "Node Teardown: #{self.id} " }

        call_collections([self.containers, self.networks], :teardown)

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

        true
      end

    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
testlab-0.4.13 lib/testlab/node/lifecycle.rb
testlab-0.4.12 lib/testlab/node/lifecycle.rb
testlab-0.4.11 lib/testlab/node/lifecycle.rb
testlab-0.4.10 lib/testlab/node/lifecycle.rb
testlab-0.4.9 lib/testlab/node/lifecycle.rb
testlab-0.4.8 lib/testlab/node/lifecycle.rb
testlab-0.4.7 lib/testlab/node/lifecycle.rb
testlab-0.4.6 lib/testlab/node/lifecycle.rb
testlab-0.4.5 lib/testlab/node/lifecycle.rb
testlab-0.4.4 lib/testlab/node/lifecycle.rb
testlab-0.4.3 lib/testlab/node/lifecycle.rb
testlab-0.4.2 lib/testlab/node/lifecycle.rb
testlab-0.4.1 lib/testlab/node/lifecycle.rb