0
votes

I am working on a Python script (sample code place_order_several_vms_vlan.py at https://softlayer.github.io/python/) that uses SoftLayer API. One attribute to set is "location". How is the location attribute is defined for SoftLayer in this context?

So far, I can only use "AMSTERDAM". Anything else, such as DAL05, failed.

Appreciate if someone can provide a list of locations that can be used in this context when working with SoftLayer API.

1
What is the error that you get when you use another location. - F.Ojeda

1 Answers

0
votes

The location is where your vm will be provisioned, and the python script example you are using is to place a new vm order in the AMSTERDAM location.

To get all the locations available to provision your vm use this rest api.

Method: GET

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

Reference:

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

You have to keep in mind that the item prices are different for each location.

To get the item prices and their locations you can use the following rest api:

Method: GET

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

The response e.g will be like this:

{
        "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
                }
            ]
        }
    },

e.g. for the item "1 x 2.0 GHz or higher Core", the item price id will be "id": 112475, and you will see the locations available for this item.

If you do not find locations for a item is because the item price is standard, it means that all locations are available for this item.

Reference:

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