Project

General

Profile

Bug #7989

/api/v2/hosts rejects POST request containing operatingsystem_id parameter

Added by Dominic Cleal over 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Bugzilla link:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1154156
Description of problem:
It is impossible to sucessfully POST the /hosts path.

When creating a host, an operating system ID is required via the operatingsystem_id parameter. However, the application responds with an HTTP 500 error:

operatingsystem_id is not allowed as nested parameter for hosts. Allowed parameters are hostgroup_id, location_id, organization_id, environment_id (RuntimeError)

Version-Release number of selected component (if applicable):
Tested against a nightly build of Satellite 6 with the following packages installed:

  • apr-util-ldap-1.3.9-3.el6_0.1.x86_64
  • candlepin-0.9.32-1.el6.noarch
  • candlepin-common-1.0.8-1.el6.noarch
  • candlepin-selinux-0.9.32-1.el6.noarch
  • candlepin-tomcat6-0.9.32-1.el6.noarch
  • elasticsearch-0.90.10-7.el6.noarch
  • foreman-1.7.0-0.develop.201410150839gitb948163.el6.noarch
  • foreman-compute-1.7.0-0.develop.201410150839gitb948163.el6.noarch
  • foreman-gce-1.7.0-0.develop.201410150839gitb948163.el6.noarch
  • foreman-libvirt-1.7.0-0.develop.201410150839gitb948163.el6.noarch
  • foreman-ovirt-1.7.0-0.develop.201410150839gitb948163.el6.noarch
  • foreman-postgresql-1.7.0-0.develop.201410150839gitb948163.el6.noarch
  • foreman-proxy-1.7.0-0.develop.201410101404git7961640.el6.noarch
  • foreman-release-1.7.0-0.develop.201410150839gitb948163.el6.noarch
  • foreman-selinux-1.7.0-0.develop.201409301113git2f345de.el6.noarch
  • foreman-vmware-1.7.0-0.develop.201410150839gitb948163.el6.noarch
  • katello-2.1.0-1.201410161306gite21feb2.el6.noarch
  • katello-certs-tools-2.0.1-1.el6.noarch
  • katello-default-ca-1.0-1.noarch
  • katello-installer-2.1.0-1.201410151311git9100203.el6.noarch
  • katello-repos-2.1.1-1.el6.noarch
  • katello-server-ca-1.0-1.noarch
  • openldap-2.4.23-32.el6_4.1.x86_64
  • pulp-docker-plugins-0.2.1-0.2.beta.el6.noarch
  • pulp-katello-0.3-3.el6.noarch
  • pulp-nodes-common-2.5.0-0.7.beta.el6.noarch
  • pulp-nodes-parent-2.5.0-0.7.beta.el6.noarch
  • pulp-puppet-plugins-2.5.0-0.7.beta.el6.noarch
  • pulp-puppet-tools-2.5.0-0.7.beta.el6.noarch
  • pulp-rpm-plugins-2.5.0-0.7.beta.el6.noarch
  • pulp-selinux-2.5.0-0.7.beta.el6.noarch
  • pulp-server-2.5.0-0.7.beta.el6.noarch
  • python-ldap-2.3.10-1.el6.x86_64
  • ruby193-rubygem-ldap_fluff-0.3.2-1.el6.noarch
  • ruby193-rubygem-net-ldap-0.3.1-2.el6.noarch
  • ruby193-rubygem-runcible-1.2.0-1.el6.noarch

How reproducible:
100%

Steps to Reproduce:
See description and "Additional info:" section below.

Actual results:
No host is created.

Expected results:
A host is created.

Additional info:
Here's an example of parameters received by the API, taken from the application log file:

{"host"=>{
"operatingsystem_id"=>76,
"root_pass"=>"[FILTERED]",
"environment_id"=>103,
"ptable_id"=>55,
"medium_id"=>64,
"organization_id"=>383,
"mac"=>"1f:66:bb:75:5c:8e",
"architecture_id"=>53,
"location_id"=>384,
"domain_id"=>58,
"puppet_proxy_id"=>1,
"name"=>"mZmHqfwWSejeJ"
}, "apiv"=>"v2"}

Related issues

Related to Foreman - Feature #3492: API v2 - nested routes for each controllerClosed2013-10-24

History

#1 Updated by Dominic Cleal over 4 years ago

  • Category set to API
  • Assignee deleted (Bryan Kearney)
  • Target version set to 1.7.2
  • Legacy Backlogs Release (now unused) set to 21

Reproduced and found the regression was introduced by:

commit 453dc6939f607d8ae0ff4580b5562734c60b19c5
Author: Joseph Magen <jmagen@redhat.com>
Date:   Tue Oct 7 09:45:20 2014 +0300

    fixes #3492 - API v2 nested routes for each controller

This isn't a nested route, it's just a parameter inside a hash.

#2 Updated by Dominic Cleal over 4 years ago

  • Related to Feature #3492: API v2 - nested routes for each controller added

#3 Updated by Dominic Cleal over 4 years ago

Ditto with users + auth_source_id, and probably loads more.

    Processing by Api::V2::UsersController#update as JSON
      Parameters: {
        "mail"=>"JgUTagrX@test.edu",
        "login"=>"g",
        "password"=>"[FILTERED]",
        "auth_source_id"=>1,
        "apiv"=>"v2",
        "id"=>"51",
        "user"=>{
          "login"=>"g",
          "mail"=>"JgUTagrX@test.edu",
          "auth_source_id"=>1,
          "password"=>"[FILTERED]" 
        }
      }
    Authorized user admin(Admin User)
    auth_source_id is not allowed as nested parameter for users. Allowed parameters are auth_source_ldap_id, role_id, location_id, organization_id, usergroup_id (RuntimeError)

#4 Updated by Shlomi Zadok over 4 years ago

  • Assignee set to Shlomi Zadok

#5 Updated by The Foreman Bot over 4 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/1870 added
  • Pull request deleted ()

#6 Updated by Dominic Cleal over 4 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Was merged in https://github.com/theforeman/foreman/commit/47ab039e61ae3f29627de0a770fa0c6b41f33c47, wrong ticket number in the commit message.

Also available in: Atom PDF