简体   繁体   中英

Reload a different OS using reloados REST API

I issue the following URL to reload a virtual guest with the current OS. rest/v3/SoftLayer_Virtual_Guest/1234/reloadOperatingSystem

What parameter do I specify to reload the virtual guest with a different operating system?

The SoftLayer_Virtual_Guest::reloadOperatingSystem service has a confirmation protocol for proceeding with the reload. To proceed with the reload without confirmation, simply pass in 'FORCE' as the token parameter, so you can use a request as below:

Method POST:

https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/123456/reloadOperatingSystem

Body:

{
   "parameters":[
      "FORCE",
      {
         "itemPrices":[
            {
               "id":211481
            }
         ]
      }
   ]
}

Also, you can get the operating system prices by filtering the items by description:

Method GET:

https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/1035/getItems.json?objectMask=mask[description,id,prices[id]]&objectFilter={"items":{"description":{"operation":"*= Ubuntu"}}}

Output example:

[
    {
        "description": "Ubuntu Linux 18.04 LTS Bionic Beaver LAMP Install (64 bit)",
        "id": 11429,
        "prices": [
            {
                "id": 211481
            }
        ]
    }
]

Keep in mind to use the same package id used in the virtual guest, below a way to get it (guessing that 123456 is the virtual guest identifier).

Method GET:

https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/123456/getObject.json?objectMask=mask[typeId,billingItem[categoryCode,package[name,id]]]

Output example:

{
    "typeId": 1,
    "billingItem": {
        "categoryCode": "guest_core",
        "package": {
            "id": 1035,
            "name": "Public Virtual Server (hourly)"
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM