Hide Forgot
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:
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"}
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.
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?
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
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.
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.
Connecting redmine issue http://projects.theforeman.org/issues/15165 from this bug
Upstream bug component is API
Moving to POST since upstream bug http://projects.theforeman.org/issues/15165 has been closed
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
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