0

When I want to upgrade/downgrade virtual guest or create a new virtual guest, we need some configs options, but I don't know how to get these available configs?

On the same time, how about disk and network?

Jérémie Bertrand
  • 3,025
  • 3
  • 44
  • 53
JerryZ
  • 5
  • 2

1 Answers1

0

To create a virtual guest the control portal use several services and methods to identify the possible type configurations as you require, for this you`ll have to use a supported programming language and programmatically create your own script as there is no specific api to retrieve the config types in one or two api calls

To determine possible options available when creating a compute instance, you could use SoftLayer_Virtual_Guest::getCreateObjectOptions method along with these other methods.

There are two ways to create a virtual guest: SoftLayer_Virtual_Guest::createObject or SoftLayer_Product_Order::placeOrder, see the followings links to create a vm:

About to get the network vlans available for the "primaryNetworkComponent"(public) and "primaryBackendNetworkComponentyou"(private) to add to the vm, you can use the followings rest api:

Method: GET

https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getPrivateNetworkVlans?objectMask=mask[billingItem[location]]

https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Account/getPublicNetworkVlans?objectMask=mask[billingItem[location]]

You have to keep in mind that the vlans that you are going to add to the vm must be in the same datacenter.

To get the item prices available e.g cpu, ram, os, disk,etc use this rest api:

Method: GET

https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Product_Package/46/getItemPrices?objectMask=mask[pricingLocationGroup[locations]]

These items must be in the same datacenter.

Related to Upgrade/Downgrade, the method will be the same as placeOrder, only the structure will differ in the Json body, please see below for this example:

POST https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Order/placeOrder

body: 
    {
        "parameters": [{
            "virtualGuests": [{
                "id": 49495232
            }],
            "prices": [{
                    "id": 2277,
                    "categories": [{
                        "categoryCode": "guest_disk1",
                        "complexType": "SoftLayer_Product_Item_Category"
                    }],
                    "complexType": "SoftLayer_Product_Item_Price"
                },

                {
                    "id": 2270,
                    "categories": [{
                        "categoryCode": "guest_disk2",
                        "complexType": "SoftLayer_Product_Item_Category"
                    }],
                    "complexType": "SoftLayer_Product_Item_Price"
                }
            ],
            "properties": [

                {
                    "name": "NOTE_GENERAL",
                    "value": "adding disks"
                },

                {
                    "name": "MAINTENANCE_WINDOW",
                    "value": "2014-08-25T9:50:00-05:00"
                }
            ],
            "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade"
        }]
    }

How to add two or more disk to softlayer virtual server while provisioning

See these other examples:

New items for SoftLayer virtual server order?

How to get the proper list of SoftLayer datacenters for a given package?

Creating a vGPU device with second disk

F.Ojeda
  • 718
  • 1
  • 4
  • 8
  • How to get all config options eg cpu memory disk etc when upgrade virtual guest,like upagrading on IBM console – JerryZ Jun 29 '18 at 09:30
  • Use the following rest api to get all config options to upgrade your virtual guest: Method: POST https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/[virtualGuestId]/getUpgradeItemPrices Body: Json { "parameters": [ true ] } The "true" data in the body is to include the downgrade item prices. For more information see this documentation: https://softlayer.github.io/reference/services/SoftLayer_Virtual_Guest/getUpgradeItemPrices/ – F.Ojeda Jun 29 '18 at 14:46
  • Thanks for your help , and the response data from getUpgradeItemPrices api is CPU alone, memory alone. How do I know if there is a valid combination between them, such as c1.1*1 and c1.2*2 in console – JerryZ Jul 02 '18 at 09:45
  • And how i can get options when i create instance, because getCreateObjectOptions' response is not detail data, i think ,it look like only have disk information – JerryZ Jul 02 '18 at 09:49
  • This method returns all the item prices that are available to make an upgrade or downgrade as in the portal control, that is only cpu, ram, disks, and Uplink Port Speeds. You can choose any combination of items as in the portal control. – F.Ojeda Jul 02 '18 at 15:17
  • I explained in the rest api above how to obtain the necessary items to be able to create an new instance and the method getCreateObjectOptions is only to know the possible options available, the control portal does not use this method to create a vm, just is a reference. To get the item prices availables you have to use getItemPrices, as I explained above. – F.Ojeda Jul 02 '18 at 15:27