Bug 1292381 - hammer fails with parameters that contains a commas
hammer fails with parameters that contains a commas
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Hammer (Show other bugs)
6.1.5
All Linux
unspecified Severity high (vote)
: GA
: --
Assigned To: Tomas Strachota
jcallaha
http://projects.theforeman.org/issues...
: Triaged
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2015-12-17 04:26 EST by Christophe Augello
Modified: 2016-07-27 07:02 EDT (History)
4 users (show)

See Also:
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 07:02:17 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Foreman Issue Tracker 12869 None None None 2016-04-26 13:08 EDT

  None (edit)
Description Christophe Augello 2015-12-17 04:26:52 EST
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 14:14:37 EST
Created redmine issue http://projects.theforeman.org/issues/12869 from this bug
Comment 3 Tomas Strachota 2016-02-29 11:33:09 EST
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 12:08:37 EDT
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 05:05:10 EDT
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 16:35:50 EDT
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 07:02:17 EDT
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

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