Bug #6952
closedCorrectly set hostgroup after provisioning from PXE menu
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1127164
Description of problem:
When we provision from the standard PXE menu, we can choose which hostgroup template to install the new server from.
Version-Release number of selected component (if applicable):
6 beta
How reproducible:
always
Steps to Reproduce:
1. Create some hostgroups with associated content views and lifecycle environments
2. Build the PXE default menu from the Provisioning Templates screen
3. PXE boot a new server
4. From the boot menu, select a hostgroup boot option
Actual results:
Machine boots and installs, however once it has registered with foreman, it is not in a hostgroup
Expected results:
The newly installed machine should be in the same hostgroup that we selected in the PXE menu.
Additional info:
Candidate patch:
patch p0 -l -f << EOF /usr/share/foreman/app/models/host/managed.rb 2014-08-06 08:24:18.912311511 0000
--
++ /usr/share/foreman/app/models/host/managed.rb 2014-08-06 09:06:02.716311124 +0000@ -404,6 +404,14
@
host ||= Host.new(:name => hostname, :certname => certname) if Setting[:create_new_host_when_facts_are_uploaded]
# set hostgroup defaults if provided by a fact
+ hostgroup_fact='foreman_hostgroup'
+ if facts.keys.include?(hostgroup_fact)
+ host.hostgroup = Hostgroup.find_by_title(facts[hostgroup_fact])
+ host.set_hostgroup_defaults
+ end
+
- if we were given a certname but found the Host by hostname we should update the certname
host.certname = certname if certname.present?
EOF