Project

General

Profile

« Previous | Next » 

Revision 35c14172

Added by Ivan Necas over 7 years ago

Refs #15779 - make background processing unavailable for now (#4217)

The original PR got vetted in the packaging phase and including
foreman-task as dependency of Foreman was refused. We need to rethink
our approach for getting the foreman-tasks functionality available
inside the core and take less obtrusive approach by making the
transition in several steps, until the foreman core will get on
future-parity with foreman-tasks which would effectively mean tasks in
core.

To clean the tasks that were created while using the original changes,
you can run:

rake foreman_tasks:cleanup\
TASK_SEARCH="label = Actions::Foreman::Report::Import
OR label = Actions::Foreman::PuppetClass::Import"\
VERBOSE=true

This reverts commits

eb371ca33dcdd7a4f71d3cda0cfcad701cd3ae7e,
69c34cd691aea4c7f21613f3859ae92a5f403529,
3a1cd1dbeb74c60a482d7c47fc290c185d7c707a,
0cf8ea6780c24954ccbe2cc33ca02e1f6010ffed,
1538b8d2addb12f04da36a2c34224cd821e77acc,
33709ef2813d0128f64905c6597616f44abad28e.

View differences:

app/controllers/concerns/api/import_puppetclasses_common_controller.rb
param :smart_proxy_id, String, :required => false
param :environment_id, String, :required => false
param :dryrun, :bool, :required => false
param :background, :bool, :required => false
param :except, String, :required => false, :desc => N_("Optional comma-delimited string containing either 'new', 'updated', or 'obsolete' that is used to limit the imported Puppet classes")
def import_puppetclasses
......
end
# RUN PuppetClassImporter
background = params.key?(:background) && !['false', false].include?(params[:background])
begin
task = ForemanTasks.trigger_task(background, ::Actions::Foreman::PuppetClass::Import, :changed => @changed)
if background
process_success task
else
render("api/v#{api_version}/import_puppetclasses/#{rabl_template}", :layout => "api/layouts/import_puppetclasses_layout")
end
rescue ForemanTasks::TaskError => e
render :json => { :message => _("Failed to update the environments and Puppet classes from the on-disk puppet installation: %s") % e.to_s }, :status => :internal_server_error
if (errors = ::PuppetClassImporter.new.obsolete_and_new(@changed)).empty?
render("api/v#{api_version}/import_puppetclasses/#{rabl_template}", :layout => "api/layouts/import_puppetclasses_layout")
else
render :json => {:message => _("Failed to update the environments and Puppet classes from the on-disk puppet installation: %s") % errors.join(", ")}, :status => :internal_server_error
end
end

Also available in: Unified diff