I'm trying to retrieve license information (license name, license version, expiry date, etc...) that are associated with each hardware components (instances) under a specific account ID. Can someone help how to list down all the hardware components associated under a specific account ID and all the software licenses attached to each hardware component?
To retrieve all VMware Licenses such as vCenter, vSAN, SRM, etc., you can use the following rest api:
Method: GET
https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getActiveAccountLicenses?objectMask=mask[billingItem[id,cancellationDate,orderItem[order[createDate]]],softwareDescription[name,manufacturer]]&objectFilter={"activeAccountLicenses":{"softwareDescription":{"manufacturer":{"operation":"VMware"}}}}
Replace the [username] and [apiKey] with your credentials.
Or you can use the below python script example:
"""
GetActiveAccountLicenses
Retrieve the active account software licenses owned by an account.
Important manual pages:
https://softlayer.github.io/reference/services/SoftLayer_Account/getActiveAccountLicenses/
https://softlayer.github.io/reference/datatypes/SoftLayer_Software_AccountLicense/
License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import json
import SoftLayer
# For nice debug output:
from pprint import pprint as pp
# Your SoftLayer API username and key.
API_USERNAME = 'set me'
# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set me'
objectMask = 'mask[billingItem[id,cancellationDate,orderItem[order[createDate]]],softwareDescription[name,manufacturer,' \
'virtualLicense]]'
objectFilter = {"activeAccountLicenses":{"softwareDescription":{"manufacturer":{"operation":"VMware"}}}}
client = SoftLayer.create_client_from_env(
username=API_USERNAME,
api_key=API_KEY
)
try:
accountLicenses = client['SoftLayer_Account'].getActiveAccountLicenses(mask=objectMask, filter= objectFilter)
print(json.dumps(accountLicenses, sort_keys=True, indent=2, separators=(',', ': ')))
except SoftLayer.SoftLayerAPIError as e:
pp('Unable to retrieve the account licenses faultCode=%s, faultString=%s'
% (e.faultCode, e.faultString))
You will get the response like the below example:
{
"accountId": 11111,
"capacity": "4",
"key": "4ADFG-5GSDL-20FDF9-SFSD3-FSDF5",
"units": "CPU",
"billingItem": {
"cancellationDate": null,
"id": 22222,
"orderItem": {
"categoryCode": "software_license",
"description": "vCenter Server Appliance 6.0",
"id": 33333,
"recurringFee": "0",
"setupTaxAmount": "0",
"order": {
"createDate": "2018-03-13T05:30:26-06:00"
}
}
},
"softwareDescription": {
"manufacturer": "VMware",
"name": "vCenter"
}
},
If you want to retrieve the "NetApp Licenses" you just have to replace the "VMware" data with "NetApp" in the rest api request.
It seems that there is not way to know what hardware are attached to those licenses by api and the same you can see by control portal. This information is not in the DB since these licenses are added internally/manually in the servers.
Reference:
https://softlayer.github.io/reference/services/SoftLayer_Account/getActiveAccountLicenses/ https://softlayer.github.io/reference/datatypes/SoftLayer_Software_AccountLicense/