Using SoftLayer Python API placeOrder to add disks to vm
<p>I've created a softlayer VM using a custom image template.  I am able to add SAN disks to my vm using curl but I'm unsuccessful trying to do this with the Python SoftLayer library.  I receive the following error:</p>

<pre><code>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.
</code></pre>

<p>Here is my code:</p>

<pre><code>self.client = SoftLayer.Client(username='myusername@email.com', api_key='key')
console_id = 11111111

order = {
        "parameters": [{
            "virtualGuests": [{"id": console_id}],
            "prices": [{
                "id": 113031,
                "categories": [{
                    "categoryCode": "guest_disk1",
                    "complexType": "SoftLayer_Product_Item_Category"
                }],
                "complexType": "SoftLayer_Product_Item_Price"
            },
                {
                    "id": 112707,
                    "categories": [{
                        "categoryCode": "guest_disk2",
                        "complexType": "SoftLayer_Product_Item_Category"
                    }],
                    "complexType": "SoftLayer_Product_Item_Price"
                }
            ],
            "properties": [
                {"name": "NOTE_GENERAL", "value": "adding disks"},
                {"name": "MAINTENANCE_WINDOW", "value": "now"}
            ],
            "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade"
        }]
    }

# response = self.client['Product_Order'].placeOrder(order, False)        
response = self.client.call('Product_Order', 'placeOrder', order)

print response
</code></pre>

<p>If I run the following curl command however my vm updates are successful:</p>

<pre><code>curl -X POST --data @updatefile https://myusername%40email%2Ecom:apikey@api.softlayer.com/rest/v3.1/SoftLayer_Product_Order/placeOrder
</code></pre>

<p>Contents of updatefile:</p>

<pre><code>{
"parameters": [{
    "virtualGuests":[{"id":11111111}],
    "prices": [{
        "id": 113031,
        "categories": [{
            "categoryCode": "guest_disk1",
            "complexType": "SoftLayer_Product_Item_Category"
        }],
        "complexType": "SoftLayer_Product_Item_Price"
    },

    {
        "id": 112707,
        "categories": [{
            "categoryCode": "guest_disk2",
            "complexType": "SoftLayer_Product_Item_Category"
        }],
        "complexType": "SoftLayer_Product_Item_Price"
    }
    ],
    "properties": [
    {"name": "NOTE_GENERAL","value": "adding disks"},
    {"name": "MAINTENANCE_WINDOW","value": "now"}
    ],
    "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade"
}]
}
</code></pre>

<p>Any idea what I'm doing wrong?</p>

<p>yep, because when you are using the Softlayer's python client you do not have to specify the "paramters" property in your order that is only for RESTful request, remove it and it should work.</p>

<p>Try this:</p>

<pre><code>self.client = SoftLayer.Client(username='myusername@email.com', api_key='key')
console_id = 11111111

order = {
            "virtualGuests": [{"id": console_id}],
            "prices": [{
                "id": 113031,
                "categories": [{
                    "categoryCode": "guest_disk1",
                    "complexType": "SoftLayer_Product_Item_Category"
                }],
                "complexType": "SoftLayer_Product_Item_Price"
            },
                {
                    "id": 112707,
                    "categories": [{
                        "categoryCode": "guest_disk2",
                        "complexType": "SoftLayer_Product_Item_Category"
                    }],
                    "complexType": "SoftLayer_Product_Item_Price"
                }
            ],
            "properties": [
                {"name": "NOTE_GENERAL", "value": "adding disks"},
                {"name": "MAINTENANCE_WINDOW", "value": "now"}
            ],
            "complexType": "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade"
    }

response = self.client['Product_Order'].placeOrder(order)        


print response
</code></pre>

<p>Regards</p>

python curl softlayer