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?
-
Have you tried using https://github.com/giampaolo/psutil ? – alec_djinn Oct 02 '18 at 13:33
-
I'm not sure what are you trying to retrieve from API, are you talking about Vmware/netapp licenses? It would helpful if you can provide an screenshot or describe on which part of the UI that information is located – Albert Camacho Oct 02 '18 at 14:22
-
@alec_djnn Just looked over it. Thanks for the help but this won't help the purpose that I'm looking for specific to the IBM-cloud-infrastructure. – user3106163 Oct 02 '18 at 14:57
-
@AlbertCamacho yes I'm trying to retrieve all the license information such as vSAN Licenses, vCenter license and billing item IDs, order IDs for each of them and the hardware they are associated with it. Usually, they are located under the vCenter but we don't want to query there. – user3106163 Oct 02 '18 at 18:14
1 Answers
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. <sldn@softlayer.com>
"""
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/

- 718
- 1
- 4
- 8
-
Thanks for helping with the REST request. Can you please help what will be the Python call for the same? I already have python-softlayer client connection available, so will be handy. I tried running the above GET request but it's giving "Access denied" error (generated key from console.bluemix.net. – user3106163 Oct 03 '18 at 01:40
-
1I updated the forum with a python script example, and the "Access denied" error is because you did not replace the [username] and [apiKey] with your credentials. – F.Ojeda Oct 03 '18 at 17:06
-
@F.Odeja thanks for helping with the python call. That really helped. With the billing item ID that gets retrieved in the response, I'm also looking for Order ID associated with it, is it possible? – user3106163 Oct 03 '18 at 21:34
-
1Yes, it is possible to get the Order ID. Try adding the ¨id¨ data to the objectMask in the script, like this example: 'mask[billingItem[id,cancellationDate,orderItem[order[id,createDate]]],softwareDescription[name,manufacturer]] – F.Ojeda Oct 03 '18 at 22:17
-
In the following documentation you will find the datatypes that you can add to the objectMask: https://softlayer.github.io/reference/datatypes/SoftLayer_Billing_Item/, https://softlayer.github.io/reference/datatypes/SoftLayer_Billing_Order_Item/, https://softlayer.github.io/reference/datatypes/SoftLayer_Billing_Order/ and this other documentation will help you how to use the ¨object-masks¨: https://softlayer.github.io/article/object-masks/ – F.Ojeda Oct 03 '18 at 22:24
-
@F.Odeja Thanks for the help. Much appreciated. Yes, I read about the Object Masks and found them too confusing to figure out how to create one own. It's little difficult to figure out based on wiki which method can accept mask and how to call it/pass a parameter to the method. – user3106163 Oct 03 '18 at 23:40