Description of problem: I'm unable to associate a content host with a host collection via API - POST won't make the association, PUT does not expect appropriate parameter Version-Release number of selected component (if applicable): Satellite-6.0.4-RHEL-6-20140806.0-Satellite-x86_64 + applied https://github.com/Katello/katello/pull/4508 How reproducible: always Steps to Reproduce: 1. create host collecition: curl -s -H "Content-Type:application/json" -H "Accept:application/json,version=2" -k -u admin:changeme -d '{"organization_id":1, "name":"group1"}' $(hostname)/katello/api/host_collections {"created_at":"2014-08-12T14:51:15Z","updated_at":"2014-08-12T14:51:15Z","name":"group1","organization_id":1,"max_content_hosts":null,"description":null,"total_content_hosts":0,"unlimited_content_hosts":true,"system_ids":[],"id":4,"permissions":{"deletable":true,"editable":true}} 2. try to register a content host associated with the host collection: curl -s -H "Content-Type:application/json" -H "Accept:application/json,version=2" -k -u admin:changeme -d '{"type":"system", "facts":{"release":"6Server", "architecture":"x86_64"}, "host_colletion_id":"4", "organization_id":1, "description":"not relevant", "name":"mysystem-123.example.com"}' $(hostname)/katello/api/systems {"id":7,"uuid":"9c507ad1-482f-47bc-8ddd-aaf196e836dd","name":"mysystem-123.example.com","description":"not relevant","location":"None","content_view":{"id":1,"name":"Default Organization View","label":"Default_Organization_View","description":null,"organization_id":1,"default":true,"created_at":"2014-08-08T15:11:41Z","updated_at":"2014-08-08T15:11:41Z","composite":null,"next_version":1,"organization":"Default_Organization","environments":["Library"],"versions":[1],"versions_details":[{"version":1,"published":"2014-08-08 15:11:41 UTC","environments":["Library"]}]},"content_view_id":1,"distribution":" ","content_overrides":[],"entitlementStatus":"valid","autoheal":true,"href":"/consumers/9c507ad1-482f-47bc-8ddd-aaf196e836dd","release":null,"checkin_time":null,"created":"2014-08-12T14:57:19.092+0000","installedProducts":[],"service_level":"","release_ver":null,"permissions":{"editable":true},"products":[],"host":null,"hostCollections":[],"customInfo":[],"environment":{"id":1,"name":"Library","label":"Library","description":null,"organization":{"name":"Default_Organization","label":"Default_Organization"},"created_at":"2014-08-08T15:11:39Z","updated_at":"2014-08-08T15:11:39Z","library":true,"prior":null,"permissions":{"view_lifecycle_environments":true,"edit_lifecycle_environments":true,"destroy_lifecycle_environments":true,"promote_or_remove_content_views_to_environments":true}},"activation_keys":[]} Actual results: 1) content host wasn't associated with the host collection ("hostCollections":[]) - it isn't associated, even if I pass host_collection_id as integer or - as an array as I would expect 2) apidoc/v2/systems/create says the value of "host_collection_id" is "Value: String" 3) "host_collection_id" is missing among the /apidoc/v2/systems/update parameters Expected results: 1) content host created with host collection association 2) expect an array (not a string) for the host_collection_id parameter, as a content host may be associated with multiple host collections 3) content host update shall make it possible to update host collection association Additional info: transition tooling is dependent on these APIs
Created redmine issue http://projects.theforeman.org/issues/7091 from this bug
(In reply to Tomas Lestach from comment #0) > 2. try to register a content host associated with the host collection: > curl -s -H "Content-Type:application/json" -H > "Accept:application/json,version=2" -k -u admin:changeme -d > '{"type":"system", "facts":{"release":"6Server", "architecture":"x86_64"}, > "host_colletion_id":"4", "organization_id":1, "description":"not relevant", > "name":"mysystem-123.example.com"}' $(hostname)/katello/api/systems > {"id":7,"uuid":"9c507ad1-482f-47bc-8ddd-aaf196e836dd","name":"mysystem-123. > example.com","description":"not > relevant","location":"None","content_view":{"id":1,"name":"Default > Organization > View","label":"Default_Organization_View","description":null, > "organization_id":1,"default":true,"created_at":"2014-08-08T15:11:41Z", > "updated_at":"2014-08-08T15:11:41Z","composite":null,"next_version":1, > "organization":"Default_Organization","environments":["Library"],"versions": > [1],"versions_details":[{"version":1,"published":"2014-08-08 15:11:41 > UTC","environments":["Library"]}]},"content_view_id":1,"distribution":" > ","content_overrides":[],"entitlementStatus":"valid","autoheal":true,"href": > "/consumers/9c507ad1-482f-47bc-8ddd-aaf196e836dd","release":null, > "checkin_time":null,"created":"2014-08-12T14:57:19.092+0000", > "installedProducts":[],"service_level":"","release_ver":null,"permissions": > {"editable":true},"products":[],"host":null,"hostCollections":[], > "customInfo":[],"environment":{"id":1,"name":"Library","label":"Library", > "description":null,"organization":{"name":"Default_Organization","label": > "Default_Organization"},"created_at":"2014-08-08T15:11:39Z","updated_at": > "2014-08-08T15:11:39Z","library":true,"prior":null,"permissions": > {"view_lifecycle_environments":true,"edit_lifecycle_environments":true, > "destroy_lifecycle_environments":true, > "promote_or_remove_content_views_to_environments":true}},"activation_keys": > []} This JSON is incorrect. It should be "host_collection_ids":[2] not "host_colletion_id":"4" (not the misspelling and the string instead of an array).
> This JSON is incorrect. It should be "host_collection_ids":[2] not > "host_colletion_id":"4" (not the misspelling and the string instead of an > array). This JSON is built according to the apidoc documentation. Just visit https://<sat6_fqdn>/apidoc/v2/systems/create.html and see: host_collection_id Value: String If you would read the bug report, you would find out the API does not work even if I pass host_collection_id as an array. Reopening as none of the reported issues were addressed.
Moving to POST since upstream bug http://projects.theforeman.org/issues/7091 has been closed
Reopening, as the bug wasn't fixed yet.
Right, there's a typo in the curl command. And passing host collection ids as "host_collection_ids" creates the association. However, there're still two unresolved issues: * API documentation is still wrong: host_collection_id /optional/ Specify the host collection / Value: String * there's no possibility to update the host collection association, as PUT /katello/api/systems/:id API does not expect host_collection_id(s) parameter -at least according to the documentation The user has no possibility to find out, he shall use host_collection_ids instead of host_collection_id, in case the API documentation is wrong.
(In reply to Tomas Lestach from comment #10) > Right, there's a typo in the curl command. And passing host collection ids > as "host_collection_ids" creates the association. > > However, there're still two unresolved issues: > * API documentation is still wrong: > host_collection_id /optional/ Specify the host collection / Value: String > > * there's no possibility to update the host collection association, as PUT > /katello/api/systems/:id API does not expect host_collection_id(s) parameter > -at least according to the documentation > > > The user has no possibility to find out, he shall use host_collection_ids > instead of host_collection_id, in case the API documentation is wrong. I will fix these issues.
PR: https://github.com/Katello/katello/pull/4594
Moving to POST since upstream bug http://projects.theforeman.org/issues/7091 has been closed ------------- Walden Raines Applied in changeset commit:katello|a239724dc797eda404ab45c99a068f10ff6b1100.
*** Bug 1131577 has been marked as a duplicate of this bug. ***
Verified. The following commands created the content-host and associated it to the required host collection # curl -s -H "Content-Type:application/json" -H "Accept:application/json" -k -u admin:changeme -d '{"type":"system", "facts":{"Release":"6Server", "Architecture":"x86_64"}, "host_collection_ids":[7], "organization_id":3, "description":"not relevant", "name":"mysystem-12345.example.com"}' https://$host/katello/api/systems # curl -s -H "Content-Type:application/json" -H "Accept:application/json" -k -u admin:changeme -d '{"type":"system", "facts":{"Release":"6Server", "Architecture":"x86_64"}, "host_collection_ids":[7,3], "organization_id":3, "description":"not relevant", "name":"mysystem-123456.example.com"}' https://$host/katello/api/systems Also API docs https://cloud-qe-14.idm.lab.bos.redhat.com/apidoc/v2/systems/create.html show: host_collection_ids Specify the host collections as an array optional Value: Must be an array of any type Version Tested: GA Snap 7 - Satellite-6.0.4-RHEL-6-20140828.0 * apr-util-ldap-1.3.9-3.el6_0.1.x86_64 * candlepin-0.9.23-1.el6_5.noarch * candlepin-common-1.0.1-1.el6_5.noarch * candlepin-scl-1-5.el6_4.noarch * candlepin-scl-quartz-2.1.5-5.el6_4.noarch * candlepin-scl-rhino-1.7R3-1.el6_4.noarch * candlepin-scl-runtime-1-5.el6_4.noarch * candlepin-selinux-0.9.23-1.el6_5.noarch * candlepin-tomcat6-0.9.23-1.el6_5.noarch * elasticsearch-0.90.10-6.el6sat.noarch * foreman-1.6.0.42-1.el6sat.noarch * foreman-compute-1.6.0.42-1.el6sat.noarch * foreman-gce-1.6.0.42-1.el6sat.noarch * foreman-libvirt-1.6.0.42-1.el6sat.noarch * foreman-ovirt-1.6.0.42-1.el6sat.noarch * foreman-postgresql-1.6.0.42-1.el6sat.noarch * foreman-proxy-1.6.0.30-1.el6sat.noarch * foreman-selinux-1.6.0.14-1.el6sat.noarch * foreman-vmware-1.6.0.42-1.el6sat.noarch * katello-1.5.0-30.el6sat.noarch * katello-ca-1.0-1.noarch * katello-certs-tools-1.5.6-1.el6sat.noarch * katello-installer-0.0.62-1.el6sat.noarch * openldap-2.4.23-34.el6_5.1.x86_64 * openldap-devel-2.4.23-34.el6_5.1.x86_64 * pulp-katello-0.3-4.el6sat.noarch * pulp-nodes-common-2.4.1-0.5.rc1.el6sat.noarch * pulp-nodes-parent-2.4.1-0.5.rc1.el6sat.noarch * pulp-puppet-plugins-2.4.1-0.5.rc1.el6sat.noarch * pulp-puppet-tools-2.4.1-0.5.rc1.el6sat.noarch * pulp-rpm-plugins-2.4.1-0.5.rc1.el6sat.noarch * pulp-selinux-2.4.1-0.5.rc1.el6sat.noarch * pulp-server-2.4.1-0.5.rc1.el6sat.noarch * python-ldap-2.3.10-1.el6.x86_64 * ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch * ruby193-rubygem-runcible-1.1.0-2.el6sat.noarch
This was delivered with Satellite 6.0 which was released on 10 September 2014.