Sha256: 92f97d5bf564a5b6db10ca7e378dfc1ac650e7d79401095f334aa6bb60ce69a2

Contents?: true

Size: 1.04 KB

Versions: 58

Compression:

Stored size: 1.04 KB

Contents

module Katello
  class UpstreamConnectionChecker
    POSSIBLE_EXCEPTIONS = [
      Katello::Errors::DisconnectedMode,
      Katello::Errors::ManifestExpired,
      Katello::Errors::UpstreamConsumerGone,
      Katello::Errors::NoManifestImported
    ].freeze

    def initialize(organization)
      @organization = organization
    end

    def can_connect?
      assert_connection
    rescue StandardError => e
      if POSSIBLE_EXCEPTIONS.include?(e.class)
        false
      else
        raise e
      end
    end

    def assert_connection
      assert_connected
      assert_unexpired_manifest
      assert_can_upstream_ping

      true
    end

    private

    def assert_connected
      fail Katello::Errors::DisconnectedMode if Setting[:content_disconnected]
    end

    def assert_can_upstream_ping
      ::Organization.as_org(@organization) do
        Katello::Resources::Candlepin::UpstreamConsumer.ping
      end
    end

    def assert_unexpired_manifest
      fail Katello::Errors::ManifestExpired if @organization.manifest_expired?
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
katello-3.17.1 app/services/katello/upstream_connection_checker.rb
katello-3.16.2 app/services/katello/upstream_connection_checker.rb
katello-3.18.0.rc2.1 app/services/katello/upstream_connection_checker.rb
katello-3.18.0.rc2 app/services/katello/upstream_connection_checker.rb
katello-3.17.0 app/services/katello/upstream_connection_checker.rb
katello-3.18.0.rc1 app/services/katello/upstream_connection_checker.rb
katello-3.17.0.rc2.2 app/services/katello/upstream_connection_checker.rb
katello-3.17.0.rc2.1 app/services/katello/upstream_connection_checker.rb
katello-3.16.1.2 app/services/katello/upstream_connection_checker.rb
katello-3.16.1.1 app/services/katello/upstream_connection_checker.rb
katello-3.17.0.rc2 app/services/katello/upstream_connection_checker.rb
katello-3.16.1 app/services/katello/upstream_connection_checker.rb
katello-3.17.0.rc1 app/services/katello/upstream_connection_checker.rb
katello-3.16.0 app/services/katello/upstream_connection_checker.rb
katello-3.16.0.rc5.1 app/services/katello/upstream_connection_checker.rb
katello-3.16.0.rc5 app/services/katello/upstream_connection_checker.rb
katello-3.16.0.rc4.1 app/services/katello/upstream_connection_checker.rb
katello-3.16.0.rc4 app/services/katello/upstream_connection_checker.rb