Bug 1264916

Summary: Missing variable to include Sat 6 Hostname in PXE Menus
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: TFTPAssignee: Marek Hulan <mhulan>
Status: CLOSED ERRATA QA Contact: Sachin Ghai <sghai>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.1.2CC: bbuckingham, omaciel, pcfe, peter.vreman, sghai, xdmoon
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/14232
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:20:03 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    
Attachments:
Description Flags
foreman fqdn varibale set and it correctly rendered as PXE menu title. none

Description Peter Vreman 2015-09-21 12:55:58 UTC
Description of problem:
We have multiple Sat6 servers. Currently from the PXE menu it is hard to distinguish between them.
There is no variable to include in the PXE Menu Title, e.g. in "PXELinux global default", to has the Sat6 Hostname.



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


How reproducible:


Steps to Reproduce:
1. Have the Sat6 Hostname rendered from template variable in the PXE Menu title 
...
DEFAULT menu
PROMPT 0
MENU TITLE Kickstart - <%= foreman_server %>
...
2.
3.

Actual results:
Missing the foreman_server name

Expected results:
Foreman Server name is included in the template


Additional info:

Comment 2 Marek Hulan 2016-03-09 09:23:13 UTC
You can use following

    DEFAULT menu
    PROMPT 0
    MENU TITLE PXE Menu - <%= foreman_url.sub('/unattended/built', '') %>

You can even omit the .sub(...) part if you don't mind that url would include unattended path. The foreman_url determines the hostname by "Unattended URL" setting (Administer -> Settings -> Provision).

Would this be enough or do you want to add new helper that would remove the path from url?

Comment 3 Marek Hulan 2016-03-09 09:26:44 UTC
Actually the snippet can be even a bit simpler using chomp instead of sub

    <%= foreman_url.chomp('/unattended/built') %>

Comment 4 Peter Vreman 2016-03-09 10:36:57 UTC
When it works the provided solution of using foreman_url is enough. But sadly it is not alled by the Safemode jail:

Using <%= foreman_url.sub('/unattended/built', '') %>:

[crash] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"organization_id\":3}" -XGET https://localhost/api/config_templates/build_pxe_default
failed to process template: undefined method 'sub' for NilClass::Jail (NilClass)

Using <%= foreman_url.chomp('/unattended/built') %>:

[crash] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999,\"organization_id\":3}" -XGET https://localhost/api/config_templates/build_pxe_default
failed to process template: Safemode doesn't allow to access 'foreman_url' on #<Safemode::ScopeObject>

Comment 5 Marek Hulan 2016-03-09 11:46:01 UTC
Sorry I've tested with slightly newer version version of satellite, this will be possible with Satellite 6.2. The foreman_url function must be available though, since we use it in default PXELinux template to get url for kickstart file. It's called slightly differently, could you please try using <%= foreman_url('provision') %> instead?

Comment 6 Marek Hulan 2016-03-14 16:33:47 UTC
I didn't realize that build_pxe_default might have different rendering context, I'll verify if that's the case

Comment 7 Marek Hulan 2016-03-16 14:22:29 UTC
Created redmine issue http://projects.theforeman.org/issues/14232 from this bug

Comment 8 Marek Hulan 2016-03-16 15:49:30 UTC
Ok I was able to reproduce. There might be a workaround to use default_template_url but it's getting really hacky. I'll change it so that it will allow using foreman_url even when building pxe default template along with other useful helpers like snippet.

Comment 9 Bryan Kearney 2016-03-16 16:09:37 UTC
Upstream bug component is TFTP

Comment 10 Bryan Kearney 2016-03-22 14:09:39 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/14232 has been closed
-------------
Marek Hulán
Applied in changeset commit:e4ed4a0db4d60f68183b5ef3bff13e136af684e6.

Comment 11 Sachin Ghai 2016-05-09 09:09:08 UTC
Verified with sat62 GA snap10.1

Now you can set the foreman_fqdn in PXE menus with variable: <%= foreman_server_fqdn %> 

Please see the attached screenshot where PXE Men Title rendered with foreman server name.

Comment 12 Sachin Ghai 2016-05-09 09:09:56 UTC
Created attachment 1155221 [details]
foreman fqdn varibale set and it correctly rendered as PXE menu title.

Comment 13 Bryan Kearney 2016-07-27 11:20:03 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/RHBA-2016:1501