Bug 1141671

Summary: Cant specify comma spaced lists as values to the --parameters option.
Product: Red Hat Satellite Reporter: Dominic Cleal <dcleal>
Component: HammerAssignee: Tomas Strachota <tstrachota>
Status: CLOSED ERRATA QA Contact: Marek Hulan <mhulan>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.2CC: bkearney, erezende, joherr, mbacovsk, mburns, mhulan, ohochman, rhos-maint, srevivo, sthirugn
Target Milestone: UnspecifiedKeywords: Reopened, Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Linux   
URL: http://projects.theforeman.org/issues/7133
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1140393 Environment:
Last Closed: 2016-07-27 11:41:31 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: 1272979    
Bug Blocks: 1140393    

Description Dominic Cleal 2014-09-15 08:03:04 UTC
+++ 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 08:05:02 UTC
Created redmine issue http://projects.theforeman.org/issues/7433 from this bug

Comment 3 Martin Bacovsky 2014-09-15 11:37:08 UTC
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 15:16:57 UTC
Connecting redmine issue http://projects.theforeman.org/issues/7133 from this bug

Comment 7 Elyézer Rezende 2015-03-09 18:38:34 UTC
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 15:28:43 UTC
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 13:04:51 UTC
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 12:28:24 UTC
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 05:16:26 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/RHSA-2015:1592

Comment 13 sthirugn@redhat.com 2015-08-14 20:45:29 UTC
Accidentally closed with 6.1.1 errata

Comment 15 Marek Hulan 2016-06-06 13:53:20 UTC
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 11:41:31 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