Bug 1114640

Summary: Can't create parameters for operating system with id 1 using API
Product: Red Hat Satellite 6 Reporter: Bryan Kearney <bkearney>
Component: ProvisioningAssignee: jmagen <jmagen>
Status: CLOSED CURRENTRELEASE QA Contact: sthirugn <sthirugn>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.0.4CC: bbuckingham, cwelton, hbrock, jmontleo, sthirugn
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
URL: http://projects.theforeman.org/issues/6375
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-09-11 12:20:29 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description Bryan Kearney 2014-06-30 14:21:47 UTC
When you try to create a new parameter for operating system with id 1, you result in 422 error

Started POST "/api/operatingsystems/1/parameters" for at 2014-06-25 08:46:15 +0000
Processing by Api::V2::ParametersController#create as JSON
  Parameters: {"parameter"=>{"value"=>"[FILTERED]", "name"=>"ssh_public_key"}, "apiv"=>"v2", "operatingsystem_id"=>"1"}
Authorized user admin(Admin User)
Unprocessable entity OsParameter (id: new):
  Reference parameters require an associated domain, host or host group

  Rendered api/v2/errors/unprocessable_entity.json.rabl within api/v2/layouts/error_layout (1.3ms)
Completed 422 Unprocessable Entity in 657ms (Views: 2.4ms | ActiveRecord: 299.7ms)

The issue is in that reference_id is set to nil (this is inspect of @parameter from create action)

#<OsParameter id: nil, name: "ssh_public_key", value: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA5mX2JV6T6CVCRmT...", reference_id: nil, created_at: nil, updated_at: nil, type: "OsParameter", priority: 2>

git bisect found #5129 and "691f0a1a809569d125e9385e60f8f1e1c8d88061":http://projects.theforeman.org/projects/foreman/repository/revisions/691f0a1a809569d125e9385e60f8f1e1c8d88061 as a source of the issue. It seems that for some reason we enforce nil for reference_id when it's set to 1. Related PR https://github.com/theforeman/foreman/pull/1504. Note that it was merged to 1.5.2

Comment 1 Bryan Kearney 2014-06-30 14:21:48 UTC
Created from redmine issue http://projects.theforeman.org/issues/6375

Comment 2 Bryan Kearney 2014-06-30 14:21:53 UTC
Upstream bug assigned to jmagen@redhat.com

Comment 4 jmagen@redhat.com 2014-07-07 14:15:54 UTC

Comment 6 Bryan Kearney 2014-07-22 08:03:44 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/6375 has been closed
Joseph Magen
Joseph Magen
Applied in changeset commit:5dded9172adeadb8ef0f56a33787b213784551a4.

Comment 9 jaudet 2014-08-04 17:51:25 UTC
Created a GitHub issue to track progress on tracking this issue. See: https://github.com/omaciel/robottelo/issues/1128

Comment 10 sthirugn@redhat.com 2014-08-25 20:15:32 UTC

# curl -X POST -H "Accept:application/json" -H "Content-Type: application/json" -u admin:changeme --insecure -d '{"operatingsystem_id":"1","parameter":{"name":"awesomename1","value":"nicevalue1"}}' https://sat6host/api/v2/operatingsystems/1/parameters


Version Tested:
GA Snap 6 - Satellite-6.0.4-RHEL-6-20140820.1

* 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-6.el6sat.noarch
* foreman-
* foreman-compute-
* foreman-gce-
* foreman-libvirt-
* foreman-ovirt-
* foreman-postgresql-
* foreman-proxy-
* foreman-selinux-
* foreman-vmware-
* katello-1.5.0-29.el6sat.noarch
* katello-ca-1.0-1.noarch
* katello-certs-tools-1.5.6-1.el6sat.noarch
* katello-installer-0.0.60-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 Bryan Kearney 2014-09-11 12:20:29 UTC
This was delivered with Satellite 6.0 which was released on 10 September 2014.