foreman_hooks icon indicating copy to clipboard operation
foreman_hooks copied to clipboard

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

Open josefjanda opened this issue 7 years ago • 2 comments

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)>'

josefjanda avatar Jun 06 '17 08:06 josefjanda

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.

domcleal avatar Jun 07 '17 19:06 domcleal

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

atgreen avatar Aug 09 '18 14:08 atgreen