Bug 722975 - subscription-manager cli should not allow one to subscribe with --quantity>1 when "multi-entitlement" attribute is not "yes"
subscription-manager cli should not allow one to subscribe with --quantity>1 ...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: subscription-manager (Show other bugs)
6.2
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Devan Goodwin
John Sefler
:
Depends On:
Blocks: rhsm-rhel62
  Show dependency treegraph
 
Reported: 2011-07-18 12:48 EDT by John Sefler
Modified: 2011-12-06 12:22 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2011-12-06 12:22:30 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description John Sefler 2011-07-18 12:48:07 EDT
Description of problem:
the subscription-manager cli is allowing me to subscribe with quantity to any pool regardless of whether or not "multi-entitlement" is set to "yes" on the pool's product attributes.


Version-Release number of selected component (if applicable):
[root@jsefler-onprem-62server ~]# rpm -qa | grep subscription-manager
subscription-manager-gnome-0.96.4-1.git.34.850053a.el6.x86_64
subscription-manager-0.96.4-1.git.34.850053a.el6.x86_64
subscription-manager-firstboot-0.96.4-1.git.34.850053a.el6.x86_64


How reproducible:


Steps to Reproduce:
[root@jsefler-onprem-62server ~]# subscription-manager register --username=testuser1 --org=admin
Password: 
The system has been registered with id: 2ecd217b-e990-498f-be5e-0cf1698061eb 
[root@jsefler-onprem-62server ~]# subscription-manager list --avail | grep PoolId
PoolId:            	8a90f8c6313dc04e01313dc1deef0268
PoolId:            	8a90f8c6313dc04e01313dc1df360270
PoolId:            	8a90f8c6313dc04e01313dc1e0110283
PoolId:            	8a90f8c6313dc04e01313dc1e061028e
PoolId:            	8a90f8c6313dc04e01313dc1e10902a4
PoolId:            	8a90f8c6313dc04e01313dc1e14c02b2
PoolId:            	8a90f8c6313dc04e01313dc1e2f102f4
PoolId:            	8a90f8c6313dc04e01313dc1e31b02fb
PoolId:            	8a90f8c6313dc04e01313dc1e3920307
PoolId:            	8a90f8c6313dc04e01313dc1e3c3030e
PoolId:            	8a90f8c6313dc04e01313dc1e5960368
PoolId:            	8a90f8c6313dc04e01313dc1e5d30371
PoolId:            	8a90f8c6313dc04e01313dc1e6430382
PoolId:            	8a90f8c6313dc04e01313dc1e677038c
PoolId:            	8a90f8c6313dc04e01313dc1e6f203a0
PoolId:            	8a90f8c6313dc04e01313dc1e72a03ac
PoolId:            	8a90f8c6313dc04e01313dc1e79e03c3
PoolId:            	8a90f8c6313dc04e01313dc1e85903e9
PoolId:            	8a90f8c6313dc04e01313dc1e8f80404
PoolId:            	8a90f8c6313dc04e01313dc1e997041f
PoolId:            	8a90f8c6313dc04e01313dc1ea95044c
PoolId:            	8a90f8c6313dc04e01313dc1eb640470
PoolId:            	8a90f8c6313dc04e01313dc1ee3504ee
PoolId:            	8a90f8c6313dc04e01313dc1f2ba05c6
PoolId:            	8a90f8c6313dc04e01313dc1e7d303cd
PoolId:            	8a90f8c6313dc04e01313dc1e83003df
PoolId:            	8a90f8c6313dc04e01313dc1e8d003fb
PoolId:            	8a90f8c6313dc04e01313dc1e9640415
PoolId:            	8a90f8c6313dc04e01313dc1e9fb0431
PoolId:            	8a90f8c6313dc04e01313dc1ea24043a
PoolId:            	8a90f8c6313dc04e01313dc1eace0455
PoolId:            	8a90f8c6313dc04e01313dc1eb300467
PoolId:            	8a90f8c6313dc04e01313dc1ee6f04f7
PoolId:            	8a90f8c6313dc04e01313dc1f18a057e
PoolId:            	8a90f8c6313dc04e01313dc1f1e2058f
PoolId:            	8a90f8c6313dc04e01313dc1f28505b4
PoolId:            	8a90f8c6313dc04e01313dc1f32405ea
PoolId:            	8a90f8c6313dc04e01313dc1f35c05fc
PoolId:            	8a90f8c6313dc04e01313dc1f3d20620
PoolId:            	8a90f8c6313dc04e01313dc1f4440632
PoolId:            	8a90f8c6313dc04e01313dc1f58f066b
PoolId:            	8a90f8c6313dc04e01313dc1f5c10677
PoolId:            	8a90f8c6313dc04e01313dc1f694069b
PoolId:            	8a90f8c6313dc04e01313dc1f79f06e1
PoolId:            	8a90f8c6313dc04e01313dc1f7d306e8
PoolId:            	8a90f8c6313dc04e01313dc1f84a06f6
PoolId:            	8a90f8c6313dc04e01313dc1f63e068e
PoolId:            	8a90f8c6313dc04e01313dc1f70b06b8
PoolId:            	8a90f8c6313dc04e01313dc1f74306c8
PoolId:            	8a90f8c6313dc04e01313dc1f87706fd
[root@jsefler-onprem-62server ~]# 

