Search code examples
restibm-cloud-infrastructure

Softlayer- A template guest record is required to use this method


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?


Solution

  • 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: