restapiibm-cloudibm-cloud-infrastructure

How to Launch a compute Instance with data disk in IBM cloud using softlayer Rest API


I need to launch compute instance with volume creation using softlayer rest API and need to launch using globalIdentifier.

https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest.json

Body: { "parameters": [{ "complexType": "SoftLayer_Virtual_Guest", "maxMemory": 4, "hostname": "jagatest", "maxCpu": 2, "domain": "test.local", "hourlyBillingFlag": true, "startCpus": 1, "blockDeviceTemplateGroup": { "globalIdentifier": "375c7ad3-1b39-4c58-a657-7fc4351d7b06" }, "blockDevices": [{ "device": "0", "diskImage": { "capacity": 25 } }, { "device": "2", "diskImage": { "capacity": 10 } } ], "localDiskFlag": false, "datacenter": { "complexType": "SoftLayer_Location", "name": "sjc01" } }] }

Error Through:

{"error":"Invalid value provided for 'blockDevices'. Block devices may not be provided when using an image template.","code":"SoftLayer_Exception_InvalidValue"}


Solution

  • Try following next request

    Method POST

    https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/createObject.json

    Body

    {
      "parameters": [
        {
          "complexType": "SoftLayer_Virtual_Guest",
          "maxMemory": 4,
          "hostname": "jagatest",
          "maxCpu": 2,
          "domain": "test.local",
          "hourlyBillingFlag": true,
          "startCpus": 1,
          "blockDeviceTemplateGroup": {
            "globalIdentifier": "375c7ad3-1b39-4c58-a657-7fc4351d7b06"
          },
          "localDiskFlag": false,
          "datacenter": {
            "complexType": "SoftLayer_Location",
            "name": "sjc01"
          }
        }
      ]
    }