-2

I tried the following REST API to add SSH Keys to virtual guest when provisioning it, but it doesn`t work.

url: https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest.json
body:
{"parameters": [{"datacenter": {"name": "lon02"}, "domain": "softlayer.com", "hourlyBillingFlag": true, "blockDeviceTemplateGroup": {"globalIdentifier": "2e9bba22-c88a-4e3b-87af-45fb8fc4531e"}, "localDiskFlag": true, "maxMemory": 4096, "hostname": "bosh-sl-test", "startCpus": 4, "primaryBackendNetworkComponent": {"networkVlan": {"id": 524954}}, "sshKeys": [{"id": 886121}], "primaryNetworkComponent": {"networkVlan": {"id": 524956}}}]}

1 Answers1

0

The JSON structure is correct and I was able to create VSI with same structure. The URL you are using is incomplete but works too, the complete URL uses the method SoftLayer_Virtual_Guest::createObject as following:

https://[user_name]:[api_key]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObject
Method: POST

Take account that SshKey will not be displayed in the response (it will not be available immediately), you need to wait until provisioning has been completed.

To verify if SshKey was added you can use the methods SoftLayer_Virtual_Guest::getObject or SoftLayer_Virtual_Guest::getSshKeys as following:

https://[user_name]:[api_key]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[deviceId]/getObject?objectMask=mask[sshKeys]

OR

https://[user_name]:[api_key]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[deviceId]/getSshKeys

Note: Change [user_name], [api_key] and [deviceId] with your own data.

Albert Camacho
  • 1,129
  • 1
  • 7
  • 13