Class: SyncRolesAndVariables

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/sync_roles_and_variables.rb

Instance Method Summary collapse

Instance Method Details

#humanized_nameObject



17
18
19
# File 'app/jobs/sync_roles_and_variables.rb', line 17

def humanized_name
  _('Import roles And Variables')
end

#perform(changed, proxy) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/jobs/sync_roles_and_variables.rb', line 4

def perform(changed, proxy)
  roles_importer = ForemanAnsible::UiRolesImporter.new(proxy)
  variables_importer = ForemanAnsible::VariablesImporter.new(proxy)
  roles_importer.finish_import(changed)
  variables_importer.import_variables_roles(changed) if changed['new'] || changed['old']
  task = ForemanTasks::Task.where(:external_id => @provider_job_id)[0]
  ForemanAnsible::ImportRolesAndVariablesSuccessNotification.deliver!(task)
rescue StandardError => e
  task = ForemanTasks::Task.where(:external_id => @provider_job_id)[0]
  notification = ForemanAnsible::ImportRolesAndVariablesErrorNotification.new(e, task)
  notification.deliver!
end