theforeman / foreman_default_hostgroup

A plugin to set the default hostgroup when hosts are created.
GNU General Public License v3.0
11 stars 29 forks source link

Plugin doesn't work in Foreman 1.12 #20

Closed sh41 closed 8 years ago

sh41 commented 8 years ago

Sadly it looks like theforeman/foreman#3242 has stopped this plugin from being able to carry out its really useful work.

As far as I can tell this plugin currently overrides the import_host_and_facts function to add in the functionality that sets a default hostgroup. The PR deprecates that function in foreman (https://github.com/theforeman/foreman/blob/d4ec64418b8db6093375f8d4b690d506705163f7/app/models/host/managed.rb#L466) and changes the code so that the overridden function is never called. Instead two different functions called import_host and import_facts are called: https://github.com/theforeman/foreman/blob/d4ec64418b8db6093375f8d4b690d506705163f7/app/controllers/api/v2/hosts_controller.rb#L236

It looks like this PR will be included in foreman 1.12 (I've noticed the problem in 1.12rc2).

GregSutcliffe commented 8 years ago

Thanks for the heads up! I have some other small things to fix in the plugin anyway, so I'll see if I can fix this and release all the changes for 1.12

GregSutcliffe commented 8 years ago

@sh41 I've just sent a PR with a ton of changes for 1.12 - on the chance that you're running a sandbox somewhere, would you be willing to give it a try and see if it works for you. Tests say it should ;)

sh41 commented 8 years ago

Hi @GregSutcliffe,

Works perfectly for me on foreman 1.12 RC-2. Just in case I got anything wrong along the way:

I installed by removing the package from the repo, adding in

gem 'foreman_default_hostgroup', :git => "https://github.com/GregSutcliffe/foreman_default_hostgroup.git", :branch => 'rewrite'

to ~foreman/bundler.d/Gemfile.local.rb

and then bundle update foreman_default_hostgroup followed by a restart of foreman.

Now when a host checks in it gets mapped to a host group correctly.

Thanks very much for your work!