Bug 1129375 - issues with associating a content host with host collection(s)
Summary: issues with associating a content host with host collection(s)
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.0.4
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: Unspecified
Assignee: Walden Raines
QA Contact: sthirugn@redhat.com
URL: http://projects.theforeman.org/issues...
Whiteboard:
: 1131577 (view as bug list)
Depends On:
Blocks: 1131577
TreeView+ depends on / blocked
 
Reported: 2014-08-12 15:17 UTC by Tomas Lestach
Modified: 2019-09-26 18:08 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 1131577 (view as bug list)
Environment:
Last Closed: 2014-09-11 12:24:14 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 7091 0 Normal Closed issues with associating a content host with host collection(s) 2020-06-03 08:11:34 UTC

Description Tomas Lestach 2014-08-12 15:17:37 UTC
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

Comment 3 Walden Raines 2014-08-14 15:30:05 UTC
Created redmine issue http://projects.theforeman.org/issues/7091 from this bug

Comment 4 Walden Raines 2014-08-15 19:23:50 UTC
(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).

Comment 5 Tomas Lestach 2014-08-18 08:35:56 UTC
> 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.

Comment 6 Bryan Kearney 2014-08-18 10:04:47 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/7091 has been closed

Comment 7 Tomas Lestach 2014-08-18 10:11:52 UTC
Reopening, as the bug wasn't fixed yet.

Comment 8 Bryan Kearney 2014-08-18 12:04:45 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/7091 has been closed

Comment 10 Tomas Lestach 2014-08-20 09:44:46 UTC
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.

Comment 11 Walden Raines 2014-08-20 13:49:56 UTC
(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.

Comment 12 Bryan Kearney 2014-08-20 14:04:42 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/7091 has been closed

Comment 13 Walden Raines 2014-08-20 17:18:37 UTC
PR: https://github.com/Katello/katello/pull/4594

Comment 14 Bryan Kearney 2014-08-20 18:04:33 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/7091 has been closed
-------------
Walden Raines
Applied in changeset commit:katello|a239724dc797eda404ab45c99a068f10ff6b1100.

Comment 15 Tomas Lestach 2014-08-21 08:03:14 UTC
*** Bug 1131577 has been marked as a duplicate of this bug. ***

Comment 18 sthirugn@redhat.com 2014-08-29 21:29:29 UTC
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

Comment 19 Bryan Kearney 2014-09-11 12:24:14 UTC
This was delivered with Satellite 6.0 which was released on 10 September 2014.


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