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 1101537 - activation_keys.add_host_collections API removes host collections from the activation key
Summary: activation_keys.add_host_collections API removes host collections from the ac...
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-05-27 12:59 UTC by Tomas Lestach
Modified: 2019-09-26 18:15 UTC (History)
6 users (show)

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


Attachments (Terms of Use)
attaching patch (934 bytes, patch)
2014-05-27 13:05 UTC, Tomas Lestach
no flags Details | Diff


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

Description Tomas Lestach 2014-05-27 12:59:29 UTC
Description of problem:

Calling
        @api.resource(:activation_keys).call(
          :add_host_collections,
          {
            :id => ak_id,
            :host_collection_ids => hc_ids
          })
does not associate host_collections with the activation key

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

How reproducible:
always

Steps to Reproduce:
# bundle exec irb
irb> require 'apipie-bindings'
irb> api = ApipieBindings::API.new({:uri => 'http://localhost:3000/', :username => 'admin', :password => 'changeme', :api_version=> '2', :aggressive_cache_checking => true})
irb> api.resource(:activation_keys).call(
          :add_host_collections,
          {
            :id => ak_id,
            :host_collection_ids => hc_ids
          })

Actual results:
* API call runs without issues, but does not associate host collections with the activation key
* according to config/routes/api/v2.rb it looks like :remove_host_collections is called instead

Expected results:
associate host collections with the activation key

Additional info:
* <sat6>/apidoc/v2/activation_keys/add_host_collections
does not have complete apidoc
* Ivan's patch:

diff --git a/config/routes/api/v2.rb b/config/routes/api/v2.rb
index ad7cb9a..3456d10 100644
--- a/config/routes/api/v2.rb
+++ b/config/routes/api/v2.rb
 -27,8 +27,8 @@ Katello::Engine.routes.draw do
         match '/releases' => 'activation_keys#available_releases', :via => :get, :on => :member
         api_resources :host_collections, :only => [:index]
         member do
-          match '/host_collections' => 'activation_keys#add_host_collections', :via => :post
-          match '/host_collections' => 'activation_keys#remove_host_collections', :via => :put
+          match '/host_collections' => 'activation_keys#add_host_collections', :via => :put
+          match '/host_collections' => 'activation_keys#remove_host_collections', :via => :delete
           match '/host_collections/available' => 'activation_keys#available_host_collections', :via => :get
         end
         api_resources :products, :only => [:index]

Comment 1 RHEL Program Management 2014-05-27 13:03:52 UTC
Since this issue was entered in Red Hat Bugzilla, the release flag has been
set to ? to ensure that it is properly evaluated for this release.

Comment 3 Tomas Lestach 2014-05-27 13:05:16 UTC
Created attachment 899496 [details]
attaching patch

Comment 4 Dustin Tsang 2014-06-23 23:59:55 UTC
redmine issue created.

Comment 5 Dustin Tsang 2014-06-24 00:01:27 UTC
for the actions had documented(apipie) the wrong http actions

Comment 6 Bryan Kearney 2014-06-26 16:03:09 UTC
Moving to POST since upstream bug http://projects.theforeman.org/issues/6347 has been closed

Comment 8 sthirugn@redhat.com 2014-08-13 20:49:14 UTC
Verified.

Tested both CLI and API calls and they work fine:

hammer> activation-key add-host-collection --host-collection-id=1 --id=7 --organization-id=3
The host collection has been associated

# curl -X POST -H "Accept:application/json" -H "Content-Type: application/json" -u admin:changeme --insecure -d '{"id":"7","host_collection_ids":["1"]}' https://$host/katello/api/activation_keys/7/host_collections
success

Comment 9 Bryan Kearney 2014-09-11 12:29:09 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.