Softlayer API下订单返回包(835)需要预设配置错误

时间:2017-11-08 05:37:09

标签: api ibm-cloud-infrastructure

当我使用SoftLayer API使用特定CPU,ram和第一个磁盘的风格创建CCI时,我无法像以前那样连接第二个磁盘。

我粘贴流程详情:

  1. 通过createObject创建CCI,参数如下:

    POST https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest.json
    {
        "parameters": [
            {
                "blockDeviceTemplateGroup": {
                    "globalIdentifier": "2aae2a36-76f3-4d2f-9881-e86fa15b040b"
                },
                "datacenter": {
                    "name": "dc02"
                },
                "dedicatedAccountHostOnlyFlag": false,
                "domain": "softlayer.com",
                "hostname": "server-ed-20171108-032526-888",
                "hourlyBillingFlag": true,
                "localDiskFlag": false,
                "networkComponents": [
                    {
                        "maxSpeed": 100
                    }
                ],
                "primaryBackendNetworkComponent": {
                    "networkVlan": {
                        "id": 12345678,
                        "networkSpace": "PRIVATE"
                    }
                },
                "primaryNetworkComponent": {
                    "networkVlan": {
                        "id": 12345676,
                        "networkSpace": "PUBLIC"
                    }
                },
                "privateNetworkOnlyFlag": false,
                "supplementalCreateObjectOptions": {
                    "flavorKeyName": "B1_4X8X25"
                }
            }
        ]
    }
    
  2. 等待提供完成

  3. 请求SoftLayer_Product_Package对象以下订单

    GET https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/{vmid}.json?objectMask=mask%5BprimaryBackendNetworkComponent%5BprimaryIpAddress%2C+networkVlan%5Bid%2Cname%2CvlanNumber%2CprimaryRouter%5D%2C+subnets%5Bnetmask%2CnetworkIdentifier%5D%5D%2C+primaryNetworkComponent%5BprimaryIpAddress%2C+networkVlan%5Bid%2Cname%2CvlanNumber%2CprimaryRouter%5D%2C+subnets%5Bnetmask%2CnetworkIdentifier%5D%5D%5D
    

    Softlayer返回两个包(我先用过)

    [
        {
            "description": "Virtual Server Instance",
            "id": 46,
            "isActive": 1,
            "name": "Cloud Server",
            "type": {
                "keyName": "VIRTUAL_SERVER_INSTANCE"
            }
        },
        {
            "description": "Public Virtual Server",
            "id": 835,
            "isActive": 1,
            "name": "Public Virtual Server",
            "type": {
                "keyName": "VIRTUAL_SERVER_INSTANCE"
            }
        }
    ]  
    
  4. 请求SoftLayer_Virtual_Guest getUpgradeItemPrices以查找第二个磁盘的升级项目价格

    POST https://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/{vmid}/getUpgradeItemPrices.json
    

    获得167件商品价格并选择第一件商品匹配categoryCode和capacity。

  5. 下订单

    POST https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Order/placeOrder.json
    Parameters:
    {
        "parameters": [
            {
                "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade",
                "packageId": 46,
                "prices": [
                    {
                        "categories": [
                            {
                                "categoryCode": "guest_disk1",
                                "id": 82,
                                "name": "Second Disk",
                                "quantityLimit": 0
                            }
                        ],
                        "currentPriceFlag": false,
                        "hourlyRecurringFee": 0.013,
                        "id": 112953,
                        "item": {
                            "attributes": [
                                {
                                    "attributeType": {
                                        "keyName": "SAN_DISK",
                                        "name": "SAN Disk"
                                    },
                                    "id": 196,
                                    "itemAttributeTypeId": 50,
                                    "itemId": 922,
                                    "value": "1"
                                }
                            ],
                            "capacity": 100,
                            "description": "100 GB (SAN)",
                            "id": 922,
                            "itemTaxCategoryId": 166,
                            "keyName": "GUEST_DISK_100_GB_SAN_3",
                            "localDiskFlag": false,
                            "units": "GB"
                        },
                        "itemId": 922,
                        "laborFee": 0,
                        "locationGroupId": 505,
                        "oneTimeFee": 0,
                        "pricingLocationGroup": {
                            "description": "Location Group 3",
                            "id": 505,
                            "locationGroupType": {
                                "name": "PRICING"
                            },
                            "locationGroupTypeId": 82,
                            "locations": [
                                {
                                    "id": 449600,
                                    "longName": "Mexico 1",
                                    "name": "mex01",
                                    "statusId": 2
                                },
                                {
                                    "id": 2124095,
                                    "longName": "London 6",
                                    "name": "lon06",
                                    "statusId": 2
                                },
                                {
                                    "id": 167094,
                                    "longName": "London 1",
                                    "name": "lon01",
                                    "statusId": 2
                                },
                                {
                                    "id": 358694,
                                    "longName": "London 2",
                                    "name": "lon02",
                                    "statusId": 2
                                },
                                {
                                    "id": 2017395,
                                    "longName": "London 4",
                                    "name": "lon04",
                                    "statusId": 2
                                },
                                {
                                    "id": 1541257,
                                    "longName": "Oslo 1",
                                    "name": "osl01",
                                    "statusId": 2
                                }
                            ],
                            "name": "Location Group 3"
                        },
                        "recurringFee": 7.98,
                        "setupFee": 0,
                        "sort": 0
                    }
                ],
                "properties": [
                    {
                        "name": "MAINTENANCE_WINDOW",
                        "value": "2017-11-08T03:34:12Z"
                    },
                    {
                        "name": "NOTE_GENERAL",
                        "value": "Upgrade instance configuration."
                    }
                ],
                "virtualGuests": [
                    {
                        "id": {vmid}
                    }
                ]
            },
            false
        ]
    }
    

    此请求因Response: {"error":"Invalid data on the order for property: packageId. Package (835) requires a preset configuration.","code":"SoftLayer_Exception_Order_InvalidData"}

  6. 而出错

    请求是我使用包'46'进行升级,但Softlayer返回有关包'835'的错误。那是什么意思?

