Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1466059 - Hammer Does Not Consistently Escape Quotes When Assigning JSON To A Host Parameter.
Summary: Hammer Does Not Consistently Escape Quotes When Assigning JSON To A Host Para...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.2.9
Hardware: x86_64
OS: Linux
unspecified
low
Target Milestone: 6.7.0
Assignee: Aditi Puntambekar
QA Contact: vijsingh
URL:
Whiteboard:
: 1607387 (view as bug list)
Depends On:
Blocks: 1607387
TreeView+ depends on / blocked
 
Reported: 2017-06-28 22:15 UTC by Bernie Hoefer
Modified: 2022-03-13 14:19 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1607387 (view as bug list)
Environment:
Last Closed: 2020-04-14 15:54:08 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 20348 0 Normal Resolved Hammer Does Not Consistently Escape Quotes When Assigning JSON To A Host Parameter. 2020-10-19 13:16:59 UTC
Red Hat Product Errata RHBA-2020:1455 0 None None None 2020-04-14 15:54:23 UTC

Description Bernie Hoefer 2017-06-28 22:15:48 UTC
Description of problem:

When attempting to update a host, like so:

# hammer -u username host update --name testserver.example.com --parameters diskinfo2='[{"group": "apache", "pciid": 160, "fstype": "ext4", "mntopts": "", "owner": "root", "path": "/mount/point/1", "fmtopts": "", "scsiid": 1, "size": 75}, {"group": "apache", "pciid": 160, "fstype": "xfs", "mntopts": "", "owner": "apache", "path": "/mount/point/2", "fmtopts": "", "scsiid": 2, "size": 200}]'

...the host parameter "diskinfo2" is set to:

["{\"group\": \"apache", "pciid\": 160", "fstype\": \"ext4", "mntopts\": ", "owner\": \"root", "path\": \"/mount/point/1", "fmtopts\": ", "scsiid\": 1", "size\": 75}", "{\"group\": \"apache", "pciid\": 160", "fstype\": \"xfs", "mntopts\": ", "owner\": \"apache", "path\": \"/mount/point/2", "fmtopts\": ", "scsiid\": 2", "size\": 200}"]

(Note the inconsistently escaped quotes, like "size\" instead of \"size\".)

Comment 1 Tomas Strachota 2017-07-19 12:21:43 UTC
This is an issue in parsing options in key-value format. As a workaround you can use either json syntax for parameters in the update command:

hammer host update --name testserver.example.com --parameters '{"diskinfo2": "[{\"group\": \"apache\", \"pciid\": 160, \"fstype\": \"ext4\", \"mntopts\": \"\", \"owner\": \"root\", \"path\": \"/mount/point/1\", \"fmto
pts\": \"\", \"scsiid\": 1, \"size\": 75}, {\"group\": \"apache\", \"pciid\": 160, \"fstype\": \"xfs\", \"mntopts\": \"\", \"owner\": \"apache\", \"path\": \"/mount/point/2\", \"fmtopts\": \"\", \"scsiid\": 2, \"size\": 200}]"}'

or set the parameter separately using set-parameter command:

hammer host set-parameter --host 8 --name diskinfo2 --value '[{"group": "apache", "pciid": 160, "fstype": "ext4", "mntopts": "", "owner": "root", "path": "/mount/point/1", "fmtopts": "", "sc$
iid": 1, "size": 75}, {"group": "apache", "pciid": 160, "fstype": "xfs", "mntopts": "", "owner": "apache", "path": "/mount/point/2", "fmtopts": "", "scsiid": 2, "size": 200}]'

Comment 2 Tomas Strachota 2017-07-19 12:25:10 UTC
Created redmine issue http://projects.theforeman.org/issues/20348 from this bug

