Sha256: 7952821abdf6acaf6cfdb1de6c13b3de1b66a197820e2fdd027b21cd9d126e50

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

require "log4r"

module VagrantPlugins
  module ManagedServers
    module Action
      class TrackDeploymentEnd
        def initialize(app, _env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_managed_servers::action::track_deployment_end")
        end

        def call(env)
          track_deployment_end(env[:tracker_host], env[:start_time], env[:success], env[:ui])
          @app.call(env)
        end

        def track_deployment_end(host, start, success, ui)
          return unless host
          @logger.debug("Tracking deployment end to #{host}.")
          id = VagrantPlugins::Orchestrate::DEPLOYMENT_ID
          ui.info("Deployment tracked in deployment-tracker with ID: #{id}")
          result = success ? "success" : "failure"
          elapsed_seconds = (Time.now - start).to_i
          deployment = { deployment_id: id,
                         result: result,
                         assert_empty_server_result: true,
                         elapsed_seconds: elapsed_seconds }
          DeploymentTrackerClient::DefaultApi.put_deployment(id, deployment)
        rescue => ex
          ui.warn("There was an error notifying deployment tracker. See error log for details.")
          @logger.warn("Error tracking deployment end for deployment #{id}")
          @logger.warn(ex)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vagrant-orchestrate-0.8.0 lib/vagrant-managed-servers/action/track_deployment_end.rb
vagrant-orchestrate-0.8.0.pre.3 lib/vagrant-managed-servers/action/track_deployment_end.rb
vagrant-orchestrate-0.8.0.pre.2 lib/vagrant-managed-servers/action/track_deployment_end.rb
vagrant-orchestrate-0.8.0.pre.1 lib/vagrant-managed-servers/action/track_deployment_end.rb
vagrant-orchestrate-0.7.2 lib/vagrant-managed-servers/action/track_deployment_end.rb
vagrant-orchestrate-0.7.1 lib/vagrant-managed-servers/action/track_deployment_end.rb
vagrant-orchestrate-0.7.0 lib/vagrant-managed-servers/action/track_deployment_end.rb