Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1141671 - Cant specify comma spaced lists as values to the --parameters option.
Cant specify comma spaced lists as values to the --parameters option.
Status: CLOSED ERRATA
Product: Red Hat Satellite 6
Classification: Red Hat
Component: Hammer (Show other bugs)
6.0.2
Unspecified Linux
unspecified Severity medium (vote)
: GA
: Unused
Assigned To: Tomas Strachota
Marek Hulan
http://projects.theforeman.org/issues...
: Reopened, Triaged
Depends On: 1272979
Blocks: 1140393
  Show dependency treegraph
 
Reported: 2014-09-15 04:03 EDT by Dominic Cleal
Modified: 2016-07-27 07:41 EDT (History)
10 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1140393
Environment:
Last Closed: 2016-07-27 07:41:31 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 7133 None None None 2016-04-22 12:33 EDT
Red Hat Product Errata RHSA-2015:1592 normal SHIPPED_LIVE Important: Red Hat Satellite 6.1.1 on RHEL 6 2015-08-12 05:04:35 EDT

  None (edit)
Description Dominic Cleal 2014-09-15 04:03:04 EDT
+++ This bug was initially created as a clone of Bug #1140393 +++

Description of problem:

A comma seperated list cannot be passed as a value in a key/value pair when using the --parameters option when creating a host.


Version-Release number of selected component (if applicable):
# hammer --version
hammer (0.1.0)
 * hammer_cli_foreman (0.1.0)


How reproducible:
Always

Steps to Reproduce:
1.Create a host and specify the --parameters option with a comma seperated list as a value in a keypair.

2. hammer host create --name "test.example.org" --build true --enabled true --managed true --environment-id 1 --ip "192.168.10.10" --mac "02:00:00:00:00:b0" --subnet-id 1 --architecture-id 1 --medium-id 8 --partition-table-id 11 --root-password changeme --parameters subscription_manager=true,subscription_manager_username=smuser,subscription_manager_password=smpass,subscription_manager_repos="rhel-server-rhscl-6-rpms, rhel-6-server-rpms, rhel-6-server-openstack-5.0-rpms",subscription_manager_pool=34gf434gf34f34f4442

3.

Actual results:
Could not create the host:
  Error: option '--parameters': value must be defined as a comma-separated list of key=value
  
  See: 'hammer host create --help'


Expected results:
Expect the host to be created with appropriate parameters


Additional info:

I am using the --parameters option to the "hammer host create" or "hammer
host update" commands. This option takes a comma seperated list of
key=value pairs. The issue I am running into is I need to specify a comma seperated list as a value.

The above command fails telling me I must specify a comma seperated list
of key/values:

I can specify the same command without the subscription_manager_repos="..." key/value pair and it works fine. If I specify only the subscription_manager_repos="..." key and value, it fails.

I suspect the hammer code is splitting the command at all commas and ignoring any quotes that indicate grouping.
Comment 2 Dominic Cleal 2014-09-15 04:05:02 EDT
Created redmine issue http://projects.theforeman.org/issues/7433 from this bug
Comment 3 Martin Bacovsky 2014-09-15 07:37:08 EDT
Fix for this issue is included in rubygem-hammer-cli-0.1.3. The PR is
https://github.com/theforeman/hammer-cli/pull/137.

With the patch applied the format of the correct command would be (the list needs to be enclosed in the square brackets, no spaces):

hammer host create --name "test.example.org" --build true --enabled true --managed true --environment-id 1 --ip "192.168.10.10" --mac "02:00:00:00:00:b0" --subnet-id 1 --architecture-id 1 --medium-id 8 --partition-table-id 11 --root-password changeme --parameters "subscription_manager=true,subscription_manager_username=smuser,subscription_manager_password=smpass,subscription_manager_repos=[rhel-server-rhscl-6-rpms,rhel-6-server-rpms,rhel-6-server-openstack-5.0-rpms],subscription_manager_pool=34gf434gf34f34f4442"
Comment 4 Bryan Kearney 2015-01-09 10:16:57 EST
Connecting redmine issue http://projects.theforeman.org/issues/7133 from this bug
Comment 7 Elyézer Rezende 2015-03-09 14:38:34 EDT
Failed on: Satellite-6.1.0-RHEL-7-20150303.0
# rpm -qa | grep hammer
rubygem-hammer_cli_foreman_discovery-0.0.1.2-1.el7sat.noarch
rubygem-hammer_cli_katello-0.0.7.3-1.el7sat.noarch
rubygem-hammer_cli_foreman_bootdisk-0.1.2.5-1.el7sat.noarch
rubygem-hammer_cli_import-0.10.6.3-1.el7sat.noarch
rubygem-hammer_cli-0.1.4.3-1.el7sat.noarch
rubygem-hammer_cli_foreman-0.1.4.6-1.el7sat.noarch
rubygem-hammer_cli_gutterball-0.0.1.2-1.el7sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3.3-1.el7sat.noarch

Tried to run using the same example in the steps to reproduce:

