Bug 1466059
| Summary: | Hammer Does Not Consistently Escape Quotes When Assigning JSON To A Host Parameter. | |||
|---|---|---|---|---|
| Product: | Red Hat Satellite | Reporter: | Bernie Hoefer <bhoefer> | |
| Component: | Hammer | Assignee: | Aditi Puntambekar <apuntamb> | |
| Status: | CLOSED ERRATA | QA Contact: | vijsingh | |
| Severity: | low | Docs Contact: | ||
| Priority: | unspecified | |||
| Version: | 6.2.9 | CC: | ahumbe, apuntamb, bkearney, dhlavacd, janarula, jcallaha, mbacovsk, mhulan, riehecky, sghai, vijsingh | |
| Target Milestone: | 6.7.0 | Keywords: | Triaged | |
| Target Release: | Unused | |||
| Hardware: | x86_64 | |||
| OS: | Linux | |||
| Whiteboard: | ||||
| Fixed In Version: | Doc Type: | If docs needed, set a value | ||
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 1607387 (view as bug list) | Environment: | ||
| Last Closed: | 2020-04-14 15:54:08 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: | ||||
| Bug Depends On: | ||||
| Bug Blocks: | 1607387 | |||
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}]'
Created redmine issue http://projects.theforeman.org/issues/20348 from this bug (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. 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 (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".) (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 *** Bug 1607387 has been marked as a duplicate of this bug. *** Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/20348 has been resolved. 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
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 ~]#
~~~~~~~~~~~~~~~~~~~~~
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 |
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\".)