class InventorySync::Async::InventoryHostsSync

Public Instance Methods

create_facets() { || ... } click to toggle source
# File lib/inventory_sync/async/inventory_hosts_sync.rb, line 24
def create_facets
  # get the results from the event
  results = yield
  add_missing_insights_facets(results.host_uuids)
  results
end
plan() click to toggle source
# File lib/inventory_sync/async/inventory_hosts_sync.rb, line 7
def plan
  unless cloud_auth_available?
    logger.debug('Cloud authentication is not available, skipping inventory hosts sync')
    return
  end

  # by default the tasks will be executed concurrently
  plan_self
  plan_self_host_sync
end
rescue_strategy_for_self() click to toggle source
# File lib/inventory_sync/async/inventory_hosts_sync.rb, line 31
def rescue_strategy_for_self
  Dynflow::Action::Rescue::Fail
end
setup_facet_transaction() { || ... } click to toggle source
# File lib/inventory_sync/async/inventory_hosts_sync.rb, line 18
def setup_facet_transaction
  InsightsFacet.transaction do
    yield
  end
end

Private Instance Methods

add_missing_insights_facets(uuids_hash) click to toggle source
# File lib/inventory_sync/async/inventory_hosts_sync.rb, line 37
def add_missing_insights_facets(uuids_hash)
  all_facets = uuids_hash.map do |host_id, uuid|
    {
      host_id: host_id,
      uuid: uuid,
    }
  end

  InsightsFacet.upsert_all(all_facets, unique_by: :host_id) unless all_facets.empty?
end
plan_self_host_sync() click to toggle source
# File lib/inventory_sync/async/inventory_hosts_sync.rb, line 48
def plan_self_host_sync
  plan_action InventorySync::Async::InventorySelfHostSync
end