theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
GNU General Public License v3.0
147 stars 163 forks source link

k_activation_key can't add subscriptions that exist multiple times #165

Closed evgeni closed 4 years ago

evgeni commented 6 years ago
SUMMARY

when adding subscriptions to an activation key, ansible errors out when there are multiple subscriptions with the same name (but different contract dates, e.g.). this is because handle_find_response explicitly expects one result, not multiple.

ISSUE TYPE
ANSIBLE VERSION
ansible 2.6.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/remote/egolov/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.15 (default, May 16 2018, 17:50:09) [GCC 8.1.1 20180502 (Red Hat 8.1.1-1)]
KATELLO/FOREMAN VERSION
# rpm -q tfm-rubygem-katello foreman
tfm-rubygem-katello-3.4.5.58-2HOTFIXRHBZ1522912.el7sat.noarch
foreman-1.15.6.34-1.el7sat.noarch
NAILGUN VERSION
git master, 6.3.z branches
EXPECTED RESULTS

Sub is added

ACTUAL RESULTS
"msg": "No subscription found for Red Hat Satellite Employee Subscription"
sean797 commented 6 years ago

Do we want to allow searching by pool_id ? I'm not sure if there is a better approach?

evgeni commented 6 years ago

pool_id is probably a good idea in this case, yeah.

wbclark commented 4 years ago

Although the cp_id (i.e. pool_id) field exists in Katello:

$ curl -k https://$satlogin:$satpass@$(hostname -f)/katello/api/subscriptions/6 2>/dev/null | python -m json.tool | grep cp_id
"cp_id": "8a88e9826db22df5016dd018abdd029b",

It is not valid for searching:

$ curl -k https://$satlogin:$satpass@$(hostname -f)/katello/api/subscriptions?search=cp_id=8a88e9826db22df5016dd018abdd029b 2>/dev/null | python -m json.tool | grep error
"error": "Field 'cp_id' not recognized for searching!",
evgeni commented 4 years ago

Right, these should be the possible search params:

https://github.com/Katello/katello/blob/master/app/models/katello/pool.rb#L24-L42