首页 文章

使用SoftLayer API时如何定义Softlayer位置?

提问于
浏览
0

我正在使用SoftLayer API的Python脚本(示例代码为place_order_several_vms_vlan.py,位于https://softlayer.github.io/python/) . 要设置的一个属性是"location" . 如何在此上下文中为SoftLayer定义location属性?

到目前为止,我只能使用“AMSTERDAM” . 其他任何东西,如DAL05,都失败了 .

感谢是否有人可以在使用SoftLayer API时提供可在此上下文中使用的位置列表 .

1 回答

  • 0

    该位置是您的vm将被配置的位置,您正在使用的python脚本示例是在AMSTERDAM位置放置一个新的vm顺序 .

    要获得可用于配置vm的所有位置,请使用此rest api .

    方法:GET

    https://[username]:[apiKey]@api.softlayer.com/rest/v3.1/SoftLayer_Location/getDatacenters
    

    参考:

    https://softlayer.github.io/reference/services/SoftLayer_Location/getDatacenters/

    您必须记住,每个位置的商品价格都不同 .

    要获取商品价格及其位置,您可以使用以下休息API:

    方法:GET

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

    响应例如如下:

    {
            "currentPriceFlag": null,
            "hourlyRecurringFee": ".018",
            "id": 112475,
            "itemId": 857,
            "laborFee": "0",
            "locationGroupId": 503,
            "onSaleFlag": null,
            "oneTimeFee": "0",
            "quantity": null,
            "recurringFee": "11.21",
            "setupFee": "0",
            "sort": 0,
            "tierMinimumThreshold": null,
            "item": {
                "capacity": "1",
                "description": "1 x 2.0 GHz or higher Core",
                "id": 857,
                "itemTaxCategoryId": 166,
                "keyName": "GUEST_CORE_1",
                "softwareDescriptionId": null,
                "units": "CORE",
                "upgradeItemId": null
            },
            "pricingLocationGroup": {
                "description": "Location Group 2",
                "id": 503,
                "locationGroupTypeId": 82,
                "name": "Location Group 2",
                "securityLevelId": null,
                "locations": [
                    {
                        "id": 449610,
                        "longName": "Montreal 1",
                        "name": "mon01",
                        "statusId": 2
                    },
                    {
                        "id": 449618,
                        "longName": "Montreal 2",
                        "name": "mon02",
                        "statusId": 2
                    },
                    {
                        "id": 448994,
                        "longName": "Toronto 1",
                        "name": "tor01",
                        "statusId": 2
                    },
                    {
                        "id": 350993,
                        "longName": "Toronto 2",
                        "name": "tor02",
                        "statusId": 2
                    },
                    {
                        "id": 221894,
                        "longName": "Amsterdam 2",
                        "name": "ams02",
                        "statusId": 2
                    },
                    {
                        "id": 265592,
                        "longName": "Amsterdam 1",
                        "name": "ams01",
                        "statusId": 2
                    },
                    {
                        "id": 814994,
                        "longName": "Amsterdam 3",
                        "name": "ams03",
                        "statusId": 2
                    }
                ]
            }
        },
    

    例如对于“1 x 2.0 GHz或更高Core”项目,商品价格ID将为“id”:112475,您将看到此商品的可用位置 .

    如果您没有找到商品的位置是因为商品价格是标准的,则表示此商品的所有商家都可以使用 .

    参考:

    https://softlayer.github.io/reference/services/SoftLayer_Product_Package/getItemPrices/

相关问题