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

foreman-rake hooks:events[foreman/model/ec2] ends with error #45

Open josefjanda opened 7 years ago

josefjanda commented 7 years ago

The foreman-rake hooks:objects gives foreman/model/ec2 object.

However listing of foreman-rake hooks:events[foreman/model/ec2] fails with error:

rake aborted!
LoadError: Unable to autoload constant Foreman::Model::Ec2, expected /usr/share/foreman/app/models/compute_resources/foreman/model/ec2.rb to define it
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:495:in `load_missing_constant'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_hooks-0.3.14/lib/foreman_hooks/as_dependencies_hook.rb:4:in `load_missing_constant'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/dependencies.rb:184:in `const_missing'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:263:in `const_get'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:263:in `block in constantize'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:259:in `each'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:259:in `inject'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/inflector/methods.rb:259:in `constantize'
/usr/share/foreman/vendor/ruby/2.3.0/gems/activesupport-4.2.8/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
/usr/share/foreman/vendor/ruby/2.3.0/gems/foreman_hooks-0.3.14/lib/tasks/hooks.rake:11:in `block (2 levels) in <top (required)>'
domcleal commented 7 years ago

Arguably this is a bug in Foreman, it should define mixed-case Ec2 rather than all-caps EC2 to match the Rails autoloader expectations, but foreman_hooks could work around it.

atgreen commented 6 years ago

The same problem with aix, gce, kt_environment, bmc and nxos. You can't add a hook to any of those objects.