Bug #30155
closedAttaching a subscription via API does not provide correct output
Description
Description of problem:
Attaching of a subscription via API call does not provide the correct output, it provides the subscription state of the host before the subscription was attached so we do not see if the actual subscription was correctly attached.
Version-Release number of selected component (if applicable):
Satellite 6.3.3
How reproducible:
100%
Steps to Reproduce:
~~~
#!/bin/bash
- VARS to be modified
user='admin'
password='user'
satellite='satellite.example.com'
host_id='526'
subscription_id='5'
break_line='#############################################################################################################' ###
echo "Retrieve current subscription for $host_id :"
curl -s -u $user:$password -k https://$satellite/api/v2/hosts/$host_id/subscriptions | python -m json.tool
echo $break_line
echo "Add subscription CENTOS for $host_id :"
curl -X PUT -H "Content-Type: application/json" -d "{\"id\":\"$host_id\",\"subscriptions\":[{\"id\":$subscription_id,\"quantity\":1}]}" -s -u $user:$password -k https://$satellite/api/v2/hosts/$host_id/subscriptions/add_subscriptions | python -m json.tool
echo $break_line
echo "Check if subscription was assigned to $host_id :"
curl -s -u $user:$password -k https://$satellite/api/v2/hosts/$host_id/subscriptions | python -m json.tool
echo $break_line
~~~
Actual results:- ./test_api.sh
~~~
Retrieve current subscription for 526 : {
"error": null,
"page": 1,
"per_page": 0,
"results": [],
"search": null,
"sort": {
"by": null,
"order": null
},
"subtotal": 0,
"total": 0
} #############################################################################################################
Add subscription CENTOS for 526 : {
"error": null,
"page": 1,
"per_page": 0,
"results": [],
"search": null,
"sort": {
"by": null,
"order": null
},
"subtotal": 0,
"total": 0
} #############################################################################################################
Check if subscription was assigned to 526 : {
"error": null,
"page": 1,
"per_page": 1,
"results": [ {
"account_number": null,
"available": -4,
"consumed": 3,
"contract_number": null,
"cores": null,
"cp_id": "4028ef8153a2f6b50153a370f2ab0017",
"end_date": "2046-03-16 12:26:39 UTC",
"id": 5,
"instance_multiplier": 1,
"multi_entitlement": null,
"name": "CentOS",
"product_id": "1458735999354",
"product_name": "CentOS",
"quantity": -1,
"quantity_consumed": 1,
"ram": null,
"sockets": null,
"stacking_id": null,
"start_date": "2016-03-23 12:26:39 UTC",
"subscription_id": 4,
"support_level": null,
"type": "NORMAL",
"unmapped_guest": false,
"virt_only": false,
"virt_who": false
}
],
"search": null,
"sort": {
"by": null,
"order": null
},
"subtotal": 1,
"total": 1
} #############################################################################################################
~~~
Expected results:
- ./test_api.sh
~~~
Retrieve current subscription for 526 : {
"error": null,
"page": 1,
"per_page": 0,
"results": [],
"search": null,
"sort": {
"by": null,
"order": null
},
"subtotal": 0,
"total": 0
} #############################################################################################################
Add subscription CENTOS for 526 : {
"error": null,
"page": 1,
"per_page": 1,
"results": [ {
"account_number": null,
"available": -4,
"consumed": 3,
"contract_number": null,
"cores": null,
"cp_id": "4028ef8153a2f6b50153a370f2ab0017",
"end_date": "2046-03-16 12:26:39 UTC",
"id": 5,
"instance_multiplier": 1,
"multi_entitlement": null,
"name": "CentOS",
"product_id": "1458735999354",
"product_name": "CentOS",
"quantity": -1,
"quantity_consumed": 1,
"ram": null,
"sockets": null,
"stacking_id": null,
"start_date": "2016-03-23 12:26:39 UTC",
"subscription_id": 4,
"support_level": null,
"type": "NORMAL",
"unmapped_guest": false,
"virt_only": false,
"virt_who": false
}
],
"search": null,
"sort": {
"by": null,
"order": null
},
"subtotal": 1,
"total": 1
} #############################################################################################################
Check if subscription was assigned to 526 : {
"error": null,
"page": 1,
"per_page": 1,
"results": [ {
"account_number": null,
"available": -4,
"consumed": 3,
"contract_number": null,
"cores": null,
"cp_id": "4028ef8153a2f6b50153a370f2ab0017",
"end_date": "2046-03-16 12:26:39 UTC",
"id": 5,
"instance_multiplier": 1,
"multi_entitlement": null,
"name": "CentOS",
"product_id": "1458735999354",
"product_name": "CentOS",
"quantity": -1,
"quantity_consumed": 1,
"ram": null,
"sockets": null,
"stacking_id": null,
"start_date": "2016-03-23 12:26:39 UTC",
"subscription_id": 4,
"support_level": null,
"type": "NORMAL",
"unmapped_guest": false,
"virt_only": false,
"virt_who": false
}
],
"search": null,
"sort": {
"by": null,
"order": null
},
"subtotal": 1,
"total": 1
} #############################################################################################################
~~~
Updated by Justin Sherrill over 4 years ago
- Project changed from virt-who configure to Katello
Updated by The Foreman Bot over 4 years ago
- Status changed from New to Ready For Testing
- Pull request https://github.com/Katello/katello/pull/8780 added
Updated by The Foreman Bot over 4 years ago
- Fixed in Releases Katello 4.0.0 added
Updated by Piyush Tiwari over 4 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset katello|4e5bccc08aa8414a15403ae603467d5274a6fe66.
Updated by Chris Roberts over 4 years ago
- Target version changed from Katello 4.0.0 to Katello 3.17.0