Sha256: a128be1b940af5e1aa4693ff2409fee1fbe838e6156b0df3fd8611a54db72c36

Contents?: true

Size: 1.01 KB

Versions: 41

Compression:

Stored size: 1.01 KB

Contents

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

      def plan
        super(ForemanRhCloud.foreman_host.organization)
      end

      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

      def rescue_strategy_for_self
        Dynflow::Action::Rescue::Fail
      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

      def action_name
        'self host sync'
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
foreman_rh_cloud-9.0.59 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-11.0.2 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-11.0.1 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-11.0.0 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-9.0.58 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-10.0.2 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-9.0.57 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-10.0.1 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-9.0.56 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-9.0.55 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-9.0.54 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-9.0.53 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-9.0.52 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-8.0.52 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-9.0.51 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-8.0.51 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-7.0.48 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-7.0.47 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-8.0.50 lib/inventory_sync/async/inventory_self_host_sync.rb
foreman_rh_cloud-8.0.49 lib/inventory_sync/async/inventory_self_host_sync.rb