Bug 1327244 - POST/PUT /api/v2/hosts (host create/update) does not document the lifecycle_environment_id and content_view_id options.
Summary: POST/PUT /api/v2/hosts (host create/update) does not document the lifecycle_e...
Alias: None
Product: Red Hat Satellite 6
Classification: Red Hat
Component: API
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
medium vote
Target Milestone: Unspecified
Assignee: Justin Sherrill
QA Contact: Lukas Zapletal
URL: http://projects.theforeman.org/issues...
Depends On:
TreeView+ depends on / blocked
Reported: 2016-04-14 14:43 UTC by Andrii Balakhtar
Modified: 2019-04-01 20:27 UTC (History)
5 users (show)

Fixed In Version: rubygem-katello-
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2016-07-27 11:22:37 UTC

Attachments (Terms of Use)

System ID Priority Status Summary Last Updated
Foreman Issue Tracker 15165 None None None 2016-05-24 16:07:37 UTC

Description Andrii Balakhtar 2016-04-14 14:43:59 UTC
Description of problem:
Seems like we can't create a host with content view and lifecycle environment associated via API - GET/POST/PUT simply do not accept/return content_view_id or lifecycle_environment_id attributes.
Before sat6.2 we used System path, which accepted content_view_id and environment_id, but that path was dropped in sat6.2. 

Version-Release number of selected component (if applicable):
Satellite 6.2 Beta Snap 8.1

How reproducible:

Steps to Reproduce:
1. Try to create a host with content view and lifecycle environment specified via API.
For exaple, HTTP POST to  https://example.com/api/v2/hosts {"host": {"operatingsystem_id": 193, "root_pass": "qwerty", "content_view_id": 1697, "mac": "b2:ac:20:44:98:f1", "location_id": 1720, "name": "nwemjcgqdeupt", "organization_id": 1719, "ptable_id": 265, "medium_id": 149, "domain_id": 153, "architecture_id": 137, "lifecycle_environment_id": 1637}}
2. Try to retrieve or update a host with content view and lifecycle environment specified.

Actual results:
Both 'content_view_id' and 'lifecycle_environment_id' are not accepted/returned.

Expected results:
'content_view_id' and 'lifecycle_environment_id' should be correctly accepted and returned by the server.

Additional info:

Comment 1 Andrii Balakhtar 2016-04-14 14:46:23 UTC
Note that /api/v2/hosts does accept 'environment_id', but that's puppet environment id, not lifecycle environment. If you try to pass lifecycle environment id, you'll receive smth like this:
Received HTTP 500 response: {
  "error": {"message":"ERROR:  insert or update on table \"hosts\" violates foreign key constraint \"hosts_environment_id_fk\"\nDETAIL:  Key (environment_id)=(1637) is not present in table \"environments\".\n"}

Comment 3 Justin Sherrill 2016-04-14 19:41:29 UTC

As part of 6.2 the host unification feature sought to unify hosts and content hosts.  As a result hosts now have 'facets' which contain additional information.  

You will want to modify your PUT request to look like:

PUT /api/v2/hosts/ID

  "content_facet_attributes": {
    "lifecycle_environment_id": 123,
    "content_view_id":  456

This is not currently documented as part of the apipie params, i will repurpose this bz for that.

Comment 4 Andrii Balakhtar 2016-04-14 20:54:45 UTC
Thanks for clarification. It's not only about PUT, POST is missing this info too, i'll update bug summary.

Also, just to clarify, user is supposed to pass ids in 'content_facet_attributes', but satellite returns them in 'content' (not 'content_facet_attributes'). Is it expected behavior?

Comment 5 Justin Sherrill 2016-04-18 14:46:34 UTC
Hi Andrii,

yes that was half technical issue half oversight, i've opened this bz to resolve that issue.  It will not make beta but will make 6.2 GA



Comment 6 Bryan Kearney 2016-05-16 15:06:44 UTC
Reading back, this appears to be 1/2 answered in the bug and 1/2 solved by https://bugzilla.redhat.com/show_bug.cgi?id=1328139 which is currently ON_QA. I am therefore closing this as NOTABUG. If I have missed anything, please let me know and I will re-open.

Comment 7 Justin Sherrill 2016-05-16 15:18:26 UTC
This is still a valid bug, as the options are not documented in https://bugzilla.redhat.com/show_bug.cgi?id=1328139

As per comment #3 (and the title change) this bz is still valid for documenting those api options.

Comment 8 Justin Sherrill 2016-05-24 15:52:39 UTC
Connecting redmine issue http://projects.theforeman.org/issues/15165 from this bug

Comment 9 Bryan Kearney 2016-05-24 18:15:03 UTC
Upstream bug component is API

Comment 10 Bryan Kearney 2016-05-26 16:18:30 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/15165 has been closed

Comment 11 Lukas Zapletal 2016-06-22 08:12:39 UTC
Looks like the change is present in SNAP 16:

[root@hp-dl360g7-01 ~]# rpm -q satellite katello foreman

[root@hp-dl360g7-01 ~]# cat /opt/theforeman/tfm/root/usr/share/gems/gems/katello-
module Katello
  class Api::V2::HostContentsController < Katello::Api::V2::ApiController
    def_param_group :content_facet_attributes  do
      param :content_view_id, Integer
      param :lifecycle_environment_id, Integer
      param :kickstart_repository_id, Integer, :desc => N_("Repository Id associated with the kickstart repo used for provisioning")

https://xxxx.brq.redhat.com/apidoc/v2/hosts/create.html contains:

optional , nil allowed	
Parameters for host's content_facet facet



optional , nil allowed	


optional , nil allowed	


optional , nil allowed	
Repository Id associated with the kickstart repo used for provisioning



Comment 12 Bryan Kearney 2016-07-27 11:22:37 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.


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