Red Hat Bugzilla – Bug 1325989
GET/POST/PUT /api/v2/host_collections/ do not return 'host_ids' attribute
Last modified: 2016-09-14 17:00:04 EDT
Description of problem: As per 6.2 changes, host_collections now accept host ids instead of system ids. Creation of host collection with hosts associated is successful, however it seems not possible to validate it through API - none of GET/POST/PUT requests return 'host_ids' attribute. Version-Release number of selected component (if applicable): Satellite 6.2 Beta Snap7.1 How reproducible: Always Steps to Reproduce: 1. Create host collection with hosts specified ('host_ids' attribute). E.g.: HTTP POST to https://example.com/katello/api/v2/host_collections with data {"organization_id": 6, "host_ids": [4, 5], "name": "test_host_collection"} 2. Capture the response. Examine the JSON payload and discover that the "host_ids" attribute is not mentioned. 3. Issue HTTP GET and HTTP PUT requests to previously created host_collection. Check the "host_ids" attribute presence. Actual results: 'host_ids' attribute is absent in GET/POST/PUT responses. Expected results: 'host_ids' attribute is present and contains a list of associated hosts ids. Additional info:
Created redmine issue http://projects.theforeman.org/issues/14712 from this bug
Upstream katello PR: https://github.com/Katello/katello/pull/5983
FailedQA in Satellite 6.2.0 GA Snap 10.0 GET and POST now have `host_ids` attribute, but PUT is still missing it. >>> # GET ... >>> entities.HostCollection(id=1).read() 2016-05-06 17:14:46 - nailgun.client - DEBUG - Making HTTP GET request to https://example.com/katello/api/v2/host_collections/1 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and no data. 2016-05-06 17:14:47 - nailgun.client - DEBUG - Received HTTP 200 response: {"host_ids":[],"name":"𪦱𥄆䇁𣛤쐥𝗭쵶콹씉秚𩪵𤤯寇𤱂𢪧츜鉿𨛨铽눵𤓦𓇸쨅𣎔𦴻휵","organization_id":130,"max_hosts":null,"description":"kmBvKnosCRqiipfXsmzizZRYblVYPplBFV","total_hosts":0,"unlimited_hosts":true,"created_at":"2016-05-06 03:02:28 UTC","updated_at":"2016-05-06 03:02:28 UTC","id":1,"permissions":{"deletable":true,"editable":true}} >>> # POST ... >>> entities.HostCollection().create() 2016-05-06 17:15:59 - nailgun.client - DEBUG - Making HTTP POST request to https://example.com/katello/api/v2/host_collections with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and data {"organization_id": 1387, "name": "\u60ca\u8d36\u7bc4\ud84a\udce2\ud851\udef8\uac1d\ud800\udf0f\ud843\udc63\ud86d\udeb3\ud843\uddc5\ud86a\udd8c\ud864\udd8f\ud85d\udc79\ubd35\u8cff\ud84f\ude17\ua13a"}. 2016-05-06 17:16:00 - nailgun.client - DEBUG - Received HTTP 200 response: {"host_ids":[],"name":"惊贶範𢣢𤛸객𐌏𠱣𫚳𠷅𪦌𩆏𧑹봵賿𣸗ꄺ","organization_id":1387,"max_hosts":null,"description":null,"total_hosts":0,"unlimited_hosts":true,"created_at":"2016-05-06 14:16:00 UTC","updated_at":"2016-05-06 14:16:00 UTC","id":100,"permissions":{"deletable":true,"editable":true}} >>> # PUT ... >>> entities.HostCollection(id=1).update() 2016-05-06 17:17:49 - nailgun.client - DEBUG - Making HTTP PUT request to https://example.com/katello/api/v2/host_collections/1 with options {'verify': False, 'auth': ('admin', 'changeme'), 'headers': {'content-type': 'application/json'}} and data {"id": 1}. 2016-05-06 17:17:50 - nailgun.client - DEBUG - Received HTTP 200 response: {"name":"𪦱𥄆䇁𣛤쐥𝗭쵶콹씉秚𩪵𤤯寇𤱂𢪧츜鉿𨛨铽눵𤓦𓇸쨅𣎔𦴻휵","organization_id":130,"max_hosts":null,"description":"kmBvKnosCRqiipfXsmzizZRYblVYPplBFV","total_hosts":0,"unlimited_hosts":true,"created_at":"2016-05-06 03:02:28 UTC","updated_at":"2016-05-06 03:02:28 UTC","id":1,"permissions":{"deletable":true,"editable":true}}
Upstream katello PR to address comment 5: https://github.com/Katello/katello/pull/6141 Good catch Andrii!
GET https://<sat host>.redhat.com/katello/api/host_collections/1 { "host_ids": [ 2, 35, 26, 27, 30, 31, 29, 33, 32, 34, 28 ], "name": "docker", "organization_id": 1, "max_hosts": null, "description": null, "total_hosts": 11, "unlimited_hosts": true, "created_at": "2016-09-01 18:51:36 UTC", "updated_at": "2016-09-01 18:51:36 UTC", "id": 1, "permissions": { "deletable": true, "editable": true } } POST https://<sat host>.redhat.com/katello/api/host_collections/ {"organization_id": 1, "host_ids": [4, 5], "name": "test_host_collection"} { "host_ids": [ 4, 5 ], "name": "test_host_collection", "organization_id": 1, "max_hosts": null, "description": null, "total_hosts": 2, "unlimited_hosts": true, "created_at": "2016-09-07 18:47:21 UTC", "updated_at": "2016-09-07 18:47:21 UTC", "id": 2, "permissions": { "deletable": true, "editable": true } } PUT https://<sat host>.redhat.com/katello/api/host_collections/2 {"name": "changed_host_collection"} { "host_ids": [ 4, 5 ], "name": "changed_host_collection", "organization_id": 1, "max_hosts": null, "description": null, "total_hosts": 2, "unlimited_hosts": true, "created_at": "2016-09-07 18:47:21 UTC", "updated_at": "2016-09-07 18:49:18 UTC", "id": 2, "permissions": { "deletable": true, "editable": true } }
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:1885