diff --git a/app/controllers/api/v2/rh_cloud/inventory_controller.rb b/app/controllers/api/v2/rh_cloud/inventory_controller.rb index 31563c9b..9df6c731 100644 --- a/app/controllers/api/v2/rh_cloud/inventory_controller.rb +++ b/app/controllers/api/v2/rh_cloud/inventory_controller.rb @@ -18,10 +18,12 @@ def download_file api :POST, "/organizations/:organization_id/rh_cloud/report", N_("Start report generation") param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request") + param :disconnected, :bool, required: false, desc: N_('Generate the report, but do not upload') def generate_report organization_id = params[:organization_id] + disconnected = params[:disconnected] - start_report_generation(organization_id) + start_report_generation(organization_id, disconnected) render json: { action_status: 'success', diff --git a/app/controllers/concerns/inventory_upload/report_actions.rb b/app/controllers/concerns/inventory_upload/report_actions.rb index e40dd367..c8bb8e0a 100644 --- a/app/controllers/concerns/inventory_upload/report_actions.rb +++ b/app/controllers/concerns/inventory_upload/report_actions.rb @@ -10,8 +10,8 @@ def initialize(**params) end end - def start_report_generation(organization_id) - ForemanTasks.async_task(ForemanInventoryUpload::Async::GenerateReportJob, ForemanInventoryUpload.generated_reports_folder, organization_id) + def start_report_generation(organization_id, disconnected) + ForemanTasks.async_task(ForemanInventoryUpload::Async::GenerateReportJob, ForemanInventoryUpload.generated_reports_folder, organization_id, disconnected) end def report_file(organization_id) diff --git a/app/controllers/foreman_inventory_upload/reports_controller.rb b/app/controllers/foreman_inventory_upload/reports_controller.rb index 20bc72e6..37d7e35e 100644 --- a/app/controllers/foreman_inventory_upload/reports_controller.rb +++ b/app/controllers/foreman_inventory_upload/reports_controller.rb @@ -21,8 +21,9 @@ def last def generate organization_id = params[:organization_id] + disconnected = params[:disconnected] - start_report_generation(organization_id) + start_report_generation(organization_id, disconnected) render json: { action_status: 'success', diff --git a/lib/foreman_inventory_upload/async/generate_report_job.rb b/lib/foreman_inventory_upload/async/generate_report_job.rb index b0bef3fc..8fe3c4c5 100644 --- a/lib/foreman_inventory_upload/async/generate_report_job.rb +++ b/lib/foreman_inventory_upload/async/generate_report_job.rb @@ -5,7 +5,7 @@ def self.output_label(label) "report_for_#{label}" end - def plan(base_folder, organization_id) + def plan(base_folder, organization_id, disconnected) sequence do super( GenerateReportJob.output_label(organization_id), diff --git a/lib/foreman_inventory_upload/async/queue_for_upload_job.rb b/lib/foreman_inventory_upload/async/queue_for_upload_job.rb index 2bbbf63d..96e9d5be 100644 --- a/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +++ b/lib/foreman_inventory_upload/async/queue_for_upload_job.rb @@ -1,9 +1,9 @@ module ForemanInventoryUpload module Async class QueueForUploadJob < ::Actions::EntryAction - def plan(base_folder, report_file, organization_id) + def plan(base_folder, report_file, organization_id, disconnected) enqueue_task = plan_self(base_folder: base_folder, report_file: report_file) - plan_upload_report(enqueue_task.output[:enqueued_file_name], organization_id) + plan_upload_report(enqueue_task.output[:enqueued_file_name], organization_id) unless disconnected end def run