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 1114065 - broken API for registering a content host
Summary: broken API for registering a content host
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.0.3
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: Dustin Tsang
QA Contact: sthirugn@redhat.com
URL: http://projects.theforeman.org/issues...
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-27 15:29 UTC by Tomas Lestach
Modified: 2019-09-26 18:10 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-11 12:24:01 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 7024 0 None None None 2016-04-22 16:16:19 UTC

Description Tomas Lestach 2014-06-27 15:29:46 UTC
Description of problem:
API for creating a content host fails with: "Cp type is not included in the list". cp type isn't among the list of required API parameters.

Version-Release number of selected component (if applicable):
Satellite-6.0.3-RHEL-6-20140619.0-Satellite-x86_64

How reproducible:
always

Steps to Reproduce:
1. call API to create/register a content host:

curl -s -H "Content-Type:application/json" -H "Accept:application/json,version=2" -k -u admin:changeme -X POST -d'{"name":"one", "organization_id":1, "type":"content host", "facts":{"1":1}}' `hostname`/katello/api/systems


Actual results:
API fails with:
{
    "displayMessage": "Validation failed: Cp type is not included in the list", 
    "errors": {
        "cp_type": [
            "is not included in the list"
        ]
    }
}


Expected results:
content host created/registered

Additional info:
This is a blocker for system profile migration from Sat5.

Comment 2 Dustin Tsang 2014-06-30 19:22:33 UTC
redmine issue created

Comment 3 Bryan Kearney 2014-07-02 22:04:55 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/6448 has been closed

Comment 4 Dustin Tsang 2014-07-02 22:10:31 UTC
type being sent should be 'system'.

Previously, the apipie docs asked the user to enter 'content host' as the type. That actually isn't a valid candlepin type. I updated the docs to ask for 'system'.

I also allowed the creation of a system/content-host without having to specify a type.

Comment 6 sthirugn@redhat.com 2014-08-10 14:35:16 UTC
Failed.

Using content-host:
# curl -s -H "Content-Type:application/json" -H "Accept:application/json,version=2" -k -u admin:changeme -X POST -d'{"name":"one", "organization_id":3, "type":"content-host", "facts":{"1":1}}' https://host/katello/api/systems

{"displayMessage":"undefined method `default_environment' for #<User:0x0000000e3c3530>","errors":["undefined method `default_environment' for #<User:0x0000000e3c3530>"]}


Using system:
curl -s -H "Content-Type:application/json" -H "Accept:application/json,version=2" -k -u admin:changeme -X POST -d'{"name":"one", "organization_id":3, "type":"system", "facts":{"1":1}}' https://host/katello/api/systems

{"displayMessage":"undefined method `default_environment' for #<User:0x007fe65088be98>","errors":["undefined method `default_environment' for #<User:0x007fe65088be98>"]}


Using content host:
# curl -s -H "Conte"Accept:application/json,version=2" -k -u admin:changeme -X POST -d'{"name":"one", "organization_id":3, "type":"content host", "facts":{"1":1}}' https://host/katello/api/systems

{"displayMessage":"undefined method `default_environment' for #<User:0x0000000d84cd00>","errors":["undefined method `default_environment' for #<User:0x0000000d84cd00>"]}

Version Tested:
GA Snap 4 - Satellite-6.0.4-RHEL-6-20140806.0

* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.9.19-1.el6_5.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.9.19-1.el6_5.noarch
* candlepin-tomcat6-0.9.19-1.el6_5.noarch
* elasticsearch-0.90.10-4.el6sat.noarch
* foreman-1.6.0.38-1.el6sat.noarch
* foreman-compute-1.6.0.38-1.el6sat.noarch
* foreman-gce-1.6.0.38-1.el6sat.noarch
* foreman-libvirt-1.6.0.38-1.el6sat.noarch
* foreman-ovirt-1.6.0.38-1.el6sat.noarch
* foreman-postgresql-1.6.0.38-1.el6sat.noarch
* foreman-proxy-1.6.0.23-1.el6sat.noarch
* foreman-selinux-1.6.0.4-1.el6sat.noarch
* foreman-vmware-1.6.0.38-1.el6sat.noarch
* katello-1.5.0-28.el6sat.noarch
* katello-ca-1.0-1.noarch
* katello-certs-tools-1.5.6-1.el6sat.noarch
* katello-installer-0.0.57-1.el6sat.noarch
* openldap-2.4.23-34.el6_5.1.x86_64
* pulp-katello-0.3-3.el6sat.noarch
* pulp-nodes-common-2.4.0-0.30.beta.el6sat.noarch
* pulp-nodes-parent-2.4.0-0.30.beta.el6sat.noarch
* pulp-puppet-plugins-2.4.0-0.30.beta.el6sat.noarch
* pulp-puppet-tools-2.4.0-0.30.beta.el6sat.noarch
* pulp-rpm-plugins-2.4.0-0.30.beta.el6sat.noarch
* pulp-selinux-2.4.0-0.30.beta.el6sat.noarch
* pulp-server-2.4.0-0.30.beta.el6sat.noarch
* python-ldap-2.3.10-1.el6.x86_64
* ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch
* ruby193-rubygem-runcible-1.1.0-2.el6sat.noarch
* sssd-ldap-1.11.5.1-3.el6.x86_64

Comment 7 Dustin Tsang 2014-08-11 20:34:51 UTC
different issue is causing problems in systems api. changing the redmine issue.

Comment 10 sthirugn@redhat.com 2014-08-14 04:32:02 UTC
Verified.

Step 1: Tried the same command from bug description and got an error message that there is more than one environment
# curl -X POST -H "Accept:application/json" -H "Content-Type: application/json" -u admin:changeme --insecure -d '{"type":"system","facts":{"1":"1"}, "organization_id":3, "name":"testsystem1.redhat.com"}' https://host/katello/api/systems
{"displayMessage":"Organization rhcorp has more than one environment. Please specify target environment for content host registration.","errors":["Organization rhcorp has more than one environment. Please specify target environment for content host registration."]}


Step 2: Passing the environment id. Got an error saying content view must be provided
# curl -X POST -H "Accept:application/json" -H "Content-Type: application/json" -u admin:changeme --insecure -d '{"type":"system","facts":{"1":"1"}, "organization_id":3, "name":"testsystem1.redhat.com","environment_id":3}' https://host/katello/api/systems
{"displayMessage":"Validation failed: Content view can't be blank","errors":{"content_view":["can't be blank"]}}


Step 3: Passing the content view id also.  Now it all works fine.

# curl -X POST -H "Accept:application/json" -H "Content-Type: application/json" -u admin:changeme --insecure -d '{"type":"system","facts":{"1":"1"}, "organization_id":3, "name":"testsystem1.redhat.com","environment_id":3, "content_view_id":3}' https://host/katello/api/systems

**Success - the content host is created.**

Version Tested:
GA Snap 5 - Satellite-6.0.4-RHEL-6-20140813.2

* apr-util-ldap-1.3.9-3.el6_0.1.x86_64
* candlepin-0.9.23-1.el6_5.noarch
* candlepin-common-1.0.1-1.el6_5.noarch
* candlepin-scl-1-5.el6_4.noarch
* candlepin-scl-quartz-2.1.5-5.el6_4.noarch
* candlepin-scl-rhino-1.7R3-1.el6_4.noarch
* candlepin-scl-runtime-1-5.el6_4.noarch
* candlepin-selinux-0.9.23-1.el6_5.noarch
* candlepin-tomcat6-0.9.23-1.el6_5.noarch
* elasticsearch-0.90.10-4.el6sat.noarch
* foreman-1.6.0.40-1.el6sat.noarch
* foreman-compute-1.6.0.40-1.el6sat.noarch
* foreman-gce-1.6.0.40-1.el6sat.noarch
* foreman-libvirt-1.6.0.40-1.el6sat.noarch
* foreman-ovirt-1.6.0.40-1.el6sat.noarch
* foreman-postgresql-1.6.0.40-1.el6sat.noarch
* foreman-proxy-1.6.0.27-1.el6sat.noarch
* foreman-selinux-1.6.0.6-1.el6sat.noarch
* foreman-vmware-1.6.0.40-1.el6sat.noarch
* katello-1.5.0-28.el6sat.noarch
* katello-ca-1.0-1.noarch
* katello-certs-tools-1.5.6-1.el6sat.noarch
* katello-installer-0.0.59-1.el6sat.noarch
* openldap-2.4.23-34.el6_5.1.x86_64
* openldap-devel-2.4.23-34.el6_5.1.x86_64
* pulp-katello-0.3-3.el6sat.noarch
* pulp-nodes-common-2.4.0-0.30.beta.el6sat.noarch
* pulp-nodes-parent-2.4.0-0.30.beta.el6sat.noarch
* pulp-puppet-plugins-2.4.0-0.30.beta.el6sat.noarch
* pulp-puppet-tools-2.4.0-0.30.beta.el6sat.noarch
* pulp-rpm-plugins-2.4.0-0.30.beta.el6sat.noarch
* pulp-selinux-2.4.0-0.30.beta.el6sat.noarch
* pulp-server-2.4.0-0.30.beta.el6sat.noarch
* python-ldap-2.3.10-1.el6.x86_64
* ruby193-rubygem-net-ldap-0.3.1-3.el6sat.noarch
* ruby193-rubygem-runcible-1.1.0-2.el6sat.noarch