PICK A POOL, ANY POOL ^^^^ 8a90f8c6313dc04e01313dc1f87706fd

[root@jsefler-onprem-62server ~]# curl -k -u admin:admin --request GET https://jsefler-onprem-62candlepin.usersys.redhat.com:8443/candlepin/pools/8a90f8c6313dc04e01313dc1f87706fd | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
102  1638  102  1638    0     0   6064      0 --:--:-- --:--:-- --:--:-- 15600
{
    "accountNumber": "12331131231", 
    "activeSubscription": true, 
    "attributes": [], 
    "consumed": 0, 
    "contractNumber": "0", 
    "created": "2011-07-18T14:59:07.511+0000", 
    "endDate": "2012-07-17T00:00:00.000+0000", 
    "href": "/pools/8a90f8c6313dc04e01313dc1f87706fd", 
    "id": "8a90f8c6313dc04e01313dc1f87706fd", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "8a90f8c6313dc04e01313dc0d63f0006", 
        "key": "admin"
    }, 
    "productAttributes": [
        {
            "created": "2011-07-18T14:59:07.511+0000", 
            "id": "8a90f8c6313dc04e01313dc1f87706fe", 
            "name": "type", 
            "productId": "awesomeos-modifier", 
            "updated": "2011-07-18T14:59:07.511+0000", 
            "value": "MKT"
        }, 
        {
            "created": "2011-07-18T14:59:07.511+0000", 
            "id": "8a90f8c6313dc04e01313dc1f87706ff", 
            "name": "arch", 
            "productId": "awesomeos-modifier", 
            "updated": "2011-07-18T14:59:07.511+0000", 
            "value": "ALL"
        }, 
        {
            "created": "2011-07-18T14:59:07.512+0000", 
            "id": "8a90f8c6313dc04e01313dc1f8780700", 
            "name": "version", 
            "productId": "awesomeos-modifier", 
            "updated": "2011-07-18T14:59:07.512+0000", 
            "value": "1.0"
        }, 
        {
            "created": "2011-07-18T14:59:07.512+0000", 
            "id": "8a90f8c6313dc04e01313dc1f8780701", 
            "name": "variant", 
            "productId": "awesomeos-modifier", 
            "updated": "2011-07-18T14:59:07.512+0000", 
            "value": "ALL"
        }
    ], 
    "productId": "awesomeos-modifier", 
    "productName": "Awesome OS Modifier", 
    "providedProducts": [
        {
            "created": "2011-07-18T14:59:07.512+0000", 
            "id": "8a90f8c6313dc04e01313dc1f8780702", 
            "productId": "37080", 
            "productName": "Awesome OS Modifier Bits", 
            "updated": "2011-07-18T14:59:07.512+0000"
        }
    ], 
    "quantity": 5, 
    "restrictedToUsername": null, 
    "sourceEntitlement": null, 
    "startDate": "2011-07-18T00:00:00.000+0000", 
    "subscriptionId": "8a90f8c6313dc04e01313dc11d710071", 
    "updated": "2011-07-18T14:59:07.511+0000"
}


^^^^ NOTICE THAT THERE IS NO "multi-entitlement" ATTRIB IN THE "productAttributes" ON THE POOL THAT WE RANDOMLY CHOSE.

I AM ASSUMING THAT THE ABSENCE OF "multi-entitlement" ATTRIB SHOULD IMPLY "multi-entitlement":"no" BEHAVIOR...

[root@jsefler-onprem-62server ~]# subscription-manager subscribe --pool=8a90f8c6313dc04e01313dc1f87706fd --quantity=3
Successfully subscribed the system to Pool 8a90f8c6313dc04e01313dc1f87706fd
[root@jsefler-onprem-62server ~]# subscription-manager list --consumed
+-------------------------------------------+
    Consumed Product Subscriptions
+-------------------------------------------+


ProductName:        	Awesome OS Modifier Bits 
ContractNumber:     	0                        
AccountNumber:      	12331131231              
SerialNumber:       	1525944662428813654      
Active:             	True                     
QuantityUsed:       	3                        
Begins:             	07/17/2011               
Expires:            	07/16/2012    


^^^^ WE APPEAR TO HAVE SUCCESSFULLY SUBSCRIBED WITH QUANTITY>1 TO A POOL THAT WAS NOT MARKED FOR MULTI-ENTITLEMENT.  THIS IS WRONG.

