Class: ForemanPuppet::PuppetclassesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ForemanPuppet::PuppetclassesController
- Includes:
- Foreman::Controller::AutoCompleteSearch, Foreman::Controller::Parameters::Host, Foreman::Controller::Parameters::Hostgroup, EnvironmentsImport, Extensions::ParametersHost, Extensions::ParametersHostgroup, ForemanPuppet::Parameters::Environment, ForemanPuppet::Parameters::Puppetclass
- Defined in:
- app/controllers/foreman_puppet/puppetclasses_controller.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #edit ⇒ Object
-
#host_params(top_level_hash = controller_name.singularize) ⇒ Object
TODO: filter for facets needs improving.
- #index ⇒ Object
- #override ⇒ Object
-
#parameters ⇒ Object
form AJAX methods.
- #resource_class ⇒ Object
- #update ⇒ Object
Methods included from EnvironmentsImport
#import_environments, #obsolete_and_new
Methods included from ForemanPuppet::Parameters::Puppetclass
Methods included from ForemanPuppet::Parameters::PuppetclassLookupKey
#puppetclass_lookup_key_params
Methods included from ForemanPuppet::Parameters::Environment
Methods included from Extensions::ParametersHostgroup
#process_deprecated_hostgroup_attributes!, #process_deprecated_hostgroup_environment_params!, #process_deprecated_hostgroup_puppet_params!
Methods included from Extensions::ParametersHost
#process_deprecated_attributes!, #process_deprecated_environment_params!, #process_deprecated_puppet_params!
Instance Method Details
#destroy ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/controllers/foreman_puppet/puppetclasses_controller.rb', line 47 def destroy if @puppetclass.destroy process_success else process_error end end |
#edit ⇒ Object
36 37 |
# File 'app/controllers/foreman_puppet/puppetclasses_controller.rb', line 36 def edit end |
#host_params(top_level_hash = controller_name.singularize) ⇒ Object
TODO: filter for facets needs improving
18 19 20 21 22 23 24 25 26 |
# File 'app/controllers/foreman_puppet/puppetclasses_controller.rb', line 18 def host_params(top_level_hash = controller_name.singularize) filter = self.class.host_params_filter filter.permit(puppet_attributes: {}) filter.filter_params(params, parameter_filter_context, top_level_hash).tap do |normalized| if parameter_filter_context.ui? && normalized['compute_attributes'] && normalized['compute_attributes']['scsi_controllers'] normalize_scsi_attributes(normalized['compute_attributes']) end end end |
#index ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/foreman_puppet/puppetclasses_controller.rb', line 28 def index @puppetclasses = resource_base_search_and_page allowed_hostgroup_ids = HostgroupPuppetFacet.joins(:hostgroup_classes) .where(HostgroupClass.arel_table[:puppetclass_id].in(@puppetclasses.map(&:id))) .pluck(:hostgroup_id).uniq @hostgroups_authorizer = Authorizer.new(User.current, collection: allowed_hostgroup_ids) end |
#override ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/foreman_puppet/puppetclasses_controller.rb', line 55 def override if @puppetclass.class_params.present? @puppetclass.class_params.each do |class_param| class_param.update(override: params[:enable]) end if [true, 'true'].include?(params[:enable]) success _('Successfully overridden all parameters of Puppet class %s') % @puppetclass.name else success _('Successfully reset all parameters of Puppet class %s to their default values') % @puppetclass.name end else error _('No parameters to override for Puppet class %s') % @puppetclass.name end redirect_to puppetclasses_path end |
#parameters ⇒ Object
form AJAX methods
72 73 74 75 76 77 |
# File 'app/controllers/foreman_puppet/puppetclasses_controller.rb', line 72 def parameters puppetclass = Puppetclass.find(params[:id]) render partial: 'foreman_puppet/puppetclasses/class_parameters', locals: { puppetclass: puppetclass, obj: find_host_or_hostgroup } end |
#resource_class ⇒ Object
79 80 81 |
# File 'app/controllers/foreman_puppet/puppetclasses_controller.rb', line 79 def resource_class model_of_controller end |
#update ⇒ Object
39 40 41 42 43 44 45 |
# File 'app/controllers/foreman_puppet/puppetclasses_controller.rb', line 39 def update if @puppetclass.update(puppetclass_params) process_success else process_error end end |