Bug 489042

Summary: Cannot give management entitlement to an org through API
Product: Red Hat Satellite 5 Reporter: Sayli Karmarkar <skarmark>
Component: APIAssignee: Brad Buckingham <bbuckingham>
Status: CLOSED CURRENTRELEASE QA Contact: Sayli Karmarkar <skarmark>
Severity: medium Docs Contact:
Priority: low    
Version: 530CC: cperry, jsefler
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: sat530 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-10 19:54:55 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 456996    

Description Sayli Karmarkar 2009-03-06 21:32:00 UTC
Description of problem:
When I try:

server.org.setSystemEntitlements(key, 326, "provisioning_entitled", 1) 
it works but all - 
server.org.setSystemEntitlements(key, 326, "enterprise_entitled", 1)
server.org.setSystemEntitlements(key, 326, "sw_mgr_entitled", 1)
server.org.setSystemEntitlements(key, 326, "management_entitled", 1)

fail with "Invalid Entitlement".

 
On the similar note I guess we should mention what system entitlement labels are valid as arguments to the API.

Comment 1 Brad Buckingham 2009-03-06 22:55:29 UTC
It looks like management_entitled is not a valid one for our case.  

The current supported entitlements appear to be:
  base: enterprise_entitled or sw_mgr_entitled
  add-on: monitoring_entitled, provisioning_entitled, virtualization_host, virtualization_host_platform

Currently, the API logic is only allowing the add-on entitlements and throws the exception mentioned for any changes to the base entitlements.  This should be updated.

Comment 2 Brad Buckingham 2009-03-06 23:06:05 UTC
Correction.... sw_mgr_entitled is not valid in this case.

Supported values are:
  base: enterprise_entitled
  add-on: monitoring_entitled, provisioning_entitled, virtualization_host,
virtualization_host_platform

Comment 3 Brad Buckingham 2009-03-06 23:17:53 UTC
git commit: 262ee714d147730cbbdf51c233fbf5408277128d

Updated API to support setting the management entitlements for the org.

Also, updated the API doc to list the supported entitlements.  E.g.

Method: setSystemEntitlements
Description:
Set an organization's entitlement allocation for the given software entitlement. If increasing the entitlement allocation, the default organization (i.e. orgId=1) must have a sufficient number of free entitlements.

Parameters:

    * string sessionKey
    * int orgId
    * string label - System entitlement label. Valid values include:
          o enterprise_entitled
          o monitoring_entitled
          o provisioning_entitled
          o virtualization_host
          o virtualization_host_platform
    * int allocation

Returns:

    * int - 1 on success, exception thrown otherwise.

Comment 4 Brad Buckingham 2009-03-17 21:17:48 UTC
mass move to ON_QA

Comment 5 Sayli Karmarkar 2009-03-19 19:12:39 UTC
verified.

Comment 6 John Sefler 2009-08-28 14:44:28 UTC
Verified on staged (Satellite-5.3.0-RHEL5-re20090811.0)

click Help|About > API > org > setSystemEntitlements


 Method: setSystemEntitlements
Description:
Set an organization's entitlement allocation for the given software entitlement. If increasing the entitlement allocation, the default organization (i.e. orgId=1) must have a sufficient number of free entitlements.

Parameters:

    * string sessionKey
    * int orgId
    * string label - System entitlement label. Valid values include:
          o enterprise_entitled
          o monitoring_entitled
          o provisioning_entitled
          o virtualization_host
          o virtualization_host_platform
    * int allocation

Returns:

    * int - 1 on success, exception thrown otherwise. 



[jsefler@jsefler api]$ cat org_setSystemEntitlements.py
#!/usr/bin/env python
import xmlrpclib

u = 'admin'
p = 'redhatqa'
url = 'http://sun-x4440-01.rhts.bos.redhat.com/rpc/api'
server = xmlrpclib.Server(url,verbose=0)
oid = 2

try:
 ses = server.auth.login(u,p)
 print "result=%d" % (server.org.setSystemEntitlements(ses,oid,"enterprise_entitled",5))
 print "result=%d" % (server.org.setSystemEntitlements(ses,oid,"monitoring_entitled",6))
 print "result=%d" % (server.org.setSystemEntitlements(ses,oid,"provisioning_entitled",7))
 print "result=%d" % (server.org.setSystemEntitlements(ses,oid,"virtualization_host",8))
 print "result=%d" % (server.org.setSystemEntitlements(ses,oid,"virtualization_host_platform",9))
 print "result=%d" % (server.org.setSystemEntitlements(ses,oid,"bad_entitlement",10))
except(xmlrpclib.Fault), f:
 print "ERROR: an Error was encountered!\n", f
 exit(-1)

[jsefler@jsefler api]$ ./org_setSystemEntitlements.py
result=1
result=1
result=1
result=1
result=1
ERROR: an Error was encountered!
<Fault -212: 'redstone.xmlrpc.XmlRpcFault: Invalid entitlement'>


Also verified that the api results were updated in the sat GUI:


moving to RELEASE_PENDING

Comment 7 Brandon Perkins 2009-09-10 19:54:55 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2009-1434.html