-1

How to get VM credentials using soft layer REST API?

Following error on invoking the rest 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"
missionMan
  • 873
  • 8
  • 21

1 Answers1

0

First you would need to find the specific Component ID for the Virtual Guest. You can do this via 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": ""
    }
]

You can then call 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"
    }
]
greyhoundforty
  • 239
  • 2
  • 9