Comment 11 sthirugn@redhat.com 2014-08-14 04:33:06 UTC
@Tomas Lestach: Can you please review my Comment 10 and let me know if you are okay with the behavior now?

Comment 12 Tomas Lestach 2014-08-18 08:57:48 UTC
Yes, the behavior is OK nad as expected with Satellite-6.0.4-RHEL-6-20140813.2-Satellite-x86_64.
(Except of the association content-host - host-collection reported in another BZ.)

$ curl -s -H "Content-Type:application/json" -H "Accept:application/json,version=2" -k -u admin:changeme -X POST -d "{\"host_colletion_id\":[1],\"type\":\"system\",\"description\":\"Initial Registration Parameters:\\nOS: redhat-release-server\\nRelease: 6Server\\nCPU Arch: x86_64\\nsat5_system_id: 1000020001\",\"content_view_id\":6,\"organization_id\":3,\"name\":\"vmware180.englab.brq.redhat.com\",\"facts\":{\"architecture\":\"x86_64\",\"release\":\"6Server\"}}" `hostname`/katello/api/systems
{"id":16,"uuid":"4b86c4bf-ce48-409c-ae0d-69f8d76f0277","name":"vmware180.englab.brq.redhat.com","description":"Initial Registration Parameters:\nOS: redhat-release-server\nRelease: 6Server\nCPU Arch: x86_64\nsat5_system_id: 1000020001","location":"None","content_view":{"id":6,"name":"Spacewalk nightly client","label":"Spacewalk_nightly_client","description":"Channel migrated from Satellite 5","organization_id":3,"default":false,"created_at":"2014-08-15T07:55:51Z","updated_at":"2014-08-15T07:55:51Z","composite":null,"next_version":2,"organization":"Galactic Empire","environments":["Library"],"versions":[1],"versions_details":[{"version":1,"published":"2014-08-15 07:55:51 UTC","environments":["Library"]}]},"content_view_id":6,"distribution":" ","content_overrides":[],"entitlementStatus":"valid","autoheal":true,"href":"/consumers/4b86c4bf-ce48-409c-ae0d-69f8d76f0277","release":null,"checkin_time":null,"created":"2014-08-18T08:52:37.443+0000","installedProducts":[],"service_level":"","release_ver":null,"permissions":{"editable":true},"products":[],"host":null,"hostCollections":[],"customInfo":[],"environment":{"id":2,"name":"Library","label":"Library","description":null,"organization":{"name":"Galactic Empire","label":"Galactic_Empire"},"created_at":"2014-08-15T07:38:17Z","updated_at":"2014-08-15T07:38:17Z","library":true,"prior":null,"permissions":{"view_lifecycle_environments":true,"edit_lifecycle_environments":true,"destroy_lifecycle_environments":true,"promote_or_remove_content_views_to_environments":true}},"activation_keys":[]}

Thank you.

Comment 13 Bryan Kearney 2014-09-11 12:24:01 UTC
This was delivered with Satellite 6.0 which was released on 10 September 2014.


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