[root@rhsm-qe-4 ~]# hammer -u admin -p changeme host create --name "bass" --mac "aa:aa:aa:dd:ee:ff"  --domain-id 1 --location-id 2 --organization-id 1 --environment-id 1 --architecture-id 1 --operatingsystem-id 1 --medium-id 8 --partition-table-id 7 --root-password "password" --puppet-proxy-id 1 --parameters subscription_manager=true,subscription_manager_username=smuser,subscription_manager_password=smpass,subscription_manager_repos="rhel-server-rhscl-6-rpms, rhel-6-server-rpms, rhel-6-server-openstack-5.0-rpms",subscription_manager_pool=34gf434gf34f34f4442
Could not create the host:
  Error: option '--parameters': value must be defined as a comma-separated list of key=value

  See: 'hammer host create --help'

Also tried to wrap into single quotes the parameters value:


[root@sat6 ~]# hammer -u admin -p changeme host create --name "bass" --mac "aa:aa:aa:dd:ee:ff"  --domain-id 1 --location-id 2 --organization-id 1 --environment-id 1 --architecture-id 1 --operatingsystem-id 1 --medium-id 8 --partition-table-id 7 --root-password "password" --puppet-proxy-id 1 --parameters 'subscription_manager=true,subscription_manager_username=smuser,subscription_manager_password=smpass,subscription_manager_repos="rhel-server-rhscl-6-rpms, rhel-6-server-rpms, rhel-6-server-openstack-5.0-rpms",subscription_manager_pool=34gf434gf34f34f4442'
Could not create the host:
  Error: option '--parameters': value must be defined as a comma-separated list of key=value

  See: 'hammer host create --help'
Comment 8 Tomas Strachota 2015-03-12 11:28:43 EDT
Elyézer, the format of specifying arrays in key-value parameters is actually a bit different. Martin describes it in a comment above. You need to enclose the list by []. In your commant it would be:

--parameters 'subscription_manager=true,subscription_manager_username=smuser,subscription_manager_password=smpass,subscription_manager_repos=[rhel-server-rhscl-6-rpms,rhel-6-server-rpms,rhel-6-server-openstack-5.0-rpms],subscription_manager_pool=34gf434gf34f34f4442'

Note the brackets after subscription_manager_repos=
Can you verify the command works when you use square brackets, please?


FYI I came accross a different issue with key-values params when I tested this one. Reported here:
https://bugzilla.redhat.com/show_bug.cgi?id=1201364
Comment 9 Elyézer Rezende 2015-05-04 09:04:51 EDT
Using the recommended format also does not work:

# hammer -u admin -p changeme host create --name "bass" --mac "aa:aa:aa:dd:ee:ff"  --domain-id 1 --location-id 2 --organization-id 1 --environment-id 1 --architecture-id 1 --operatingsystem-id 1 --medium-id 8 --partition-table-id 7 --root-password "password" --puppet-proxy-id 1 --parameters 'subscription_manager=true,subscription_manager_username=smuser,subscription_manager_password=smpass,subscription_manager_repos=[rhel-server-rhscl-6-rpms,rhel-6-server-rpms,rhel-6-server-openstack-5.0-rpms],subscription_manager_pool=34gf434gf34f34f4442'
Could not create the host:
  undefined method `strip!' for #<Array:0x0000000e09b3f8>
Comment 10 Tomas Strachota 2015-05-19 08:28:24 EDT
There's another issue that prevents from setting parameters on hosts:
http://projects.theforeman.org/issues/10547

Upstream patch created and ready for review.
Comment 12 errata-xmlrpc 2015-08-12 01:16:26 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/RHSA-2015:1592
Comment 13 sthirugn@redhat.com 2015-08-14 16:45:29 EDT
Accidentally closed with 6.1.1 errata
Comment 15 Marek Hulan 2016-06-06 09:53:20 EDT
Verified.

Version Tested:
satellite-6.2.0-14.2.el7sat.noarch

Following command worked as expected 

    hammer host create --managed false --name "test2.example.org" --build false --environment-id 1 --location 'Default Location' --organization 'Default Organization' --parameters 'subscription_manager=true,subscription_manager_username=smuser,subscription_manager_password=smpass,subscription_manager_repos=[rhel-server-rhscl-6-rpms,rhel-6-server-rpms,rhel-6-server-openstack-5.0-rpms],subscription_manager_pool=34gf434gf34f34f4442'

Additional information:
rpm -qa | grep hammer
tfm-rubygem-hammer_cli-0.5.1.10-1.el7sat.noarch
tfm-rubygem-hammer_cli_foreman_remote_execution-0.0.5.3-1.el7sat.noarch
tfm-rubygem-hammer_cli_foreman_bootdisk-0.1.3.2-1.el7sat.noarch
tfm-rubygem-hammer_cli_foreman_tasks-0.0.10.2-1.el7sat.noarch
tfm-rubygem-hammer_cli_katello-0.0.22.13-2.el7sat.noarch
tfm-rubygem-hammer_cli_foreman_docker-0.0.5-1.el7sat.noarch
tfm-rubygem-hammer_cli_csv-2.0.0.1-1.el7sat.noarch
tfm-rubygem-hammer_cli_import-0.10.23-1.el7sat.noarch
tfm-rubygem-hammer_cli_foreman-0.5.1.8-1.el7sat.noarch
tfm-rubygem-hammer_cli_foreman_discovery-0.0.2.2-1.el7sat.noarch
Comment 16 Bryan Kearney 2016-07-27 07:41:31 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.