Red Hat Bugzilla – Bug 1141671
Cant specify comma spaced lists as values to the --parameters option.
Last modified: 2016-07-27 07:41:31 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.
Created redmine issue http://projects.theforeman.org/issues/7433 from this bug
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"
Connecting redmine issue http://projects.theforeman.org/issues/7133 from this bug
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'
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
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>
There's another issue that prevents from setting parameters on hosts: http://projects.theforeman.org/issues/10547 Upstream patch created and ready for review.
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
Accidentally closed with 6.1.1 errata
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
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