Class: ForemanRhCloud::CloudPingService::CertPing

Inherits:
Object
  • Object
show all
Includes:
ForemanRhCloud::CloudRequest, InsightsCloud::CandlepinCache
Defined in:
app/services/foreman_rh_cloud/cloud_ping_service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InsightsCloud::CandlepinCache

#candlepin_id_cert, #cp_owner_id, #upstream_owner

Methods included from ForemanRhCloud::CloudRequest

#execute_cloud_request

Constructor Details

#initialize(org, logger) ⇒ CertPing

Returns a new instance of CertPing.



11
12
13
14
# File 'app/services/foreman_rh_cloud/cloud_ping_service.rb', line 11

def initialize(org, logger)
  @org = org
  @logger = logger
end

Instance Attribute Details

#loggerObject

Returns the value of attribute logger.



9
10
11
# File 'app/services/foreman_rh_cloud/cloud_ping_service.rb', line 9

def logger
  @logger
end

Instance Method Details

#pingObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/services/foreman_rh_cloud/cloud_ping_service.rb', line 16

def ping
  certs = candlepin_id_cert(@org)
  return StandardError.new('certificate missing') unless certs

  cert_checker = Katello::UpstreamConnectionChecker.new(@org)
  cert_checker.assert_connection

  execute_cloud_request(
    method: :get,
    url: ForemanRhCloud.cert_base_url + "/api/apicast-tests/ping",
    headers: {
      content_type: :json,
    },
    ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
    ssl_client_key: OpenSSL::PKey.read(certs[:key])
  )
rescue StandardError => ex
  ex
end