Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1369737

Summary: API template_combinations GET and DELETE by id not working
Product: Red Hat Satellite Reporter: Peter Vreman <peter.vreman>
Component: APIAssignee: Shimon Shtein <sshtein>
Status: CLOSED ERRATA QA Contact: Renzo Nuccitelli <rnuccite>
Severity: high Docs Contact:
Priority: high    
Version: 6.2.0CC: bbuckingham, bkearney, brubisch, jcallaha, rnuccite
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-21 16:51:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1122832    

Description Peter Vreman 2016-08-24 09:27:46 UTC
Description of problem:
With 6.2.1 there GET and DELETE of templates_combinations is not working anymore.
This is a regression over 6.0/6.1 where the same process worked for years.

[crash] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/hostgroups/3 | jq .template_combinations
[
  {
    "config_template_name": "HOIOS-6.8.1-hf1-Library",
    "id": 1,
    "provisioning_template_id": 106,
    "provisioning_template_name": "HOIOS-6.8.1-hf1-Library",
    "hostgroup_id": 3,
    "hostgroup_name": "crash/AWS-HiltiCloud/Oracle-IAM-DB",
    "environment_id": null,
    "environment_name": null,
    "config_template_id": 106
  },
  {
    "config_template_name": "HOIOS-6.8.1-hf3-Library",
    "id": 44,
    "provisioning_template_id": 117,
    "provisioning_template_name": "HOIOS-6.8.1-hf3-Library",
    "hostgroup_id": 3,
    "hostgroup_name": "crash/AWS-HiltiCloud/Oracle-IAM-DB",
    "environment_id": null,
    "environment_name": null,
    "config_template_id": 117
  }
]

[crash] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/template_combinations/44
{
  "error": {"message":"Resource template_combination not found by id '44'"}
}
[crash] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XGET https://localhost/api/v2/template_combinations/1
{
  "error": {"message":"Resource template_combination not found by id '1'"}
}

[crash] root@li-lc-1578:~# curl -K /opt/hoici/etc/sat6/curl-hoici.conf "-HContent-Type: application/json" "-d{\"per_page\":9999}" -XDELETE https://localhost/api/v2/template_combinations/1
{
  "error": {"message":"Resource template_combination not found by id '1'"}
}


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1. Assiocate a template with a hostgroup
2. Get association using the API GET template_combinations/:id
3. Delete association using the API DELETE template_combinations/:id

Actual results:
Step 2 and 3 are giving a resource not foudn

Expected results:
Step 2 lists the tempmplate combination
Step 3 deletes the template combination


Additional info:

Comment 2 Peter Vreman 2016-08-31 13:53:00 UTC
Patch to make the API consistent that also DELETE and GET will only work on combinations with the environment or hostgroup

[crash] root@li-lc-1578:/usr/share/foreman# diff -u /usr/share/foreman/config/routes/api/v2.rb.160831-1 /usr/share/foreman/config/routes/api/v2.rb
--- /usr/share/foreman/config/routes/api/v2.rb.160831-1 2016-08-09 22:10:52.000000000 +0000
+++ /usr/share/foreman/config/routes/api/v2.rb  2016-08-31 13:47:35.776275554 +0000
@@ -32,7 +32,7 @@
           get 'build_pxe_default' # Keeping get variant for backward compatibility, see #6976 for details
           get 'revision'
         end
-        resources :template_combinations, :only => [:index, :create, :update, :show]
+        resources :template_combinations, :only => [:index, :create, :update, :show, :destroy]
         resources :operatingsystems, :except => [:new, :edit]
         resources :os_default_templates, :except => [:new, :edit]
       end
@@ -44,7 +44,7 @@
           post 'build_pxe_default'
           get 'revision'
         end
-        resources :template_combinations, :only => [:index, :create, :update, :show]
+        resources :template_combinations, :only => [:index, :create, :update, :show, :destroy]
         resources :operatingsystems, :except => [:new, :edit]
         resources :os_default_templates, :except => [:new, :edit]
       end
