Bug 1010575

Summary: [RFE] Support deep merging of hash structures in smart class parameters
Product: Red Hat Satellite Reporter: Dominic Cleal <dcleal>
Component: ProvisioningAssignee: orabin
Status: CLOSED ERRATA QA Contact: Tazim Kolhar <tkolhar>
Severity: low Docs Contact:
Priority: low    
Version: 6.0.1CC: bkearney, chrobert, cwelton, jswensso, mburgerh, mriddle, orabin, tkolhar, xdmoon
Target Milestone: UnspecifiedKeywords: FutureFeature, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/3309
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-08-12 05:07:35 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 Dominic Cleal 2013-09-21 17:16:57 UTC
Description of problem:
When storing complex hashes in smart variables/class parameters (i.e. JSON/YAML), the matchers simply override previous values with a certain precedence order.

Instead, we want to be able to deep merge data across the matchers, so a hash can be built up with a culmination of data.

Steps to Reproduce:
1. set a parameter/variable matcher order to "fqdn", "hostgroup", set data type to JSON
2. add an override of "hostgroup=Example" (change as appropriate), value: {"example":{"foo":"bar"}}
3. add an override of "fqdn=foo.example.com" (change), value: {"example":{"bar":"baz"}}
4. check YAML output on foo.example.com's host page

Actual results:
example:
  bar: baz

Expected results:
example:
  foo: bar
  bar: baz

Additional info:
http://www.theforeman.org/manuals/1.2/index.html#4.2.5ParameterizedClasses
http://www.youtube.com/watch?v=Ksr0tilbmcc

Comment 3 Dominic Cleal 2013-09-22 18:58:52 UTC
We should probably do the same for arrays too, e.g.

admin_users = []

hostgroup = [user1, user2]
location  = [user3, user4]

admin users = [user(1..4)]

(thanks Ohad)

Comment 6 Bryan Kearney 2014-10-22 12:01:20 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/3309 has been closed
-------------
Ori Rabin
Applied in changeset commit:ea4eec44b30b977bfd863d47b4fe3dd248816673.

Comment 9 Tazim Kolhar 2015-03-31 14:01:32 UTC
please provide verification steps
thanks

Comment 10 orabin 2015-03-31 14:53:19 UTC
Tazim, besides the deep dive I sent you these are some of the things that need varification:
- The steps to reproduce from the beginning using the type 'hash' for the variable/parameter
- The merge override button is only enabled for array/hash parameter type
- The avoid duplicates is only available for arrays
- Using "avoid duplicates": use the steps from the beginning with the values ['a'] for both matchers

Comment 11 Tazim Kolhar 2015-04-01 12:01:34 UTC
VERIFIED :

# rpm -qa | grep foreman
foreman-postgresql-1.7.2.15-1.el6_6sat.noarch
foreman-ovirt-1.7.2.15-1.el6_6sat.noarch
ruby193-rubygem-foreman-tasks-0.6.12.3-1.el6_6sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.5-1.el6_6sat.noarch
ruby193-rubygem-foreman-redhat_access-0.1.0-1.el6_6sat.noarch
rubygem-hammer_cli_foreman-0.1.4.7-1.el6_6sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.3-1.el6_6sat.noarch
foreman-1.7.2.15-1.el6_6sat.noarch
foreman-gce-1.7.2.15-1.el6_6sat.noarch
ruby193-rubygem-foreman_bootdisk-4.0.2.10-1.el6_6sat.noarch
ruby193-rubygem-foreman_gutterball-0.0.1.9-1.el6_6sat.noarch
foreman-debug-1.7.2.15-1.el6_6sat.noarch
rubygem-hammer_cli_foreman_discovery-0.0.1.4-1.el6_6sat.noarch
foreman-selinux-1.7.2.13-1.el6_6sat.noarch
qe-sat6-rhel66.usersys.redhat.com-foreman-proxy-1.0-2.noarch
foreman-compute-1.7.2.15-1.el6_6sat.noarch
ruby193-rubygem-foreman_docker-1.2.0.7-1.el6_6sat.noarch
ruby193-rubygem-foreman_discovery-2.0.0.9-1.el6_6sat.noarch
foreman-libvirt-1.7.2.15-1.el6_6sat.noarch
foreman-proxy-1.7.2.4-1.el6_6sat.noarch
qe-sat6-rhel66.usersys.redhat.com-foreman-client-1.0-1.noarch
qe-sat6-rhel66.usersys.redhat.com-foreman-proxy-client-1.0-1.noarch
ruby193-rubygem-foreman_hooks-0.3.7-2.el6_6sat.noarch
foreman-vmware-1.7.2.15-1.el6_6sat.noarch

able to select parameters with Override enable
the merge override button is only enabled for array/hash parameter type
the avoid duplicates is only available for arrays

Comment 12 Bryan Kearney 2015-04-14 21:08:21 UTC
*** Bug 1175885 has been marked as a duplicate of this bug. ***

Comment 13 Bryan Kearney 2015-08-11 13:33:40 UTC
This bug is slated to be released with Satellite 6.1.

Comment 14 errata-xmlrpc 2015-08-12 05:07:35 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-2015:1592