Sha256: cacf23c5f1e1218206421331642ed453c87affabd7514e876e5d79a107bf3d34

Contents?: true

Size: 811 Bytes

Versions: 4

Compression:

Stored size: 811 Bytes

Contents

module InventorySync
  module Async
    class InventorySelfHostSync < QueryInventoryJob
      set_callback :step, :around, :create_facets

      def create_facets
        # get the results from the event
        results = yield

        add_missing_insights_facet(results.uuid_by_fqdn) unless results.uuid_by_fqdn.empty?
        results
      end

      private

      def add_missing_insights_facet(uuids_hash)
        facet = InsightsFacet.find_or_create_by(host_id: ForemanRhCloud.foreman_host.id) do |facet|
          facet.uuid = uuids_hash.values.first
        end

        # fix empty uuid in case the facet already exists
        facet.update(uuid: uuids_hash.values.first) unless facet.uuid
      end

      def request_url
        ForemanInventoryUpload.inventory_self_url
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.24.1 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-4.0.24.1 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-3.0.24 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-4.0.24 lib/inventory_sync/async/inventory_self_host_sync.rb