Project

General

Profile

Bug #30155

Attaching a subscription via API does not provide correct output

Added by Piyush Tiwari about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
Difficulty:
Triaged:
Yes
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:

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

  1. 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:
  1. ./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:

  1. ./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
    } #############################################################################################################
    ~~~

Associated revisions

Revision 4e5bccc0 (diff)
Added by Piyush Tiwari about 2 years ago

Fixes #30155 - Fix add/remove subscription api response

History

#1 Updated by Justin Sherrill about 2 years ago

  • Project changed from virt-who configure to Katello

#2 Updated by Piyush Tiwari about 2 years ago

  • Bugzilla link set to 1638425

#3 Updated by The Foreman Bot about 2 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/Katello/katello/pull/8780 added

#4 Updated by The Foreman Bot about 2 years ago

  • Fixed in Releases Katello 4.0.0 added

#5 Updated by Piyush Tiwari about 2 years ago

  • Status changed from Ready For Testing to Closed

#6 Updated by James Jeffers about 2 years ago

  • Triaged changed from No to Yes

#7 Updated by James Jeffers about 2 years ago

  • Target version set to Katello 4.0.0

#8 Updated by Chris Roberts about 2 years ago

  • Target version changed from Katello 4.0.0 to Katello 3.17.0

Also available in: Atom PDF