Sha256: b57a0e6a293fd81242baf31dbefb6bff544860c8794e59017c0612fc7e393ab0

Contents?: true

Size: 1.13 KB

Versions: 18

Compression:

Stored size: 1.13 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.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

18 entries across 18 versions & 1 rubygems

Version Path
katello-4.2.2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.2.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.2.0.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.4 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.2.0.1.rc3 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.2.0.1.rc2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.2.0.rc2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.3 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.2.0.rc1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.2.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.0 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.0.rc2.2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.0.rc2.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.0.rc2 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.0.rc1.1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb
katello-4.1.0.rc1 app/lib/actions/middleware/record_smart_proxy_sync_history.rb