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, #foreman_certificate

Methods included from CandlepinCache

#candlepin_id_cert, #cp_owner_id, #upstream_owner

Methods included from ForemanRhCloud::CloudRequest

#execute_cloud_request

Instance Method Details

#loggerObject



58
59
60
# File 'lib/insights_cloud/async/insights_full_sync.rb', line 58

def logger
  action_logger
end

#perform_hits_sync(organization) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/insights_cloud/async/insights_full_sync.rb', line 49

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
31
32
33
34
# File 'lib/insights_cloud/async/insights_full_sync.rb', line 10

def plan(organizations)
  organizations = organizations.select do |organization|
    checker = ::Katello::UpstreamConnectionChecker.new(organization)
    if cert_auth_available?(organization) && !organization.manifest_expired? && checker.can_connect?
      true
    else
      logger.info("A manifest is not available for org: #{organization.name}, or it has expired, or been deleted. 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
    valid_organizations = organizations.reject(&:manifest_expired?)
    if valid_organizations.any?
      plan_hosts_sync(organizations)
      plan_self(organization_ids: organizations.map(&:id))
      concurrence do
        plan_rules_sync(organizations)
        plan_notifications
      end
    end
  end
end

#try_executeObject



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/insights_cloud/async/insights_full_sync.rb', line 36

def try_execute
  organizations.each do |organization|
    checker = ::Katello::UpstreamConnectionChecker.new(organization)
    if !cert_auth_available?(organization) && organization.manifest_expired && !checker.can_connect?
      logger.info("A manifest is not available for org: #{organization.name}, or it has expired, or been deleted. skipping insights sync")
      next
    end

    perform_hits_sync(organization)
  end
  done!
end