2016-12-22 2 views
1

Wie unten gezeigt, wird das neue SoftLayer Datacenter in Norwegen von der API nicht erkannt. Dieser Aufruf funktioniert mit anderen Datencentern.SoftLayer API erkennt neues Datacenter nicht (osl01)

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

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

Antwort

0

Ich bin nicht in der Lage, dies mit Bare Metal (Package 200) als Test zu replizieren. Können Sie angeben, mit welcher Paket-ID Sie dies sehen?

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=(',', ': '))) 
+0

Wir haben versucht, Pakete 257 und 251. – sambol

+0

dass ungerade ist, ich bin das nicht in der Lage zu replizieren mit 257 oder 251. Wenn Sie in der Lage sind hier, um das Codebeispiel verwenden https: //softlayer.github. io/python/location_based_pricing/dann kann es mit dem Python-Manager (Helfer) sein. Wenn dies der Fall ist, können Sie ein Problem unter https://github.com/softlayer/softlayer-python/issues öffnen. – greyhoundforty

0

könnten Sie Informationen darüber, wie Sie sind Paket Objekt zu bekommen? oder das Objekt, das du sendest?

The package 257 has "Oslo 1" datacenter in regions assigned, but for 251 package is expected, because the package has not available "Oslo 1" as a region

+0

Hilft das? 'File "/home/blueboxadmin/sambol/venv/local/lib/python2.7/site-packages/SoftLayer/managers/hardware.py", Linie 738, in _get_location % location) SoftLayer.exceptions.SoftLayerError : Konnte keinen gültigen Ort für: 'osl01'' finden – sambol

+0

Nun, es ist notwendig, den Weg zu bekommen, dass Sie das ** Paket ** erhalten, denn wenn Sie ** Paket [' Regionen '] ** drucken, bin ich wirklich sicher, dass Sie nicht 'Oslo 1' als Datencenter haben, diese Methode ** _ get_location ** bekommt nur die spezifische Region aus dem ** Paket ** Objekt, das Sie senden, so ist das Problem in der Art, wie Sie bekommen ** Paket ** Objekt –

+0

So erhalten wir das Paket: https://gist.github.com/sambol/20ab5b573a45494a207e26a959d55a61 – sambol

Verwandte Themen