Sha256: 709ab75492da1f759eba93af8a75c89f1a43e07c59403351e28cdd8d4af41dc5

Contents?: true

Size: 1.76 KB

Versions: 12

Compression:

Stored size: 1.76 KB

Contents

module SimpleDeploy
  class Stack
    class Deployment
      class Status

        def initialize(args)
          @config   = args[:config]
          @stack    = args[:stack]
          @ssh_user = args[:ssh_user]
          @name     = args[:name]
          @logger   = @config.logger
        end

        def clear_for_deployment?
          !deployment_in_progress?
        end

        def clear_deployment_lock(force=false)
          if deployment_in_progress? && force
            @logger.info "Forcing. Clearing deployment status."
            unset_deployment_in_progress
          end
        end

        def deployment_in_progress?
          @logger.debug "Checking deployment status for #{@name}."
          if attributes['deployment_in_progress'] == 'true'
            @logger.info "Deployment in progress for #{@name}."
            @logger.info "Started by #{attributes['deployment_user']}@#{attributes['deployment_datetime']}."
            true
          else
            @logger.debug "No other deployments in progress for #{@name}."
            false
          end
        end

        def set_deployment_in_progress
          @logger.debug "Setting deployment in progress by #{@ssh_user} for #{@name}."
          @stack.update :attributes => [ { 'deployment_in_progress' => 'true',
                                           'deployment_user'        => @ssh_user,
                                           'deployment_datetime'    => Time.now.to_s } ]
        end

        def unset_deployment_in_progress
          @logger.debug "Clearing deployment in progress for #{@name}."
          @stack.update :attributes => [ { 'deployment_in_progress' => 'false' } ]
        end

        private

        def attributes
          @stack.attributes
        end

      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
simple_deploy-0.7.2 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.7.2.beta.1 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.7.1 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.7.0 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.6.7 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.6.6 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.6.5 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.6.4 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.6.3 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.6.2 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.6.1 lib/simple_deploy/stack/deployment/status.rb
simple_deploy-0.6.0 lib/simple_deploy/stack/deployment/status.rb