On 24/10/17 17:42, Ivan Necas wrote: > On Tue, Oct 24, 2017 at 3:16 PM, jbm <[email protected]> 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`) Just so I understand you right: Are you saying that it is a missing feature in foreman that one can not add custom parameters in the `compute_attributes'? If so, did I understand the "How to Create a Plugin" guide wrong? Is `compute_attributes' *not* the correct way to add custom provider specific parameters to the NIC creation (by adding them to `app/views/compute_resources_vms/form/foreman_powervm/_network.html.erb')? What is the correct way?
If the only way to do this is to implement your suggested change in foreman, I will do that, but since I don't know how fast I could get this patch to the production system I want to run my plugin on I'd prefer a solution that works without altering foreman and would be happy for a suggestion. -- jbm > - Ivan > >>> -- Ivan >>> >>> On Thu, Oct 12, 2017 at 7:24 PM, jbm <[email protected]> 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 [email protected]. >>>> 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 [email protected]. >> 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
