要检索 vCenter、vSAN、SRM 等所有 VMware 许可证,您可以使用以下 rest api:
方法:获取
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"}}}}
将 [username] 和 [apiKey] 替换为您的凭据。
或者你可以使用下面的python脚本示例:
"""
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))
您将得到如下示例的响应:
{
"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"
}
},
如果您想检索“NetApp 许可证”,您只需在其余 api 请求中将“VMware”数据替换为“NetApp”即可。
似乎无法通过 api 了解这些许可证附加了哪些硬件,而您可以通过控制门户看到相同的硬件。此信息不在数据库中,因为这些许可证是在服务器内部/手动添加的。
参考:
https://softlayer.github.io/reference/services/SoftLayer_Account/getActiveAccountLicenses/
https://softlayer.github.io/reference/datatypes/SoftLayer_Software_AccountLicense/