Class: InventorySync::Async::InventoryFullSync
- Inherits:
-
InventoryHostsSync
- Object
- Actions::EntryAction
- QueryInventoryJob
- InventoryHostsSync
- InventorySync::Async::InventoryFullSync
- Defined in:
- lib/inventory_sync/async/inventory_full_sync.rb
Constant Summary
Constants inherited from InventoryHostsSync
InventorySync::Async::InventoryHostsSync::MAX_IP_STRING_SIZE
Instance Method Summary collapse
- #plan(organization) ⇒ Object
- #rescue_strategy_for_self ⇒ Object
- #setup_statuses ⇒ Object
- #update_statuses_batch ⇒ Object
Methods inherited from InventoryHostsSync
#create_facets, #create_missing_hosts, #setup_facet_transaction
Methods inherited from QueryInventoryJob
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, #foreman_certificate
Methods included from InsightsCloud::CandlepinCache
#candlepin_id_cert, #cp_owner_id, #upstream_owner
Methods included from ForemanRhCloud::CloudRequest
Instance Method Details
#plan(organization) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/inventory_sync/async/inventory_full_sync.rb', line 7 def plan(organization) unless cert_auth_available?(organization) logger.debug('Cloud authentication is not available, skipping inventory hosts sync') return end super(organization) end |
#rescue_strategy_for_self ⇒ Object
50 51 52 |
# File 'lib/inventory_sync/async/inventory_full_sync.rb', line 50 def rescue_strategy_for_self Dynflow::Action::Rescue::Fail end |
#setup_statuses ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/inventory_sync/async/inventory_full_sync.rb', line 16 def setup_statuses @subscribed_hosts_ids = Set.new(affected_host_ids) @omitted_ids = Set.new(user_omitted_host_ids) # Remove user-omitted hosts from subscribed set. In normal operation, affected_host_ids # already excludes user-omitted hosts via for_slice, but this handles edge cases like # a host transitioning from uploaded to user-omitted between syncs. @subscribed_hosts_ids.subtract(@omitted_ids) InventorySync::InventoryStatus.transaction do InventorySync::InventoryStatus.where(host_id: @subscribed_hosts_ids).delete_all InventorySync::InventoryStatus.where(host_id: @omitted_ids).delete_all yield add_missing_hosts_statuses(@subscribed_hosts_ids) # any remaining hosts after yield are disconnected add_user_omitted_host_statuses(@omitted_ids) host_statuses[:disconnect] += @subscribed_hosts_ids.size host_statuses[:user_omitted] += @omitted_ids.size end logger.debug("Synced hosts count: #{host_statuses[:sync]}") logger.debug("Disconnected hosts count: #{host_statuses[:disconnect]}") logger.debug("User-omitted hosts count: #{host_statuses[:user_omitted]}") output[:host_statuses] = host_statuses end |
#update_statuses_batch ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/inventory_sync/async/inventory_full_sync.rb', line 41 def update_statuses_batch results = yield existing_hosts = results.status_hashes.select { |hash| @subscribed_hosts_ids.include?(hash[:host_id]) } update_hosts_status(existing_hosts) host_statuses[:sync] += existing_hosts.size end |