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
- #clear_inventory_statuses_for_hosts_with_insights_false ⇒ Object
- #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
#clear_inventory_statuses_for_hosts_with_insights_false ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/inventory_sync/async/inventory_full_sync.rb', line 31 def clear_inventory_statuses_for_hosts_with_insights_false host_ids_to_delete = Host.joins(:host_parameters).where(id: InventorySync::InventoryStatus.select(:host_id), host_parameters: { name: 'host_registration_insights', value: false }) if host_ids_to_delete.present? InventorySync::InventoryStatus.where(host_id: host_ids_to_delete).delete_all Host.where(id: host_ids_to_delete).find_each(&:refresh_global_status!) else logger.debug('No hosts with host_registration_insights set to false found') end end |
#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 |
# 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
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 |