November 23, 2017
Get available locations.

This script will retrieve a collection of valid locations for a given package and the server.
It displays the same locations as Control Portal does.
E.g: Portal Link:
package = 265
server = 49565
Important manual pages:
@Author: SoftLayer Technologies, Inc. <>

# So we can talk to the SoftLayer API:
import SoftLayer

# Your SoftLayer API username and key.
API_USERNAME = 'set me'
API_KEY = 'set me'
# Declare the package id
package = 200
# Declare the server id
server = 37318
# Create a client instance
client = SoftLayer.Client(username=API_USERNAME, api_key=API_KEY)
# Declare an object mask to get location conflicts for the server
priceMask = 'mask[locationConflicts]'
    flag = False
    locations = client['SoftLayer_Product_Package'].getRegions(id=package)
    locationConflicts = client['SoftLayer_Product_Item_Price'].getItem(id=server, mask=priceMask)
    print('*****   AVAILABLE LOCATIONS   *****')
    for location in locations:
        for locationConflict in locationConflicts['locationConflicts']:
            if location['location']['location']['id'] == locationConflict['resourceTableId']:
                flag = False
        if flag:
            print('Id: %s, Location Name: %s' % (location['location']['location']['id'], location['location']['location']['longName']))
        flag = True
except SoftLayer.SoftLayerAPIError as e:
    print("Unable to get available locations faultCode=%s, faultString=%s" % (e.faultCode, e.faultString))