1
votes

I am trying to implement the loadFromImage function using Softlayer java API. When I test on control.softlayer.com, a private image is not being listed. Do I need to load a private image to my server first? Then, load the image on the server? If not, Can you guide me the right procedure ? Can I have any sample code to implement?

Thank you Mike

Load From Image Page

1
Have you added the image to the image manager? knowledgelayer.softlayer.com/procedure/import-image - underscorephil

1 Answers

1
votes

Currently, you don’t have any “private image” in your account, please see in Control Portal to confirm this:

https://control.softlayer.com/devices/images

(filter by “private images”)

To create a new image from portal:

  • Go to https://control.softlayer.com/devices
  • Select a server from the list
  • Once ready the “Device List” window, select “Create Image Template” from “Actions” right menu. A standard image will be created. This image will be listed in your private images.

API examples:

Meanwhile for API, I will provide some REST requests that may help you:

  • To create a new standard image, execute:

URL:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/5464742/createArchiveTransaction.json

Method: POST

Json:
*-----------------------
{
  "parameters": [
    "my-new-standard-image-name ",
    [
      {
        "id": 6862924,
        "complexType": "SoftLayer_Virtual_Guest_Block_Device"
      }
    ],
    "api note"
  ]
}
*-----------------------

where: 

" my-new-standard-image-name " is the group name for the archive
"6862924" A computing instance block device's unique ID
"api note" is A long note describing the image template
"5464742" is the id of virtual server

How to get the “block device's unique ID”?

Please, execute:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[Virtual_Guest_ID]/getBlockDevices?objectFilter={"blockDevices":{"bootableFlag":{"operation": "1"}}}&objectMask=mask[id]

After executing the “SoftLayer_Virtual_Guest::createArchiveTransaction” a new transaction will be created in the server, please wait some minutes until it is completed.

Reference: http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createArchiveTransaction

  • How to load from image via API?

URL:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[Virtual_Guest_ID]/reloadOperatingSystem

Method: POST

    Json:

*----------------------------    
{
  "parameters": [
    "f610b52f9fce12ef4fc37d6e9f5fe77a",
    {
      "imageTemplateId": 931371
    }
  ]
}
*----------------------------    

Where:

“f610b52f9fce12ef4fc37d6e9f5fe77a” is the token (The token will remain active for 10 minutes)
“931371” the image template to use

But, How to get the token for our above configuration?

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[Virtual_Guest_ID]/reloadOperatingSystem
    Method: GET

References:

http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/reloadOperatingSystem http://knowledgelayer.softlayer.com/learning/introduction-image-templates http://knowledgelayer.softlayer.com/faq/what-standard-image-template http://knowledgelayer.softlayer.com/faq/what-flex-image http://knowledgelayer.softlayer.com/procedure/create-standard-image http://knowledgelayer.softlayer.com/procedure/create-flex-image

Regards.