Bug 1369737 - API template_combinations GET and DELETE by id not working
Summary: API template_combinations GET and DELETE by id not working
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: API
Version: 6.2.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: Unspecified
Assignee: Shimon Shtein
QA Contact: Renzo Nuccitelli
URL:
Whiteboard:
Depends On:
Blocks: 1122832
TreeView+ depends on / blocked
 
Reported: 2016-08-24 09:27 UTC by Peter Vreman
Modified: 2021-03-11 14:40 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-21 16:51:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 16397 0 None None None 2016-08-31 16:03:21 UTC

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


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