1

I am using postman REST client to execute softlayer REST API's.current trying to create snapshot of vm

I am getting error,

"A template guest record is required to use this method"

when executing below rest call:

https://[username]:[api-key]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[virtual_guest_id]/

in form data using below file createArchiveTransaction.json:

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

Can anyone help me with this issue?

Vinoth Krishnan
  • 2,925
  • 6
  • 29
  • 34
Raghav
  • 89
  • 10

1 Answers1

1

Follow these steps to create an image from Virtual Guest.

1 Get Block Devices from Virtual Guest

The following Rest request will help with it:

https://[username]:[api-key]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/22334455/getBlockDevices?objectMask=mask[diskImage[name, description]]

Method: Get

Replace 22334455 with your VSI id.

You will get a result like this:

[
  {
    "bootableFlag": 1,
    "createDate": "2015-09-21T15:20:27-03:00",
    "device": "0",
    "diskImageId": 10629873,
    "guestId": 22334455,
    "hotPlugFlag": 0,
    "id": 11223344,
    "modifyDate": "2015-10-19T13:25:53-03:00",
    "mountMode": "RW",
    "mountType": "Disk",
    "statusId": 1,
    "uuid": "c1d1d92a-42ee-cdef-47sdfsf3543456e1e17",
    "diskImage": {
      "description": "test.softlayer.com",
      "name": "test.softlayer.com"
    }
  },
  {
    "bootableFlag": 0,
    "createDate": "2015-10-19T13:24:58-03:00",
    "device": "1",
    "diskImageId": 11277111,
    "guestId": 22334455,
    "hotPlugFlag": 0,
    "id": 111122233,
    "modifyDate": null,
    "mountMode": "RW",
    "mountType": "Disk",
    "statusId": 1,
    "uuid": "38987d23-8395-aasdfsdf23434a602",
    "diskImage": {
      "description": "22334455-SWAP",
      "name": "22334455-SWAP"
    }
  },
  {
    "bootableFlag": 1,
    "createDate": "2015-09-21T15:20:42-03:00",
    "device": "3",
    "diskImageId": null,
    "guestId": 22334455,
    "hotPlugFlag": 1,
    "id": 33445566,
    "modifyDate": "2015-10-19T13:31:35-03:00",
    "mountMode": "RO",
    "mountType": "CD",
    "statusId": 1,
    "uuid": "4b3e59af-ed6a-3c96-sfsdf234a4aa708ff"
  }
]

2 Create image template

Make sure to not include swap partition and CD mounts.

https://[username]:[api-key]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/22334455/createArchiveTransaction

Method: Post

{  
   "parameters":[  
      "testGroupNameRcv",
      [  
         {  
            "id":11223344
         }
      ],
      "Note for test"
   ]
}

Replace 11223344 and 22334455 with your identifiers from your Virtual Guest and its block device(s)

References:

  • Hi Ruber,..I followed these steps , now I am getting below error { "error": "No block devices provided to archive.", "code": "SoftLayer_Exception_Public" } – Raghav May 13 '16 at 08:05
  • Apparently the issue is when no block devices defined in the body, but if you followed the steps, the image should be created. Could you submit a ticket please? Don't forget to provide the request that you are trying – Ruber Cuellar Valenzuela May 13 '16 at 15:48
  • ok sure thank you..I will raise ticket and provide the request that i am trying – Raghav May 13 '16 at 16:57
  • according to the issue, you are trying to upload a file "createArchiveTransaction.json" as parameter. I'm not sure which Tool you are using, but I think the file is not consider as parameters. I can recommend to use [Advanced Rest Client for Chrome](https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo) and send the parameters in "Raw payload" section. – Ruber Cuellar Valenzuela May 16 '16 at 15:37
  • Hi Ruber, I am using postman REST client of chrome. I tried sending parameters instead of json file but faced same issue – Raghav May 17 '16 at 06:27
  • I have selected URL params and passing arguments as below url params value groupName abc blockDevices [{ "id":19458813 }] note abc – Raghav May 17 '16 at 07:00
  • 1
    Did you try to send the parameters in "raw" section? Because the only way to load files that I found is: "Body >> binary >> Choose Files" but according to: [Postman - Sending Requests](https://www.getpostman.com/docs/requests) "binary" binary data allows you to send things which you can not enter in Postman. For example, image, audio or video files. You can send text files as well. As mentioned earlier in the form-data section, you would have to reattach a file if you are loading a request through the history or the collection. – Ruber Cuellar Valenzuela May 17 '16 at 13:59
  • Hi Ruber...it worked when I passed parameters through raw section ...Thank you very much – Raghav May 18 '16 at 10:27