我正在尝试检索与特定帐户ID下的每个硬件组件(实例)相关联的许可证信息(许可证名称,许可证版本,有效期等)。有人可以帮助您列出特定帐户ID下关联的所有硬件组件以及每个硬件组件附带的所有软件许可证吗?

最佳答案

要检索所有VMware许可证(例如vCenter,vSAN,SRM等),可以使用以下rest api:

方法: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"}}}}


用您的凭据替换[用户名]和[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/

09-10 12:34
查看更多