首页 > 解决方案 > Softlayer API:如何获取我们可以与 softlayer api 一起使用的所有 Virtual_Guest 配置类型

问题描述

当我想升级/降级虚拟客户或创建一个新的虚拟客户时,我们需要一些配置选项,但我不知道如何获得这些可用配置?

同时,磁盘和网络呢?

标签: apiibm-cloud-infrastructurenim-lang

解决方案


要创建虚拟访客,控制门户使用多种服务和方法来根据需要识别可能的类型配置,为此,您必须使用受支持的编程语言并以编程方式创建自己的脚本,因为没有特定的 api 来检索在一两个 API 调用中配置类型

要确定创建计算实例时可用的可能选项,您可以将SoftLayer_Virtual_Guest::getCreateObjectOptions方法与这些其他方法一起使用。

创建虚拟机有两种方法:SoftLayer_Virtual_Guest::createObjectSoftLayer_Product_Order::placeOrder,创建虚拟机的链接如下:

关于获取可用于“primaryNetworkComponent”(公共)和“primaryBackendNetworkComponentyou”(私有)添加到虚拟机的网络vlan,您可以使用以下rest api:

方法:获取

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]]

您必须记住,要添加到 vm 的 vlan 必须位于同一个数据中心。

要获得可用的项目价格,例如 cpu、ram、os、disk 等,请使用以下 api:

方法:获取

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

这些项目必须位于同一个数据中心。

升级/降级相关,方法与placeOrder相同,只是Json主体结构不同,示例见下图:

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"
        }]
    }

如何在配置时将两个或更多磁盘添加到 softlayer 虚拟服务器

请参阅这些其他示例:

SoftLayer 虚拟服务器订单的新项目?

如何为给定的包获取正确的 SoftLayer 数据中心列表?

使用第二个磁盘创建 vGPU 设备


推荐阅读