On Tue, Oct 24, 2017 at 3:16 PM, jbm <j...@bachmeier.cc> wrote: > On 24/10/17 13:20, Ivan Necas wrote: >> Hi, >> >> I was hitting this issue recently in the rex plugin, I needed to >> change the way the param is whitelisted, >> from using an array, to pass it via a block like this: >> >> https://github.com/theforeman/foreman_remote_execution/pull/276 > I changed the portion to > > parameter_filter Nic::Interface do |ctx| > ctx.permit compute_attributes: [:my_param] > end > > but it still doesn't work. I also tried `ctx.permit :my_param', which worked > neither. > > I'm not sure if I transfered your solution correctly to my usecase, as you > seem to be passing the NIC parameters differently than I do (I do it in > app/views/compute_resources_vms/form/powervm/_network.html.erb, you in > app/views/overrides/nics/_execution_interface.html.erb). >> Also, make sure you're testing it with the version of Foreman that has >> this patch >> https://github.com/theforeman/foreman/pull/4886, as it needs it to >> work properly. > I'm using the latest develop branch, so this is included
Oh, I haven't realized you need to put it under the `compute_attributes`. In that case, I think you would need to convert the `compute_attributes` in (https://github.com/theforeman/foreman/blob/c6760930cf08a4b584b75df8a621092dd787da01/app/controllers/concerns/foreman/controller/parameters/host_base.rb#L42) to use filter (such as Nic::ComputeAttribute), similarly as we have in the host (https://github.com/theforeman/foreman/blob/c6760930cf08a4b584b75df8a621092dd787da01/app/controllers/concerns/foreman/controller/parameters/host_base.rb#L42) and then, define the parameter_filter on `Nic::ComputeAttribute`) - Ivan >> >> -- Ivan >> >> On Thu, Oct 12, 2017 at 7:24 PM, jbm <j...@bachmeier.cc> wrote: >>> Hi, >>> >>> I'm currently working on a Foreman plugin to use IBM PowerVM instances as >>> compute resources, and have run into the following problem when implementing >>> the network interface form: >>> >>> Following the guide at [1], I put my additional network parameters in >>> `foreman_powervm/app/views/compute_resources_vms/form/foreman_powervm/_network.html.erb', >>> like this: >>> >>> <%= number_f f, :my_param >>> :label => _("Foo") %> >>> >>> I now expected :my_param to be available in >>> ForemanPowerVM::PowerVM#create_vm (which is my subclass of ComputeResource), >>> in the form of args['interfaces_attributes'][i]['my_param'], but it is not >>> there (even though the foreman log shows that my_param was in fact recieved >>> as a POST parameter). >>> >>> So, as described in [2], I added >>> >>> parameter_filter Nic::Interface, compute_attributes: [:my_param] >>> >>> to the Plugin.register block in my Engine class, but to no avail. >>> >>> >>> After a bit of digging around in the foreman code I managed to "fix" this by >>> adding :my_param to the :compute_attributes entry in >>> Foreman::Controller::Parameters::NicBase#add_nic_base_params_filter (file >>> `foreman_app/controllers/concerns/foreman/controller/parameters/nic_base.rb:27'). >>> >>> >>> How do I keep my parameter from being filtered without altering foreman >>> code? What is the correct way to register parameters, as parameter_filter >>> doesnt seem to work? >>> >>> >>> Thanks for reading and hopefully your help! >>> >>> >>> [1]: >>> http://projects.theforeman.org/projects/foreman/wiki/How_to_Create_a_Plugin#Required-views >>> [2]: http://projects.theforeman.org/projects/foreman/wiki/Strong_parameters >>> >>> -- >>> jbm >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "foreman-dev" group. >>> To unsubscribe from this group and stop receiving emails from it, send an >>> email to foreman-dev+unsubscr...@googlegroups.com. >>> For more options, visit https://groups.google.com/d/optout. > > -- > You received this message because you are subscribed to the Google Groups > "foreman-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to foreman-dev+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "foreman-dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to foreman-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.