Comment 3 Bernie Hoefer 2017-07-20 12:57:47 UTC
(In reply to Tomas Strachota from comment #1)
===
> This is an issue in parsing options in key-value format.
> As a workaround you can use either json syntax for
> parameters in the update command:
===

Thank you, Tomas.  I will pass that information on to the customer.

Comment 5 Bernie Hoefer 2018-03-29 19:39:00 UTC
Has anybody tested this to see if it is still a problem in Satellite 6.3.0?  (I'm guessing so, since the upstream bug[1] is still open.)

[1]<http://projects.theforeman.org/issues/20348

Comment 7 Bernie Hoefer 2018-06-21 20:39:59 UTC
(In reply to Bernie Hoefer from comment #5)
===
> Has anybody tested this to see if it is still a problem in Satellite 6.3.0? 
> (I'm guessing so, since the upstream bug[1] is still open.)
> 
> [1]<http://projects.theforeman.org/issues/20348
===

I have finally gotten around to confirming that it is still a problem:


# hammer host update --name test.localdomain --parameters diskinfo2='[{"group": "apache", "pciid": 160, "fstype": "ext4", "mntopts": "", "owner": "root", "path": "/mount/point/1", "fmtopts": "", "scsiid": 1, "size": 75}, {"group": "apache", "pciid": 160, "fstype": "xfs", "mntopts": "", "owner": "apache", "path": "/mount/point/2", "fmtopts": "", "scsiid": 2, "size": 200}]'
Host updated

# hammer host info --name test.localdomain | grep -A1 Parameters:
Parameters:               
    diskinfo2 => ["{\"group\": \"apache", "pciid\": 160", "fstype\": \"ext4", "mntopts\": ", "owner\": \"root", "path\": \"/mount/point/1", "fmtopts\": ", "scsiid\": 1", "size\": 75}", "{\"group\": \"apache", "pciid\": 160", "fstype\": \"xfs", "mntopts\": ", "owner\": \"apache", "path\": \"/mount/point/2", "fmtopts\": ", "scsiid\": 2", "size\": 200}"]


Note the double-quotes are still inconsistently escaped.  (Like the 2nd double-quote for "apache", or the 1st double-quote for "pciid".)

Comment 8 Bernie Hoefer 2018-06-21 20:43:26 UTC
(In reply to Bernie Hoefer from comment #7)
===
> I have finally gotten around to confirming that it is still a problem:
===

Doh, I forgot to mention the version I'm using.


# rpm -q satellite
satellite-6.3.2-1.el7sat.noarch

# rpm -qf `which hammer`
tfm-rubygem-hammer_cli-0.11.0.1-1.el7sat.noarch

Comment 9 Ivan Necas 2018-07-31 13:39:38 UTC
*** Bug 1607387 has been marked as a duplicate of this bug. ***

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

Comment 13 Martin Bacovsky 2019-09-10 19:16:42 UTC
This issue was fixed in upstream in hammer-cli-0.18.0. That version is part of Satellite 6.6. Moving to ON_QA for verification.
The preferred format for complex values is JSON and the fields were fixed to parse it properly. Simplified case from this bz could look like:

host update --id 4 --parameters '{"diskinfo2":[{"group":"apache", "pciid":160}, {"group":"apache", "pciid":160}]}'

where the diskinfo2 is the key and [{"group":"apache", "pciid":160}, {"group":"apache", "pciid":160}] is the value

For simple hash values it is possible to use e.g. --parameters key1=val1,key2=val2

Comment 15 vijsingh 2020-02-19 10:33:59 UTC
Verified

@Satellite 6.7.0 snap 12.0

Steps/Observations:

~~~~~~~~~~~~~~~~~~~~~
[root@dhcp-3-187 ~]# hammer host update --id 1 --parameters '{"diskinfo3":[{"group":"tomcat", "pciid":160}, {"group":"tomcat", "pciid":160}]}'
Host updated.
[root@dhcp-3-187 ~]# hammer host info --id 1 --fields Parameters
Parameters: 
    diskinfo3 => [{"group"=>"tomcat", "pciid"=>160}, {"group"=>"tomcat", "pciid"=>160}]

[root@dhcp-3-187 ~]# hammer host update --id 1 --parameters '{"diskinfo3":[{"group":"tomcat", "pciid":160}, {"group":"tomcat", "pciid":160}], "diskinfo1":[{"group":"tomcat1", "pciid":160}, {"group":"tomcat1", "pciid":160}]}'
Host updated.

[root@dhcp-3-187 ~]# hammer host info --id 1 --fields Parameters
Parameters: 
    diskinfo1 => [{"group"=>"tomcat1", "pciid"=>160}, {"group"=>"tomcat1", "pciid"=>160}]
    diskinfo3 => [{"group"=>"tomcat", "pciid"=>160}, {"group"=>"tomcat", "pciid"=>160}]


[root@dhcp-3-187 ~]# hammer host info --id 1 --fields 'All parameters'
All parameters: 
    diskinfo1 => [{"group"=>"tomcat1", "pciid"=>160}, {"group"=>"tomcat1", "pciid"=>160}]
    diskinfo3 => [{"group"=>"tomcat", "pciid"=>160}, {"group"=>"tomcat", "pciid"=>160}]
    enable-puppet5 => true
    enable-epel => false

[root@dhcp-3-187 ~]#
~~~~~~~~~~~~~~~~~~~~~

Comment 18 errata-xmlrpc 2020-04-14 15:54:08 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-2020:1455


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