Class: InsightsCloud::Async::InsightsFullSync

Inherits:
Actions::EntryAction
  • Object
show all
Includes:
ForemanRhCloud::Async::ExponentialBackoff, ForemanRhCloud::CertAuth
Defined in:
lib/insights_cloud/async/insights_full_sync.rb

Instance Method Summary collapse

Methods included from ForemanRhCloud::Async::ExponentialBackoff

#attempts_before_next_interval, #done!, #done?, #invoke_external_task, #poll_external_task, #poll_intervals

Methods included from ForemanRhCloud::CertAuth

#cert_auth_available?, #execute_cloud_request

Methods included from CandlepinCache

#candlepin_id_cert, #cp_owner_id, #upstream_owner

Methods included from ForemanRhCloud::CloudRequest

#execute_cloud_request

Instance Method Details

#loggerObject



53
54
55
# File 'lib/insights_cloud/async/insights_full_sync.rb', line 53

def logger
  action_logger
end

#perform_hits_sync(organization) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/insights_cloud/async/insights_full_sync.rb', line 44

def perform_hits_sync(organization)
  hits = query_insights_hits(organization)

  uuids = hits.map { |hit| hit['uuid'] }
  setup_host_ids(uuids, organization)

  replace_hits_data(hits, organization)
end

#plan(organizations) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/insights_cloud/async/insights_full_sync.rb', line 10

def plan(organizations)
  organizations = organizations.select do |organization|
    if cert_auth_available?(organization)
      true
    else
      logger.debug("Certificate is not available for org: #{organization.name}, skipping insights sync")
      false
    end
  end

  sequence do
    # This can be turned off when we enable automatic status syncs
    # This step will query cloud inventory to retrieve inventory uuids for each host
    plan_hosts_sync(organizations)
    plan_self(organization_ids: organizations.map(&:id))
    concurrence do
      plan_rules_sync(organizations)
      plan_notifications
    end
  end
end

#try_executeObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/insights_cloud/async/insights_full_sync.rb', line 32

def try_execute
  organizations.each do |organization|
    unless cert_auth_available?(organization)
      logger.debug("Certificate is not available for org: #{organization.name}, skipping insights sync")
      next
    end

    perform_hits_sync(organization)
  end
  done!
end