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

support for Host::Discovered objects [issue 24] #25

Closed phirince closed 9 years ago

phirince commented 9 years ago

This is needed so that the discovered_hosts/*.rabl files from the foreman_discovery plugin are available fore rendering. Please review this.

Thanks, -PP

phirince commented 9 years ago

Can somebody please look into this and let me know if this can be pulled up?

-PP

domcleal commented 9 years ago

Sorry for not getting to this.

This causes an issue with plain Foreman hooks if you're not using the Discovery plugin, as the constant isn't known. You might want to change the case statement to compare self.class.name instead, so we're only comparing strings without the need for Host::Discovered to actually exist.

Running hook: /home/dcleal/code/foreman/foreman/config/hooks/domain/before_validation/01_log.sh before_validation 
Unable to render  (Domain) using RABL: uninitialized constant Host::Discovered
/home/dcleal/code/foreman/foreman_hooks/lib/foreman_hooks.rb:83:in `load_missing_constant_with_hooks'
/home/dcleal/code/foreman/foreman_hooks/lib/foreman_hooks/util.rb:10:in `render_hook_type'
/home/dcleal/code/foreman/foreman_hooks/lib/foreman_hooks/util.rb:20:in `render_hook_json'
/home/dcleal/code/foreman/foreman_hooks/lib/foreman_hooks/util.rb:31:in `block in exec_hook'
domcleal commented 9 years ago

Thanks @phirince!