Bug 1127595

Summary: Global PXE Menu hostgroup name shall be first in menu label and also sort menu labels
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: Provisioning TemplatesAssignee: Lukas Zapletal <lzap>
Status: CLOSED ERRATA QA Contact: Katello QA List <katello-qa-list>
Severity: low Docs Contact:
Priority: medium    
Version: 6.0.3CC: afeferku, brubisch, cwelton, lzap, peter.vreman, pgagne
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/6977
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:54:17 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1122832    

Description Peter Vreman 2014-08-07 08:28:32 UTC
Description of problem:
The hostgroup name is more important for the server then the provisioning template name. The hostgroup defines really what it will get and also the content view afterwards.

Also sort the list of PXE menu entries alphanumeric to have a easier to browse/navigate PXE menu.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:
PXE menu to have the hostgroup name as first words in the menu entry before the provisioning template

Additional info:

Comment 1 Dominic Cleal 2014-08-07 08:32:25 UTC
Created redmine issue http://projects.theforeman.org/issues/6977 from this bug

Comment 3 Peter Vreman 2014-11-07 10:42:42 UTC
Patch to sort the entries:

patch -p0 -l -f << EOF
--- /usr/share/foreman/app/models/config_template.rb
+++ /usr/share/foreman/app/models/config_template.rb
@@ -197,6 +197,7 @@
         end
       end
     end
+    combos.sort! { |x,y| "#{x[:hostgroup]} - #{x[:template]}" <=> "#{y[:hostgroup]} - #{y[:template]}" }
     combos
   end
 end

EOF

Comment 4 Peter Vreman 2014-11-07 10:43:15 UTC
Patch for the template:

patch -p0 -l -f << EOF
--- /usr/share/foreman/app/views/unattended/pxe/PXELinux_default.erb
+++ /usr/share/foreman/app/views/unattended/pxe/PXELinux_default.erb
@@ -18,11 +18,12 @@
      LOCALBOOT 0

 <% for profile in @profiles -%>
-LABEL <%= "#{profile[:template]} - #{profile[:hostgroup]}" %>
+LABEL <%= "#{profile[:hostgroup]} - #{profile[:template]}" %>
      kernel <%= profile[:hostgroup].operatingsystem.kernel(profile[:hostgroup].architecture) %>
 <% case profile[:hostgroup].operatingsystem.pxe_type -%>
 <% when 'kickstart' -%>
      append initrd=<%= profile[:hostgroup].operatingsystem.initrd(profile[:hostgroup].architecture) %> ks=<%= default_template_url(profile[:template], profile[:hostgroup]) %> ksde$
+     ipappend 2
 <% when 'preseed' -%>
      append initrd=<%= profile[:hostgroup].operatingsystem.initrd(profile[:hostgroup].architecture) %> interface=auto url=<%= default_template_url(profile[:template], profile[:hos$
 <% end -%>
EOF

Comment 5 Bryan Kearney 2015-08-25 18:00:03 UTC
Upstream bug component is Provisioning Templates

Comment 6 Bryan Kearney 2016-05-02 08:03:21 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/6977 has been closed

Comment 9 Peter Vreman 2016-10-05 14:19:23 UTC
The upstream patch is not correct.
It sorts on the hostgroup name instead of the full hostgroup title

Comment 11 Peter Vreman 2016-10-19 07:08:03 UTC
Working patch against 6.2.2

--- /usr/share/foreman/app/models/provisioning_template.rb
+++ /usr/share/foreman/app/models/provisioning_template.rb
@@ -188,6 +188,6 @@ def self.pxe_default_combos
         end
       end
     end
-    combos
+    combos.sort_by! { |profile| [profile[:hostgroup].title, profile[:template]] }
   end
 end
EOF

Comment 12 Peter Vreman 2016-10-19 07:09:49 UTC
For testing use nested hostgroups, for example:

dev/Cluster1/Database
dev/Cluster1/WebServer
prod/Cluster1/Database
prod/Cluster1/WebServer

The output shall be like the list above

Comment 14 Amir 2016-11-10 23:47:20 UTC
A new upstream bug fix has been close - https://github.com/theforeman/foreman/pull/3982

Comment 15 Lukas Zapletal 2017-08-16 11:03:38 UTC
VERIFIED order is correct.

LABEL A_RHEL 7.3 HGP - A Kickstart
  KERNEL boot/CentOS-7.3-x86_64-vmlinuz
  APPEND initrd=boot/CentOS-7.3-x86_64-initrd.img ks=http://xxx.redhat.com/unattended/template/A%20Kickstart/A_RHEL%207.3%20HGP ksdevice=bootif network kssendmac ks.sendmac inst.ks.sendmac

LABEL RHEL 7.3 HGP - A Kickstart
  KERNEL boot/CentOS-7.3-x86_64-vmlinuz
  APPEND initrd=boot/CentOS-7.3-x86_64-initrd.img ks=http://xxx.redhat.com/unattended/template/A%20Kickstart/RHEL%207.3%20HGP ksdevice=bootif network kssendmac ks.sendmac inst.ks.sendmac

Comment 16 Satellite Program 2018-02-21 16:54:17 UTC
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA.
> 
> For information on the advisory, and where to find the updated files, follow the link below.
> 
> If the solution does not work for you, open a new bug report.
> 
> https://access.redhat.com/errata/RHSA-2018:0336