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
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
40 41 42 |
# File 'lib/inventory_sync/async/inventory_full_sync.rb', line 40 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 |
# File 'lib/inventory_sync/async/inventory_full_sync.rb', line 16 def setup_statuses @subscribed_hosts_ids = Set.new(affected_host_ids) InventorySync::InventoryStatus.transaction do InventorySync::InventoryStatus.where(host_id: @subscribed_hosts_ids).delete_all yield add_missing_hosts_statuses(@subscribed_hosts_ids) host_statuses[:disconnect] += @subscribed_hosts_ids.size end logger.debug("Synced hosts amount: #{host_statuses[:sync]}") logger.debug("Disconnected hosts amount: #{host_statuses[:disconnect]}") output[:host_statuses] = host_statuses end |
#update_statuses_batch ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/inventory_sync/async/inventory_full_sync.rb', line 31 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 |