December 10, 2012

Dedicated server ordering with Flex Image and Python<p>Automating server provisioning is not only fun, it can also save you the time and pain recovering from the carpal tun

Automating server provisioning is not only fun, it can also save you the time and pain recovering from the carpal tunnel all of the clicking and typing ordering 100's of servers from the managment portal can cause. To save you from that fate I have put together this guide in hopes to help you explore the world of order automation with the SoftLayer API :)

We will assume that at some earlier point in time we have created a Flex Image. Each image is a point in time snapshot of your primary drive, complete with OS and software configurations which means less work once the server is online.

To create an dedicated server order using Flex Image we must define the following:
*ID of the Flex Image template
*Package ID
*Location
*Item prices(a list of items the new server will have: RAM, CPUs, storage, etc...)
*List of "hardware"
*Quantity of servers to order
Let us start our journey into the depths of server ordering by grathering the template id of our Flex Image. However, as with most people we could not be bothered to remember the actual integer which defines our template; we simply remember the name we gave it.
So off we are to search for the Flex Image's ID, armed with our trusty template name...

Now for the fun one: item prices. The item prices can be a bit daunting to gather at first. Each package has a configuration which defines what type of items must be included in each order. It achieves this by grouping items in categories which can be listed as optional or required. To determine a list of options from categories which must include we will use this script:

There is no particular need to have all of these scripts in this discrete format. In fact, they are most useful when combined together into a super-automation-script...but that task I leave to you. Hopefully this will help light your path on the way to no-hands server ordering!