Class: InventorySync::Async::InventoryHostsSync

Inherits:
QueryInventoryJob
  • Object
show all
Defined in:
lib/inventory_sync/async/inventory_hosts_sync.rb

Direct Known Subclasses

InventoryFullSync

Constant Summary collapse

MAX_IP_STRING_SIZE =
254

Instance Method Summary collapse

Methods inherited from QueryInventoryJob

#try_execute

Methods included from ForemanRhCloud::Async::ExponentialBackoff

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

Methods included from ForemanRhCloud::CertAuth

#cert_auth_available?, #execute_cloud_request

Methods included from InsightsCloud::CandlepinCache

#candlepin_id_cert, #cp_owner_id, #upstream_owner

Methods included from ForemanRhCloud::CloudRequest

#execute_cloud_request

Instance Method Details

#create_facetsObject



22
23
24
25
26
27
# File 'lib/inventory_sync/async/inventory_hosts_sync.rb', line 22

def create_facets
  # get the results from the event
  results = yield
  add_missing_insights_facets(results.organization, results.host_uuids)
  results
end

#create_missing_hostsObject



29
30
31
32
33
34
35
36
37
38
# File 'lib/inventory_sync/async/inventory_hosts_sync.rb', line 29

def create_missing_hosts
  results = yield
  missing_hosts = results.missing_hosts.map { |host| to_missing_host_record(host, results.organization) }
  # remove records that are no longer in the query results
  InsightsMissingHost.
    where.not(insights_id: missing_hosts.map { |host_hash| host_hash[:insights_id] }).
    where(organization_id: results.organization.id).delete_all
  # readd new hosts that appear in the results, but the subscription_id is missing from the DB.
  InsightsMissingHost.upsert_all(missing_hosts) if missing_hosts.present?
end

#plan(organizations) ⇒ Object



10
11
12
13
14
# File 'lib/inventory_sync/async/inventory_hosts_sync.rb', line 10

def plan(organizations)
  # by default the tasks will be executed concurrently
  super(organizations)
  plan_self_host_sync
end

#rescue_strategy_for_selfObject



40
41
42
# File 'lib/inventory_sync/async/inventory_hosts_sync.rb', line 40

def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end

#setup_facet_transactionObject



16
17
18
19
20
# File 'lib/inventory_sync/async/inventory_hosts_sync.rb', line 16

def setup_facet_transaction
  ActiveRecord::Base.transaction do
    yield
  end
end