Module: InsightsCloud::CandlepinCache

Extended by:
ActiveSupport::Concern
Included in:
ForemanRhCloud::CertAuth, ForemanRhCloud::CloudPingService::CertPing, ForemanRhCloud::CloudPresence, Api::MachineTelemetriesController
Defined in:
app/controllers/concerns/insights_cloud/candlepin_cache.rb

Instance Method Summary collapse

Instance Method Details

#candlepin_id_cert(org) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/concerns/insights_cloud/candlepin_cache.rb', line 17

def candlepin_id_cert(org)
  owner = upstream_owner(org)
  return unless owner
  id_cert = {
    cert: owner.dig('idCert', 'cert'),
    key: owner.dig('idCert', 'key'),
  }
  return unless id_cert.values.all?
  id_cert
end

#cp_owner_id(org) ⇒ Object



12
13
14
15
# File 'app/controllers/concerns/insights_cloud/candlepin_cache.rb', line 12

def cp_owner_id(org)
  owner = upstream_owner(org)
  owner['uuid'] if owner
end

#upstream_owner(org) ⇒ Object



5
6
7
8
9
10
# File 'app/controllers/concerns/insights_cloud/candlepin_cache.rb', line 5

def upstream_owner(org)
  # We use a cache because owner_details is a call to Candlepin
  Rails.cache.fetch("rh_cloud_upstream_owner_#{org.id}", expires_in: 1.minute) do
    org.owner_details['upstreamConsumer']
  end
end