Class: AnsibleVariablesController

Inherits:
LookupKeysController
  • Object
show all
Includes:
Foreman::Controller::AutoCompleteSearch, Foreman::Controller::Parameters::AnsibleVariable, ForemanAnsible::Concerns::ImportControllerHelper
Defined in:
app/controllers/ansible_variables_controller.rb

Overview

UI controller for ansible variables

Instance Method Summary collapse

Methods included from Foreman::Controller::Parameters::AnsibleVariable

#ansible_variable_params

Methods included from ForemanAnsible::Concerns::ImportControllerHelper

#find_proxy

Instance Method Details

#confirm_importObject



47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/ansible_variables_controller.rb', line 47

def confirm_import
  results = @importer.finish_import(new_vars, old_vars, updated_vars)
  success _(
    "Import of variables successfully finished.\n"\
    "Added: #{results[:added].count} \n "\
    "Removed: #{results[:obsolete].count} \n"\
    "Updated: #{results[:updated].count}"
  )
  redirect_to ansible_variables_path
end

#createObject



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

def create
  @ansible_variable = AnsibleVariable.new(ansible_variable_params.merge(:imported => false))
  if @ansible_variable.save
    process_success
  else
    process_error
  end
end

#importObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/ansible_variables_controller.rb', line 34

def import
  import_roles = @importer_roles.import_role_names
  import_roles[:new_roles] = import_roles[:new]
  import_variables = @importer.import_variable_names(import_roles[:new_roles])
  if import_variables.values.all?(&:empty?)
    success(_('No changes in variables detected on %s.') % @proxy.name)
    redirect_to ansible_variables_path
  else
    render 'ansible_variables/import',
           :locals => { :changed => import_variables }
  end
end

#indexObject



14
15
16
17
18
19
# File 'app/controllers/ansible_variables_controller.rb', line 14

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

#newObject



21
22
23
# File 'app/controllers/ansible_variables_controller.rb', line 21

def new
  @ansible_variable = AnsibleVariable.new
end