1 个答案:

答案 0 :(得分:1)

尝试在请求中添加值为“0”的属性“presetId”,packageId也将其设置为0.例如

POST https://api.softlayer.com/rest/v3.1/SoftLayer_Product_Order/placeOrder.json
Parameters:
{
    "parameters": [
        {
            "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade",
            "packageId": 0,
            "presetId": 0,
            "prices": [
                {
                    "categories": [
                        {
                            "categoryCode": "guest_disk1",
                            "id": 82,
                            "name": "Second Disk",
                            "quantityLimit": 0
                        }
                    ],
                    "currentPriceFlag": false,
                    "hourlyRecurringFee": 0.013,
                    "id": 112953,
                    "item": {
                        "attributes": [
                            {
                                "attributeType": {
                                    "keyName": "SAN_DISK",
                                    "name": "SAN Disk"
                                },
                                "id": 196,
                                "itemAttributeTypeId": 50,
                                "itemId": 922,
                                "value": "1"
                            }
                        ],
                        "capacity": 100,
                        "description": "100 GB (SAN)",
                        "id": 922,
                        "itemTaxCategoryId": 166,
                        "keyName": "GUEST_DISK_100_GB_SAN_3",
                        "localDiskFlag": false,
                        "units": "GB"
                    },
                    "itemId": 922,
                    "laborFee": 0,
                    "locationGroupId": 505,
                    "oneTimeFee": 0,
                    "pricingLocationGroup": {
                        "description": "Location Group 3",
                        "id": 505,
                        "locationGroupType": {
                            "name": "PRICING"
                        },
                        "locationGroupTypeId": 82,
                        "locations": [
                            {
                                "id": 449600,
                                "longName": "Mexico 1",
                                "name": "mex01",
                                "statusId": 2
                            },
                            {
                                "id": 2124095,
                                "longName": "London 6",
                                "name": "lon06",
                                "statusId": 2
                            },
                            {
                                "id": 167094,
                                "longName": "London 1",
                                "name": "lon01",
                                "statusId": 2
                            },
                            {
                                "id": 358694,
                                "longName": "London 2",
                                "name": "lon02",
                                "statusId": 2
                            },
                            {
                                "id": 2017395,
                                "longName": "London 4",
                                "name": "lon04",
                                "statusId": 2
                            },
                            {
                                "id": 1541257,
                                "longName": "Oslo 1",
                                "name": "osl01",
                                "statusId": 2
                            }
                        ],
                        "name": "Location Group 3"
                    },
                    "recurringFee": 7.98,
                    "setupFee": 0,
                    "sort": 0
                }
            ],
            "properties": [
                {
                    "name": "MAINTENANCE_WINDOW",
                    "value": "2017-11-08T03:34:12Z"
                },
                {
                    "name": "NOTE_GENERAL",
                    "value": "Upgrade instance configuration."
                }
            ],
            "virtualGuests": [
                {
                    "id": {vmid}
                }
            ]
        },
        false
    ]
}

如果能解决您的问题,请告诉我。