[英]how is Softlayer location defined when working with SoftLayer API?
我正在使用SoftLayer API的Python腳本(示例代碼place_order_several_vms_vlan.py位於https://softlayer.github.io/python/ )上。 要設置的一個屬性是“位置”。 在這種情況下,如何為SoftLayer定義location屬性?
到目前為止,我只能使用“ AMSTERDAM”。 其他任何事件,例如DAL05,都失敗了。
感謝有人在使用SoftLayer API時是否可以提供可以在此上下文中使用的位置列表。
該位置是您要配置虛擬機的位置,而您使用的python腳本示例是在AMSTERDAM位置中放置一個新的虛擬機訂單。
要獲取所有可用於配置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/
您必須記住,每個位置的商品價格都不同。
要獲取商品價格及其位置,您可以使用以下rest 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或更高核心”,商品價格id將為“ id”:112475,您將看到該商品的可用位置。
如果找不到商品的地點是因為商品價格是標准價格,則意味着該商品的所有地點都可用。
參考:
https://softlayer.github.io/reference/services/SoftLayer_Product_Package/getItemPrices/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.