Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
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...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Justin Sherrill
QA Contact: Lukas Zapletal
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-04-14 14:43 UTC by Andrii Balakhtar
Modified: 2019-09-26 14:53 UTC (History)
5 users (show)

Fixed In Version: rubygem-katello-3.0.0.38-1
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-07-27 11:22:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 15165 0 Normal Closed Document facet attributes for hosts 2020-08-28 22:47:31 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:
Always

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.
3.

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
Hi,

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
Justin,
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

https://bugzilla.redhat.com/show_bug.cgi?id=1328139

-Justin

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
satellite-6.2.0-17.0.el7sat.noarch
katello-3.0.0-8.el7sat.noarch
foreman-1.11.0.39-1.el7sat.noarch

[root@hp-dl360g7-01 ~]# cat /opt/theforeman/tfm/root/usr/share/gems/gems/katello-3.0.0.51/app/controllers/katello/api/v2/host_contents_controller.rb
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")
    end
  end
end

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

host[content_facet_attributes] 
optional , nil allowed	
Parameters for host's content_facet facet

Validations:

Hash

host[content_facet_attributes][content_view_id] 
optional , nil allowed	
Validations:

Integer

host[content_facet_attributes][lifecycle_environment_id] 
optional , nil allowed	
Validations:

Integer

host[content_facet_attributes][kickstart_repository_id] 
optional , nil allowed	
Repository Id associated with the kickstart repo used for provisioning

Validations:

Integer

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.

https://access.redhat.com/errata/RHBA-2016:1501


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