Bug 1746780

Summary: [RFE] Host parameter should be accessible in Report Template without setting "Safemode rendering" to false
Product: Red Hat Satellite Reporter: Ranjan Kumar <rankumar>
Component: ReportingAssignee: Ondřej Pražák <oprazak>
Status: CLOSED ERRATA QA Contact: Lukáš Hellebrandt <lhellebr>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.5.0CC: bkearney, inecas, mhulan, oprazak, pcreech
Target Milestone: 6.7.0Keywords: FutureFeature, Triaged
Target Release: Unused   
Hardware: All   
OS: All   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-14 13:25:28 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:

Description Ranjan Kumar 2019-08-29 09:07:29 UTC
Description of problem:
Currently, the host parameter is accessible in report template only using  host.info['parameters']['Parameter Name'] but needs to set "Safemode rendering" to false. We should able to access this when "Safemode rendering" is set to true

Here is an example template

<%- load_hosts().each_record do |host| -%>

<%-   report_row({

        'Name': host.name,

        'LOB': host.info['parameters']['SomeParameter']

      }) -%>

<%- end -%>

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


How reproducible: Always

Actual results: Getting Error message --> Warning! There was an error rendering the parameterreport template: undefined method '#info' for Host::Managed::Jail (Host::Managed)


Expected results: parameter should be accessible when "Safemode rendering" to true

Comment 3 Marek Hulan 2019-08-30 17:36:54 UTC
Have you tried host_param macro? From the request, it's not clear if you ask for host parameter of smart class parameter, but both is available when safe mode is enabled. Try:

host_param('SomeParameter')
host_enc('parameters', 'SomeParameter')
host_enc['parameters']['SomeParameter']

all of that will work with safe mode. If you find out it's working, please close as notabug.

Comment 7 Marek Hulan 2019-09-24 09:00:37 UTC
Created redmine issue https://projects.theforeman.org/issues/27926 from this bug

Comment 8 Bryan Kearney 2019-10-04 14:04:11 UTC
Upstream bug assigned to oprazak

Comment 9 Bryan Kearney 2019-10-04 14:04:12 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/27926 has been resolved.

Comment 10 Lukáš Hellebrandt 2019-12-04 14:42:42 UTC
Verified with Sat 6.7 snap 4.

With safemode on (Administer -> Settings -> Safemode rendering -> yes), I tried to generate report with contents:

<%- load_hosts(includes: :host_statuses).each_record do |host| -%>
<%-   report_row({
        'Name': host.name,
        'Global': host.global_status,
        'Parameter 1': host.host_param('test') || 'Unknown',
      }) -%>
<%- end -%>
<%= report_render -%>

The generated report contained the correct data.

Comment 13 errata-xmlrpc 2020-04-14 13:25:28 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-2020:1454