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 1607387 - 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 DUPLICATE of bug 1466059
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Hammer
Version: 6.4
Hardware: x86_64
OS: Linux
medium
low
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Katello QA List
URL:
Whiteboard:
Depends On: 1466059
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-07-23 12:23 UTC by Ashish Humbe
Modified: 2022-03-13 15:16 UTC (History)
15 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1466059
Environment:
Last Closed: 2018-07-31 13:39:38 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 20348 0 None None None 2018-07-23 12:23:10 UTC

Comment 1 Ashish Humbe 2018-07-23 13:02:09 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\".)

--- Additional comment from Tomas Strachota on 2017-07-19 08:21:43 EDT ---

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}]'


I see this issue is present on Satellite 6.4 latest SNAP too. 


# hammer host update --name client.example.com --parameters diskinfo3='[{"group": "apache", "pciid": 160, "fstype": "ext4", "mntopts": ""}]'
Host updated.

# hammer host info --name client.example.com | grep  Parameters -A1
Parameters:               
    diskinfo3 => ["{\"group\": \"apache", "pciid\": 160", "fstype\": \"ext4", "mntopts\": \"\"}"]


Here we see that the stored data contain "\" in it which should not be the case. 


Whereas when we pass the values to parameters as below the data get stored and displayed properly. 

# hammer host update --name client.example.com --parameters '{"diskinfo4": "[{\"group\": \"apache\", \"pciid\": 160, \"fstype\": \"ext4\", \"mntopts\": \"\"}]"}'
Host updated.

# hammer host info --name client.example.com | grep  Parameters -A1
Parameters:               
    diskinfo4 => [{"group": "apache", "pciid": 160, "fstype": "ext4", "mntopts": ""}]


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