Module: InventoryUpload::TaskActions

Extended by:
ActiveSupport::Concern
Included in:
Api::V2::RhCloud::InventoryController, ForemanInventoryUpload::TasksController
Defined in:
app/controllers/concerns/inventory_upload/task_actions.rb

Defined Under Namespace

Classes: NothingToSyncError

Instance Method Summary collapse

Instance Method Details

#start_inventory_sync(selected_org) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/concerns/inventory_upload/task_actions.rb', line 13

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