SoftLayer API无法识别新的Datacenter(osl01)

时间:2016-12-22 23:59:17

标签: ibm-cloud-infrastructure

如下所示,API无法识别挪威的新SoftLayer数据中心。此调用适用于其他数据中心。

SoftLayer.managers.hardware._get_location(package, "osl01")

Traceback (most recent call last):
...
SoftLayer.exceptions.SoftLayerError: Could not find valid location for: 'osl01'

2 个答案:

答案 0 :(得分:0)

我无法使用Bare Metal(Package 200)作为测试复制此项。你能指定一下你看到的包ID吗?

import SoftLayer
import json

package_id = 200
datacenter = 'osl01'

client = SoftLayer.Client()

location_object_filter = {
    'name': {'operation': datacenter}
}

location_object_mask = "priceGroups"

location = client["SoftLayer_Location_Datacenter"].getDatacenters(filter=location_object_filter, mask=location_object_mask)

if len(location) == 0:
    # error handling
    exit()

# lookup location group ids
location_group_ids = []
for location_group in location[0]["priceGroups"]:
    location_group_ids.append(location_group["id"])

object_filter_standard = {
    'items': {
        "prices": {
            "locationGroupId": {
                "operation": "is null"
            }
        }
    }
}

standard_items = client["SoftLayer_Product_Package"].getItems(id=package_id, filter=object_filter_standard)

object_filter_location = {
    'items': {
        "prices": {
            "locationGroupId": {
                "operation": "in",
                "options": [
                    {
                        "name": "data",
                        "value": location_group_ids
                    }
                ]
            }
        }
    }
}

location_items = client["SoftLayer_Product_Package"].getItems(id=package_id, filter=object_filter_location)

# let's key by item id
items = {}

for standard_item in standard_items:
    for location_item in location_items:
        if location_item["id"] == standard_item["id"]:
            items[location_item["id"]] = location_item
            break

    if standard_item["id"] not in items:
        items[standard_item["id"]] = standard_item


print(json.dumps(items, sort_keys=True, indent=2, separators=(',', ': ')))

答案 1 :(得分:0)

您是否可以提供有关如何获取对象的信息?或者您要发送的对象?

  

257 有"奥斯陆1"分配区域中的数据中心,但是   对于 251 包是预期的,因为该包不可用   "奥斯陆1"作为一个地区