theforeman / foreman_hooks

Run custom hook scripts on Foreman events
http://m0dlx.com/blog/Extending_Foreman_quickly_with_hook_scripts.html
GNU General Public License v3.0
56 stars 50 forks source link

Missing host parameters in foreman_hooks json #43

Closed domcleal closed 7 years ago

domcleal commented 7 years ago

Copied from http://projects.theforeman.org/issues/19565

Started playing with foreman_hooks and noticed that the json data passed to my hook script is missing host parameters when I create a new host. I started digging through commits and found that if i revert this commit:

https://github.com/theforeman/foreman/commit/94265cf7ab7e383fc864182efd443be0adfac1de#diff-5ef0189b17a78606adef8f22e909697e

in the app/views/api/v2/hosts/show.json.rabl file it works again.

So, this code (which nowadays is moved to main.json.rabl):

node do |host|
  { :parameters => partial("api/v2/parameters/base", :object => host.host_parameters.authorized) }
end

does not work for me but this do:

child :host_parameters => :parameters do
  extends "api/v2/parameters/base" 
end

I'm running this as administrator in my Foreman installation, am I missing something or is this a bug?

wiad commented 7 years ago

Alright, now I see my global params. I'm also using the custom_host_parameters plugin but those parameters are not showing up in the json output unfortunately.

wiad commented 7 years ago

So I get content in the "all_parameters" key, but the "parameters" key is empty:

"parameters":[]

wiad commented 7 years ago

@domcleal Any feedback on how to get the '@parameters' data?