如何使用软层REST API获取VM凭据?

时间:2017-12-27 08:22:36

标签: ibm-cloud-infrastructure

如何使用软层REST API获取VM凭据?

在调用其余api时出现以下错误。

PHP

1 个答案:

答案 0 :(得分:0)

首先,您需要找到虚拟访客的特定组件ID。您可以通过SoftLayer_Virtual_Guest :: getSoftwareComponents

执行此操作
$ curl -s "https://$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/VSI_ID/getSoftwareComponents" | pmj
[
    {
        "hardwareId": null,
        "id": 22088293,
        "manufacturerLicenseInstance": ""
    }
]

然后,您可以调用SoftLayer_Software_Component :: getPasswords

$ curl -s "https://$SOFTLAYER_USERNAME:$SOFTLAYER_API_KEY@api.softlayer.com/rest/v3/SoftLayer_Software_Component/22088293/getPasswords" | pmj
[
    {
        "createDate": "2017-12-26T10:52:12-06:00",
        "id": 24126369,
        "modifyDate": "2017-12-26T10:52:12-06:00",
        "password": "xxxxx",
        "port": null,
        "software": {
            "hardwareId": null,
            "id": 22088293,
            "manufacturerLicenseInstance": "",
            "passwords": [
                null
            ]
        },
        "softwareId": 22088293,
        "username": "root"
    }
]