
#create the tenant org
tenantOrg = client.org.create(key, "tenant", "tenant", "24^gold", "Mr.", "Shadow", "Man",
# retrieve all the system entitlements
SysEnts = client.org.listSystemEntitlements(key)
#loop through each entitlement
for SysE in SysEnts:
#if INFRA_ORG_ENTITLEMENTS if more than 1/2 of the unallocated, only assign 1/2
if SysE['unallocated'] > 2 * INFRA_ORG_ENTITLEMENTS:
nEnt = INFRA_ORG_ENTITLEMENTS
else:
nEnt = SysE['unallocated'] / 2
# assign infrastructure system entitlements printing an error on failure
try:
ret = client.org.setSystemEntitlements(key, infraOrg['id'], SysE['label'], nEnt)
except:
print "Unable to add: ", nEnt, " entitlements of type: ", SysE['label'], " to org", infraOrg['id']
# assign tenant system entitlements and print error on a failure
try:
ret = client.org.setSystemEntitlements(key, tenantOrg['id'], SysE['label'], SysE['unallocated'] -
nEnt)
except:
print "Unable to add: ", SysE['unallocated'] - nEnt, " entitlements of type: ", SysE['label'], " to
org", tenantOrg['id']
#Retrieve all the Software entitlements
SoftEnts = client.org.listSoftwareEntitlements(key)
for SoftE in SoftEnts:
if SoftE['unallocated'] > 2 * INFRA_ORG_ENTITLEMENTS:
nEnt = INFRA_ORG_ENTITLEMENTS
else:
nEnt = SoftE['unallocated'] / 2
try:
client.org.setSoftwareEntitlements(key, infraOrg['id'], SoftE['label'], nEnt)
except:
print "Unable to add: ", nEnt, " entitlements of type: ", SoftE['label'], " to org", infraOrg['id']
try:
client.org.setSoftwareEntitlements(key, tenantOrg['id'], SoftE['label'], SoftE['unallocated'] -
nEnt)
except:
print "Unable to add: ", SoftE['unallocated'] - nEnt, " entitlements of type: ", SoftE['label'], " to
org", tenantOrg['id']
#get all orgs
Orgs = client.org.listOrgs(key)
59 www.redhat.com
Komentáře k této Příručce