Bug 1235380

Summary: PUT /api/v2/hostgroups/:id returns misnamed attribute
Product: Red Hat Satellite Reporter: jaudet
Component: APIAssignee: alon <agoldboi>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.1.0CC: bkearney, fsimonce, jcallaha, orabin, tbrisker
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 08:53:09 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: 1216236    
Bug Blocks:    
Attachments:
Description Flags
Output of foreman-debug from a Satellite 6.1.0 system running RHEL 6.6. none

Description jaudet 2015-06-24 16:19:05 UTC
Created attachment 1042788 [details]
Output of foreman-debug from a Satellite 6.1.0 system running RHEL 6.6.

Description of problem:
A hostgroup has an attribute named "parent". I know this because:

* The API documentation states that one can issue an HTTP POST request to
  `/api/v2/hostgroups` and provide a `hostgroup[parent_id]` attribute.
  Hands-on experience shows that this works.
* The API documentation states that one can issue an HTTP PUT request to
  `/api/v2/hostgroups/:id` and provide a `hostgroup[parent_id]` attribute.
  Hands-on experience shows that this works.

The server responds to HTTP PUT requests to `/api/v2/hostgroups/:id` with a JSON
payload that does not include a "parent" attribute. However, this payload
includes a semantically identical attribute named "ancestors". This mismatch is
disorienting and makes using the API harder.

Version-Release number of selected component (if applicable):
Satellite 6.1.0. Foreman-debug is attached.

How reproductible:
100%

Steps to Reproduce:
1. Issue an HTTP PUT request to `/api/v2/hostgroups/:id`.
2. Capture the response and examine the keys in the JSON payload.
3. Discover that "parent" is missing, but an equivalent attribute named
   "ancestors" is returned.

Actual results:
See above.

Expected results:
See above

Additional info:

Comment 1 RHEL Program Management 2015-06-24 16:22:36 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Tomer Brisker 2016-04-12 12:54:01 UTC
This has been resolved in current 6.2 snaps, moving to ON_QA for verification.
Note for verification: the attribute is named "parent_name", not "parent".

Comment 4 jcallaha 2016-05-25 17:39:57 UTC
Verified in Satellite 6.2 Beta Snap 12.

{
  "content_source_id": 1,
  "content_source_name": "rhsm-qe-1.rhq.lab.eng.bos.redhat.com",
  "content_view_id": 2,
  "content_view_name": "rhel7 beta",
  "lifecycle_environment_id": 1,
  "lifecycle_environment_name": "Library",
  "subnet_id": null,
  "subnet_name": null,
  "operatingsystem_id": null,
  "operatingsystem_name": null,
  "domain_id": null,
  "domain_name": null,
  "environment_id": null,
  "environment_name": null,
  "compute_profile_id": null,
  "compute_profile_name": null,
  "ancestry": null,
  "parent_id": null,
  "parent_name": null,
  "puppet_proxy_id": 1,
  "puppet_ca_proxy_id": 1,
  "ptable_id": null,
  "ptable_name": null,
  "medium_id": null,
  "medium_name": null,
  "architecture_id": null,
  "architecture_name": null,
  "realm_id": null,
  "realm_name": null,
  "created_at": "2016-05-25 17:30:41 UTC",
  "updated_at": "2016-05-25 17:30:41 UTC",
  "id": 1,
  "name": "hosts1",
  "title": "hosts1",
  "parameters": [
    {
      "id": 1,
      "name": "kt_activation_keys",
      "value": "rhel7 beta"
    }
  ],
  "template_combinations": [],
  "puppetclasses": [],
  "config_groups": [],
  "all_puppetclasses": [],
  "locations": [
    {
      "id": 2,
      "name": "Default Location",
      "title": "Default Location",
      "description": null
    }
  ],
  "organizations": [
    {
      "id": 1,
      "name": "Default Organization",
      "title": "Default Organization",
      "description": null
    }
  ]
}

Comment 6 errata-xmlrpc 2016-07-27 08:53:09 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:1500