Sha256: 6bd8e0dab796eade076e17b12e448698151d5426bb7c3b692c74194ab1416a18

Contents?: true

Size: 1.68 KB

Versions: 12

Compression:

Stored size: 1.68 KB

Contents

class TestLab
  class Node

    module Lifecycle

      # 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

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

        end

        true
      end

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

        (self.state == :not_created) and return false

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

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

        end

        true
      end

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

        true
      end

      # Returns all defined provisioners for this node and it's networks and containers.
      def all_provisioners
        [self.provisioners, self.networks.map(&:provisioners), self.containers.map(&:provisioners)].flatten.compact.uniq
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
testlab-0.7.6 lib/testlab/node/lifecycle.rb
testlab-0.7.5 lib/testlab/node/lifecycle.rb
testlab-0.7.4 lib/testlab/node/lifecycle.rb
testlab-0.7.3 lib/testlab/node/lifecycle.rb
testlab-0.7.2 lib/testlab/node/lifecycle.rb
testlab-0.7.1 lib/testlab/node/lifecycle.rb
testlab-0.7.0 lib/testlab/node/lifecycle.rb
testlab-0.6.17 lib/testlab/node/lifecycle.rb
testlab-0.6.16 lib/testlab/node/lifecycle.rb
testlab-0.6.15 lib/testlab/node/lifecycle.rb
testlab-0.6.14 lib/testlab/node/lifecycle.rb
testlab-0.6.12 lib/testlab/node/lifecycle.rb