A while back I wrote an OpenStack V3 API compute resource provider for
Foreman 1.11.0. It was actually fairly simple (I didn't write it as a
plugin/extension but modified the code in place; I know this isn't ideal
and will work on making it a plugin/extension).
However I want to validate that the code still works. Really all that was
needed was to drop in the provider code in
foreman/app/models/compute_resources/foreman/model/openstackv3.rb
module Foreman::Model
class OpenstackV3 < ComputeResource
attr_accessor :tenant
Then add the provider to the list of supported providers.
def self.supported_providers
{
'Libvirt' => 'Foreman::Model::Libvirt',
'Ovirt' => 'Foreman::Model::Ovirt',
'EC2' => 'Foreman::Model::EC2',
'Vmware' => 'Foreman::Model::Vmware',
'Openstack' => 'Foreman::Model::Openstack',
'OpenstackV3' => 'Foreman::Model::OpenstackV3',
'Rackspace' => 'Foreman::Model::Rackspace',
'GCE' => 'Foreman::Model::GCE'
}
However, when I do that on Foreman 1.13 I get
uninitialized constant Foreman::Model::OpenstackV3 (NameError)
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman_hooks-0.3.12/lib/foreman_hooks.rb:90:in load_missing_constant_with_hooks' /usr/share/foreman/app/models/concerns/fog_extensions.rb:54:in
<top (required)>'
/opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require' /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in
require'
/opt/rh/sclo-ror42/root/usr/share/gems/gems/polyglot-0.3.4/lib/polyglot.rb:65:in require' /usr/share/foreman/config/initializers/foreman.rb:12:in
<top (required)>
Which if I am understanding the error correctly means it can't find the OpenstackV3 class.
In 1.11 the new provider code above was auto loaded/required, but this doesn't appear to be happening in 1.13.
Any help would be appreciated.
Thanks
> However I want to validate that the code still works. Really all that
> was needed was to drop in the provider code in
>
> >
> foreman/app/models/compute_resources/foreman/model/openstackv3.rb
>
> module Foreman::Model
> class OpenstackV3 < ComputeResource
This filename doesn't look right for the class name - it may need to be
openstack_v3.rb (because "Foreman::Model::OpenstackV3".underscore
returns "foreman/model/openstack_v3").
[…]
>
> However, when I do that on Foreman 1.13 I get
>
> uninitialized constant Foreman::Model::OpenstackV3 (NameError)
> /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_hooks-0.3.12/lib/foreman_hooks.rb:90:in load_missing_constant_with_hooks' > /usr/share/foreman/app/models/concerns/fog_extensions.rb:54:in
<top (required)>'
> /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in require' > /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in
require'
> /opt/rh/sclo-ror42/root/usr/share/gems/gems/polyglot-0.3.4/lib/polyglot.rb:65:in require' > /usr/share/foreman/config/initializers/foreman.rb:12:in
<top (required)>
>
>
> Which if I am understanding the error correctly means it can't find the OpenstackV3 class.
Yes, the Rails autoloader probably can't find it at the current location.
···
On 05/01/17 18:27, Matthew Ceroni wrote:
–
Dominic Cleal
dominic@cleal.org
I was able to correct this by moving my provider to a plugin and following
other plugin examples, like docker.
···
On Friday, January 6, 2017 at 12:32:55 AM UTC-8, Dominic Cleal wrote:
>
> On 05/01/17 18:27, Matthew Ceroni wrote:
> > However I want to validate that the code still works. Really all that
> > was needed was to drop in the provider code in
> >
> > >
> > foreman/app/models/compute_resources/foreman/model/openstackv3.rb
> >
> > module Foreman::Model
> > class OpenstackV3 < ComputeResource
>
> This filename doesn't look right for the class name - it may need to be
> openstack_v3.rb (because "Foreman::Model::OpenstackV3".underscore
> returns "foreman/model/openstack_v3").
>
> [..]
> >
> > However, when I do that on Foreman 1.13 I get
> >
> > uninitialized constant Foreman::Model::OpenstackV3 (NameError)
> >
> /opt/theforeman/tfm/root/usr/share/gems/gems/foreman_hooks-0.3.12/lib/foreman_hooks.rb:90:in
> `load_missing_constant_with_hooks'
> > /usr/share/foreman/app/models/concerns/fog_extensions.rb:54:in ` (required)>'
> >
> /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in
> `require'
> >
> /opt/rh/rh-ruby22/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:54:in
> `require'
> >
> /opt/rh/sclo-ror42/root/usr/share/gems/gems/polyglot-0.3.4/lib/polyglot.rb:65:in
> `require'
> > /usr/share/foreman/config/initializers/foreman.rb:12:in ` (required)>
> >
> >
> > Which if I am understanding the error correctly means it can't find the
> OpenstackV3 class.
>
> Yes, the Rails autoloader probably can't find it at the current location.
>
> --
> Dominic Cleal
> dom...@cleal.org
>