Class: AnsibleRolesController

Inherits:
ApplicationController
  • Object
show all
Includes:
Foreman::Controller::AutoCompleteSearch, ForemanAnsible::AnsibleRolesDataPreparations, ForemanAnsible::Concerns::ImportControllerHelper
Defined in:
app/controllers/ansible_roles_controller.rb

Overview

UI controller for ansible roles

Constant Summary

Constants included from ForemanAnsible::AnsibleRolesDataPreparations

ForemanAnsible::AnsibleRolesDataPreparations::ROLE_ACTION_NAMES, ForemanAnsible::AnsibleRolesDataPreparations::VARIABLE_ACTION_NAMES

Instance Method Summary collapse

Methods included from ForemanAnsible::AnsibleRolesDataPreparations

#excluded_roles, #get_old_roles_variables, #get_roles_variables, #prepare_ansible_import_rows, #prepare_api_row, #prepare_ui_row, #role_action_name, #role_match_excluded_roles, #variable_action_name, #variables_to_s

Methods included from ForemanAnsible::Concerns::ImportControllerHelper

#find_proxy

Instance Method Details

#confirm_importObject



34
35
36
37
38
39
40
# File 'app/controllers/ansible_roles_controller.rb', line 34

def confirm_import
  job = SyncRolesAndVariables.perform_later(params['changed'].to_unsafe_h, @proxy)
  task = ForemanTasks::Task.find_by(external_id: job.provider_job_id)
  render json: {
    task: task
  }, status: :ok
end

#destroyObject



15
16
17
18
19
20
21
# File 'app/controllers/ansible_roles_controller.rb', line 15

def destroy
  if @ansible_role.destroy
    process_success
  else
    process_error
  end
end

#importObject



23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/ansible_roles_controller.rb', line 23

def import
  changed = @importer.import!
  @rows = prepare_ansible_import_rows(changed, @variables_importer)
  if @rows.empty?
    success no_changed_roles_message
    redirect_to ansible_roles_path
  else
    render
  end
end

#indexObject



8
9
10
11
12
13
# File 'app/controllers/ansible_roles_controller.rb', line 8

def index
  @ansible_roles = resource_base.search_for(params[:search],
                                            :order => params[:order]).
                   paginate(:page => params[:page],
                            :per_page => params[:per_page])
end