如何使用软层 REST API 获取 VM 凭据?
How to get VM credentials using soft layer REST API?
如何使用软层 REST 获取 VM 凭据API?
调用其余部分时出现以下错误 api。
ser%!(EXTRA services.Software_Component_Password={0xc420184000 {<nil> <nil> <nil>}})
2017/12/27 00:02:48 [DEBUG] Request URL: GET https://api.softlayer.com/rest/v3/SoftLayer_Software_Component_Password.json
2017/12/27 00:02:48 [DEBUG] Parameters:
2017/12/27 00:02:48 [DEBUG] Response: {"error":"Object does not exist to execute method on. (SoftLayer_Software_Component_Password::getObject)","code":"SoftLayer_Exception"
首先,您需要找到虚拟来宾的特定组件 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"
}
]
如何使用软层 REST 获取 VM 凭据API?
调用其余部分时出现以下错误 api。
ser%!(EXTRA services.Software_Component_Password={0xc420184000 {<nil> <nil> <nil>}})
2017/12/27 00:02:48 [DEBUG] Request URL: GET https://api.softlayer.com/rest/v3/SoftLayer_Software_Component_Password.json
2017/12/27 00:02:48 [DEBUG] Parameters:
2017/12/27 00:02:48 [DEBUG] Response: {"error":"Object does not exist to execute method on. (SoftLayer_Software_Component_Password::getObject)","code":"SoftLayer_Exception"
首先,您需要找到虚拟来宾的特定组件 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"
}
]