@@ -66,7 +66,7 @@
           end
         end
         resources :hosts, :except => [:new, :edit]
-        resources :template_combinations, :only => [:index, :show, :create, :update]
+        resources :template_combinations, :only => [:index, :create, :update, :show, :destroy]
       end

       resources :fact_values, :only => [:index]
@@ -89,7 +89,7 @@
         resources :puppetclasses, :except => [:new, :edit]
         resources :hostgroup_classes, :path => :puppetclass_ids, :only => [:index, :create, :destroy]
         resources :hosts, :except => [:new, :edit]
-        resources :template_combinations, :only => [:show, :index, :create, :update]
+        resources :template_combinations, :only => [:index, :create, :update, :show, :destroy]
       end

       resources :media, :except => [:new, :edit] do
@@ -228,7 +228,6 @@

       resources :template_kinds, :only => [:index]

-      resources :template_combinations, :only => [:show, :destroy]
       resources :config_groups, :except => [:new, :edit]

       resources :compute_attributes, :only => [:create, :update]
[crash] root@li-lc-1578:/usr/share/foreman# diff -u /usr/share/foreman/app/controllers/api/v2/template_combinations_controller.rb.160831-1 /usr/share/foreman/app/controllers/api/v2/template_combinations_controller.rb
--- /usr/share/foreman/app/controllers/api/v2/template_combinations_controller.rb.160831-1      2016-08-09 22:10:52.000000000 +0000
+++ /usr/share/foreman/app/controllers/api/v2/template_combinations_controller.rb       2016-08-31 13:36:02.841309152 +0000
@@ -41,7 +41,6 @@
         process_response @template_combination.save
       end

-      api :GET, "/template_combinations/:id", N_("Show template combination")
       api :GET, "/config_templates/:config_template_id/template_combinations/:id", N_("Show template combination"), :deprecated => true
       api :GET, "/provisioning_templates/:provisioning_template_id/template_combinations/:id", N_("Show template combination")
       api :GET, "/hostgroups/:hostgroup_id/template_combinations/:id", N_("Show template combination")
@@ -63,8 +62,13 @@
         process_response @template_combination.update_attributes!(params[:template_combination])
       end

-      api :DELETE, "/template_combinations/:id", N_("Delete a template combination")
+      api :DELETE, "/config_templates/:config_template_id/template_combinations/:id", N_("Delete template combination"), :deprecated => true
+      api :DELETE, "/provisioning_templates/:provisioning_template_id/template_combinations/:id", N_("Delete template combination")
+      api :DELETE, "/hostgroups/:hostgroup_id/template_combinations/:id", N_("Delete template combination")
+      api :DELETE, "/environments/:environment_id/template_combinations/:id", N_("Delete template combination")
       param :id, :identifier, :required => true
+      param_group :template_combination_identifiers
+      param_group :template_combination

       def destroy
         process_response @template_combination.destroy

Comment 3 Shimon Shtein 2016-08-31 16:03:19 UTC
Created redmine issue http://projects.theforeman.org/issues/16397 from this bug

Comment 4 Bryan Kearney 2016-08-31 18:21:18 UTC
Upstream bug assigned to sshtein

Comment 5 Bryan Kearney 2016-08-31 18:21:22 UTC
Upstream bug assigned to sshtein

Comment 7 Bryan Kearney 2016-09-12 10:17:59 UTC
Upstream bug component is API

Comment 8 Bryan Kearney 2016-09-12 10:18:02 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/16397 has been resolved.

Comment 11 Renzo Nuccitelli 2016-11-08 18:20:04 UTC
Bug fixed on 6.3. Added automation issue to avoid regressions on future: https://github.com/SatelliteQE/robottelo/issues/3961. Moving to verified.

Comment 12 Satellite Program 2018-02-21 16:51:07 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/RHSA-2018:0336