Sha256: 1e2788cbe41150df22624dff1773917564b803cb957c754d5cf3d34112fcbfc1

Contents?: true

Size: 1.49 KB

Versions: 30

Compression:

Stored size: 1.49 KB

Contents

module Actions
  module Middleware
    class BackendServicesCheck < Dynflow::Middleware
      def plan(*args)
        if Setting[:check_services_before_actions]
          #To prevent the ping from happening multiple times, keep track on the initial entry action
          #If capsule_id is passed as in args from an action, Katello::Ping checks the pulp server on the capsule
          parent = source_action
          parent.input[:services_checked] ||= []
          to_check = services - parent.input[:services_checked]

          if to_check.any?
            result = User.as_anonymous_admin { ::Katello::Ping.ping(services: to_check, capsule_id: capsule_id(args))[:services] }

            to_check.each do |service|
              if result[service][:status] != ::Katello::Ping::OK_RETURN_CODE
                fail _("There was an issue with the backend service %s: ") % service + result[service][:message]
              end
            end
            parent.input[:services_checked].concat(to_check)
          end
        end
        pass(*args)
      end

      protected

      def capsule_id(args)
        capsule_hash = args.select { |x| x[:capsule_id] if x.is_a? Hash }
        capsule_hash[0] ? capsule_hash[0][:capsule_id] : nil
      end

      def source_action
        parent = self.action
        until parent.trigger.nil?
          parent = parent.trigger
        end
        parent
      end

      def services
        fail _("No services defined, is this class extended?")
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
katello-3.3.2 app/lib/actions/middleware/backend_services_check.rb
katello-3.4.0.rc2 app/lib/actions/middleware/backend_services_check.rb
katello-3.4.0.rc1 app/lib/actions/middleware/backend_services_check.rb
katello-3.3.1.1 app/lib/actions/middleware/backend_services_check.rb
katello-3.3.1 app/lib/actions/middleware/backend_services_check.rb
katello-3.3.0.1 app/lib/actions/middleware/backend_services_check.rb
katello-3.3.0 app/lib/actions/middleware/backend_services_check.rb
katello-3.3.0.rc2 app/lib/actions/middleware/backend_services_check.rb
katello-3.3.0.rc1.1 app/lib/actions/middleware/backend_services_check.rb
katello-3.3.0.rc1 app/lib/actions/middleware/backend_services_check.rb
katello-3.2.1.1 app/lib/actions/middleware/backend_services_check.rb
katello-3.2.1 app/lib/actions/middleware/backend_services_check.rb
katello-3.2.0 app/lib/actions/middleware/backend_services_check.rb
katello-3.2.0.rc3 app/lib/actions/middleware/backend_services_check.rb
katello-3.2.0.rc2 app/lib/actions/middleware/backend_services_check.rb
katello-3.2.0.rc1.1 app/lib/actions/middleware/backend_services_check.rb
katello-3.2.0.rc1 app/lib/actions/middleware/backend_services_check.rb
katello-3.1.0.1 app/lib/actions/middleware/backend_services_check.rb
katello-3.1.0 app/lib/actions/middleware/backend_services_check.rb
katello-3.1.0.rc2.1 app/lib/actions/middleware/backend_services_check.rb