Sha256: 93506bd4a33f72d84f1d5e2ce928a787686b1584067a304c5229097f953c74d9

Contents?: true

Size: 690 Bytes

Versions: 74

Compression:

Stored size: 690 Bytes

Contents

module InventoryUpload
  module TaskActions
    extend ActiveSupport::Concern

    class NothingToSyncError < Foreman::Exception
      MESSAGE = N_('Nothing to sync, there are no hosts with subscription for this organization.')

      def initialize(**params)
        super(self.class::MESSAGE, params)
      end
    end

    def start_inventory_sync(selected_org)
      subscribed_hosts = ForemanInventoryUpload::Generators::Queries.for_slice(
        Host.unscoped.where(organization: selected_org)
      )

      if subscribed_hosts.empty?
        raise NothingToSyncError
      end

      ForemanTasks.async_task(InventorySync::Async::InventoryFullSync, selected_org)
    end
  end
end

Version data entries

74 entries across 74 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.28 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-5.0.28 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-4.0.27 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-3.0.26 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-4.0.26 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-4.0.25.1 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-3.0.25 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-4.0.25 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-3.0.24.1 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-4.0.24.1 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-3.0.24 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-4.0.24 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-3.0.23 app/controllers/concerns/inventory_upload/task_actions.rb
foreman_rh_cloud-4.0.23 app/controllers/concerns/inventory_upload/task_actions.rb