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[nic/bmc] ends with error bug #55

Open 1binary00 opened 6 years ago

1binary00 commented 6 years ago

Hello,

The foreman-rake hooks:objects gives nic/bmc object.

However listing of foreman-rake hooks:events[nic/bmc]

fails with error:

** Invoke hooks:events (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute hooks:events
rake aborted!
LoadError: Unable to autoload constant Nic::Bmc, expected /usr/share/foreman/app/models/nic/bmc.rb to define it
/usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:495:in `load_missing_constant'
/usr/share/foreman/vendor/ruby/2.1.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.1.0/gems/activesupport-4.2.9/lib/active_support/dependencies.rb:184:in `const_missing'
/usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:263:in `const_get'
/usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:263:in `block in constantize'
/usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:259:in `each'
/usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:259:in `inject'
/usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/inflector/methods.rb:259:in `constantize'
/usr/share/foreman/vendor/ruby/2.1.0/gems/activesupport-4.2.9/lib/active_support/core_ext/string/inflections.rb:66:in `constantize'
/usr/share/foreman/vendor/ruby/2.1.0/gems/foreman_hooks-0.3.14/lib/tasks/hooks.rake:11:in `block (2 levels) in <top (required)>'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/task.rb:251:in `call'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/task.rb:251:in `block in execute'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/task.rb:251:in `each'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/task.rb:251:in `execute'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/task.rb:195:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/task.rb:188:in `invoke_with_call_chain'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/task.rb:181:in `invoke'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:160:in `invoke_task'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:116:in `each'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:116:in `block in top_level'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:125:in `run_with_threads'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:110:in `top_level'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:83:in `block in run'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:186:in `standard_exception_handling'
/usr/share/foreman/vendor/ruby/2.1.0/gems/rake-12.3.0/lib/rake/application.rb:80:in `run'
/usr/bin/rake:27:in `<main>'
Tasks: TOP => hooks:events

As domcleal says: 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.

Anybody knows if a workaround is possible or in progress ?

I was looking on foreman issue without finding is this problem was open. Is this normal?