0
votes

I want to create cloud object storage using python API and referred to link https://sldn.softlayer.com/blog/waelriac/managing-softlayer-object-storage-through-rest-apis. When I use following command to order CLOUD_OBJECT_STORAGE, it prompt errors. Did I miss some config or give the wrong config?

payload = '{"parameters" : [{"complexType": "SoftLayer_Container_Product_Order_Network_Storage_Hub", "quantity": 1, "packageId": 206, "prices": [{"id": 177725}]}]}'

client['SoftLayer_Product_Order'].placeOrder(payload)

client['SoftLayer_Product_Order'].placeOrder(payload) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 392, in call_handler return self(name, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 360, in call return self.client.call(self.name, name, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/SoftLayer/API.py", line 263, in call return self.transport(request) File "/usr/local/lib/python2.7/dist-packages/SoftLayer/transports.py", line 195, in call raise _ex(ex.faultCode, ex.faultString) SoftLayer.exceptions.SoftLayerAPIError: SoftLayerAPIError(SoftLayer_Exception_Order_InvalidContainer): Invalid container specified: SoftLayer_Container_Product_Order. Ordering a server or service requires a specific container type, not the generic base order container.

1

1 Answers

0
votes

well in order to call the Softlayer's API methods using the Soflayer's Python client the request are differents from REST request I recomend you to review documentation to get more information.

this is the code you need to use:

import SoftLayer

USERNAME="set me"    
APIKEY="set me"      

client = SoftLayer.create_client_from_env(
    username=USERNAME,
    api_key=APIKEY
)

order = {
    "quantity": 1,
    "packageId": 206,
    "prices": [{
        "id": 177725
    }]
}

result = client['SoftLayer_Product_Order'].verifyOrder(order)
print (result)

Another thing to point out is that you need to make sure that you are using the correct price, the prices can be different for each account, so in order to make sure you are using the correct price I recomend you to call the SoftLayer_Product_Package:getItemPrices

Using Python use this:

result = client['SoftLayer_Product_Package'].getItemPrices(id=206)
print (result)

Regards