Sha256: 2e9aa59d144fc0a2751a210d13f623c4935ebe1bf310e9ad4ffe0bfa70666e77

Contents?: true

Size: 1.66 KB

Versions: 2

Compression:

Stored size: 1.66 KB

Contents

class TestLab
  class Container

    module Lifecycle

      # Provision the container
      #
      # Attempts to provision the container.  We first create the container,
      # then attempt to bring it online.  Afterwards the containers provisioner
      # is called.
      #
      # @return [Boolean] True if successful.
      def provision
        @ui.logger.debug { "Container Provision: #{self.id} " }

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

        please_wait(:ui => @ui, :message => format_object_action(self, :provision, :green)) do
          do_provisioner_callbacks(self, :provision, @ui)
        end

        true
      end

      # Deprovision the container
      #
      # Attempts to deprovision the container.  We first call the provisioner
      # deprovision method defined for the container, if any.  Next we attempt
      # to offline the container.  Afterwards the container is destroy.
      #
      # @return [Boolean] True if successful.
      def deprovision
        @ui.logger.debug { "Container Deprovision: #{self.id} " }

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

        please_wait(:ui => @ui, :message => format_object_action(self, :deprovision, :red)) do
          do_provisioner_callbacks(self, :deprovision, @ui)
        end

        true
      end

      # Build the container
      def build
        self.create
        self.up
        self.provision

        true
      end

      # Demolish the container
      def demolish
        self.deprovision
        self.down
        self.destroy

        true
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
testlab-1.0.1 lib/testlab/container/lifecycle.rb
testlab-1.0.0 lib/testlab/container/lifecycle.rb