Bug 1267646 - Failed to render the smart proxy name
Failed to render the smart proxy name
Status: CLOSED NOTABUG
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Provisioning Templates (Show other bugs)
6.1.2
Unspecified Unspecified
unspecified Severity medium (vote)
: Unspecified
: --
Assigned To: Stephen Benjamin
: Triaged
Depends On:
Blocks: 1122832
  Show dependency treegraph
 
Reported: 2015-09-30 10:56 EDT by Peter Vreman
Modified: 2015-10-15 09:35 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-10-15 09:35:04 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Peter Vreman 2015-09-30 10:56:11 EDT
Description of problem:
Printing the name of the content_source is not allowed. We wanted to use it in the logging like:

%post
echo "==> Registering to Satellite 6 '<%= @host.content_source.name %>'"

There was an error rendering the Unnamed template: undefined method 'name' for SmartProxy::Jail 


Patch to add support:

--- /usr/share/foreman/app/models/smart_proxy.rb.old    2015-09-30 14:46:12.954768684 +0000
+++ /usr/share/foreman/app/models/smart_proxy.rb        2015-09-30 14:47:00.845945575 +0000
@@ -94,6 +94,10 @@
     conditions
   end

+  class Jail < Safemode::Jail
+    allow :name
+  end
+
   private

   def sanitize_url


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


How reproducible:


Steps to Reproduce:
1. Include <%= @host.content_source.name %> in the template
2.
3.

Actual results:
Error thrown

Expected results:
The smart proxy name is shown

Additional info:
Comment 2 Stephen Benjamin 2015-10-15 09:35:04 EDT
You can do this instead:

echo "==> Registering to Satellite 6 '<%= @host.content_source %>'"

It will implicitly do a .to_s on the content_source, which is allowed in the Jail.
In the case of the Smart Proxy, that returns the name.

Note You need to log in before you can comment on or make changes to this bug.