Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1292381

Summary: hammer fails with parameters that contains a commas
Product: Red Hat Satellite Reporter: Christophe Augello <caugello>
Component: HammerAssignee: Tomas Strachota <tstrachota>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.1.5CC: bbuckingham, cwelton, jcallaha, tstrachota
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
URL: http://projects.theforeman.org/issues/12869
Whiteboard:
Fixed In Version: rubygem-hammer_cli-0.5.1.6-1 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:02:17 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 Christophe Augello 2015-12-17 09:26:52 UTC
Description of problem:

hammer fails with parameters that contains a comma

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

How reproducible:
100%

Steps to Reproduce:
Run a hammer command where a parameter contains a coma:

hammer --debug host create --subnet-id 3 --domain-id 2 --name testtest --organization-id 3 --location-id 2 --operatingsystem-id 1 --hostgroup-id 1 --mac AA:BB:CC:DD:EE:H1 --parameters bridges='[["bridge0.20","bond0.20"],["bridge1","bond1"]]'


hammer --debug host create --subnet-id 3 --domain-id 2 --name testtest --organization-id 3 --location-id 2 --operatingsystem-id 1 --hostgroup-id 1 --mac AA:BB:CC:DD:EE:H1 --parameters bridges='a,b'

Actual results:

Clamp::UsageError (option '--parameters': value must be defined as a comma-separated list of key=value):
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/option/parsing.rb:34:in `rescue in parse_options'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/option/parsing.rb:31:in `parse_options'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:52:in `parse'
    /usr/share/gems/gems/hammer_cli-0.1.4.13/lib/hammer_cli/abstract.rb:31:in `parse'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:66:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4.13/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4.13/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/subcommand/execution.rb:11:in `execute'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:67:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4.13/lib/hammer_cli/abstract.rb:23:in `run'
    /usr/share/gems/gems/clamp-0.6.2/lib/clamp/command.rb:125:in `run'
    /usr/share/gems/gems/hammer_cli-0.1.4.13/bin/hammer:108:in `<top (required)>'
    /usr/bin/hammer:23:in `load'
    /usr/bin/hammer:23:in `<main>'


Expected results:
When the value of a key is between quotes, handle it as a string and ignore the commas.

Additional info:
Same parameters trough webui works and values are saved as string in db.

[#<HostParameter id: 46, name: "bridges", value: "[[\"bridge0.20\",\"bond0.20\"],[\"bridge1\",\"bond1\"]]", reference_id: 109, created_at: "2015-12-17 08:19:06", updated_at: "2015-12-17 08:19:06", type: "HostParameter", priority: 4, hidden_value: false>]

Comment 1 Bryan Kearney 2015-12-17 19:14:37 UTC
Created redmine issue http://projects.theforeman.org/issues/12869 from this bug

Comment 3 Tomas Strachota 2016-02-29 16:33:09 UTC
Unfortunately capabilities of the current format are quite limited. You can only enter either --parameters='key1=value1,key2=value2' or --parameters='key1=[val1,val2,val3]'.

Would it be acceptable if we added support for json format with backward compatibility with the current one? Parameters could be then entered as both:

--parameters='key1=value1'
or
--parameters='{"key1": "value1", "nested": {"array": [1, 2]}}'

We have json parameters already in the hammer so the implementation should be trivial.

Comment 4 Bryan Kearney 2016-03-21 16:08:37 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/12869 has been closed
-------------
Anonymous
Applied in changeset commit:1c83d898364270ac7f00eef171d5b2a964e04d25.

Comment 5 Tomas Strachota 2016-03-23 09:05:10 UTC
QE, please note that we've switched to json format for more complicated parameter strucutres as it was described in https://bugzilla.redhat.com/show_bug.cgi?id=1292381#c3.

Comment 6 jcallaha 2016-05-26 20:35:50 UTC
Verified in Satellite 6.2 Beta Snap 13.

Using a json format allows you to specify multiple items without encountering the issue initially reported.

Comment 7 Bryan Kearney 2016-07-27 11:02:17 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-2016:1501