THE SUBSCRIBE ATTEMPT SHOULD HAVE BLOCKED US WITH A MESSAGE.  How about..

Subscription pool '8a90f8c6313dc04e01313dc1f87706fd' cannot be multi-entitled.  Try --quantity=1
Comment 1 Devan Goodwin 2011-07-22 14:52:46 EDT
Good catch, this was completely not checked server side. I suspect this is because quantities were originally only used for candlepin consumers transferring things downstream, where multi-entitlement is not required.

Added check during pre_global rule and it will error out if you try. This check should not affect candlepin consumers as they do not run this set of rules.

Fix is in multientitlefix branch in candlepin git. I have not yet merged it because I need to do more testing and fix an issue where pre-global is called twice during all entitlement operations. Leaving for PTO shortly so will wrap up on return, but the fix is out there if needed urgently.
Comment 2 Devan Goodwin 2011-08-02 10:09:03 EDT
Fixed in candlepin.git master: f6f175d864a42be02638ba62d45efc91b1cfc9cf
Comment 3 Shwetha Kallesh 2011-08-09 01:09:49 EDT
Moving the bug to verified as it works fine now.

Rpm's used :

subscription-manager-0.96.5-1.git.5.4303921.el6.x86_64
subscription-manager-firstboot-0.96.5-1.git.5.4303921.el6.x86_64
subscription-manager-gnome-0.96.5-1.git.5.4303921.el6.x86_64


Steps to reproduce the expected result:

curl -k -u admin:admin --request GET https://10.65.193.123:8443/candlepin/pools/ff80808131a8cbb10131a8ccd57306e6 | python -mjson.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
102  1639  102  1639    0     0  14413      0 --:--:-- --:--:-- --:--:-- 28258
{
    "accountNumber": "12331131231", 
    "activeSubscription": true, 
    "attributes": [], 
    "consumed": 1, 
    "contractNumber": "1", 
    "created": "2011-08-08T09:50:21.555+0000", 
    "endDate": "2012-08-07T00:00:00.000+0000", 
    "href": "/pools/ff80808131a8cbb10131a8ccd57306e6", 
    "id": "ff80808131a8cbb10131a8ccd57306e6", 
    "owner": {
        "displayName": "Admin Owner", 
        "href": "/owners/admin", 
        "id": "ff80808131a8cbb10131a8cbf0950006", 
        "key": "admin"
    }, 
    "productAttributes": [
        {
            "created": "2011-08-08T09:50:21.555+0000", 
            "id": "ff80808131a8cbb10131a8ccd57306e7", 
            "name": "type", 
            "productId": "awesomeos-modifier", 
            "updated": "2011-08-08T09:50:21.555+0000", 
            "value": "MKT"
        }, 
        {
            "created": "2011-08-08T09:50:21.555+0000", 
            "id": "ff80808131a8cbb10131a8ccd57306e8", 
            "name": "arch", 
            "productId": "awesomeos-modifier", 
            "updated": "2011-08-08T09:50:21.555+0000", 
            "value": "ALL"
        }, 
        {
            "created": "2011-08-08T09:50:21.556+0000", 
            "id": "ff80808131a8cbb10131a8ccd57406e9", 
            "name": "version", 
            "productId": "awesomeos-modifier", 
            "updated": "2011-08-08T09:50:21.556+0000", 
            "value": "1.0"
        }, 
        {
            "created": "2011-08-08T09:50:21.556+0000", 
            "id": "ff80808131a8cbb10131a8ccd57406ea", 
            "name": "variant", 
            "productId": "awesomeos-modifier", 
            "updated": "2011-08-08T09:50:21.556+0000", 
            "value": "ALL"
        }
    ], 
    "productId": "awesomeos-modifier", 
    "productName": "Awesome OS Modifier", 
    "providedProducts": [
        {
            "created": "2011-08-08T09:50:21.556+0000", 
            "id": "ff80808131a8cbb10131a8ccd57406eb", 
            "productId": "37080", 
            "productName": "Awesome OS Modifier Bits", 
            "updated": "2011-08-08T09:50:21.556+0000"
        }
    ], 
    "quantity": 10, 
    "restrictedToUsername": null, 
    "sourceEntitlement": null, 
    "startDate": "2011-08-08T00:00:00.000+0000", 
    "subscriptionId": "ff80808131a8cbb10131a8cc2a8d0072", 
    "updated": "2011-08-08T09:50:21.555+0000"
}


subscription-manager subscribe --pool=ff80808131a8cbb10131a8ccd57306e6 --quantity=3

Multi-entitlement not supported for pool with id 'ff80808131a8cbb10131a8ccd57306e6'.
Comment 4 errata-xmlrpc 2011-12-06 12:22:30 EST
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.

http://rhn.redhat.com/errata/RHBA-2011-1695.html

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