Sha256: e5eb808ee08b94ae0ca64d61dceeddff4772d222eb2643a5c1c5797e91da96b4

Contents?: true

Size: 1.14 KB

Versions: 77

Compression:

Stored size: 1.14 KB

Contents

module Actions
  module Middleware
    class RecordSmartProxySyncHistory < Dynflow::Middleware
      def save_smart_proxy_sync_history
        if (action.input[:repository_id] && (action.input[:smart_proxy_id] || action.input[:capsule_id]) && !self.action.output[:smart_proxy_history_id])
          repo_id = action.input[:repository_id]
          repo = ::Katello::Repository.find_by(id: repo_id)
          smart_proxy_id = action.input[:smart_proxy_id] || action.input[:capsule_id]
          smart_proxy = ::SmartProxy.unscoped.find_by(id: smart_proxy_id)

          if repo && smart_proxy
            self.action.output[:smart_proxy_history_id] = repo.create_smart_proxy_sync_history(smart_proxy)
          else
            fail "Smart Proxy could not be found with id #{smart_proxy_id}" if smart_proxy.nil?
            fail "Repository could not be found with id #{repo_id}" if repo.nil?
          end
        end
      end

      def run(*args)
        begin
          save_smart_proxy_sync_history
        rescue => error
          Rails.logger.error("Error saving smart proxy history: #{error.message}")
        end
        pass(*args)
      end
    end
  end
end

Version data entries

77 entries across 77 versions & 1 rubygems

Version Path
katello-4.16.0 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.15.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.16.0.rc2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.16.0.rc1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.14.3 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.14.2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.15.0 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.15.0.rc2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.15.0.rc1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.14.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.14.0 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.14.0.rc3 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.14.0.rc2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.14.0.rc1.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.14.0.rc1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.13.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.13.0 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.12.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.13.0.rc1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.12.0 app/lib/actions/middleware/record_smart_proxy_sync_history.rb