Skip to content

Instantly share code, notes, and snippets.

@underscorephil
underscorephil / gist:3790139
Created September 26, 2012 19:44
Python Upgrade CCI
# So we can talk to the SoftLayer API, grab the current date
# and structured list/dict output
import SoftLayer.API
import datetime
from pprint import pprint as pp
# Find the priceId for the RAM item matching our defined memory allotment
def getMemoryPrice(memoryCapacity):
packageClient = SoftLayer.API.Client('SoftLayer_Product_Package', 46, apiUsername, apiKey)
@underscorephil
underscorephil / gist:3777178
Created September 24, 2012 17:32
Command Line Order CCI
import SoftLayer.API
import pprint
def table_print(data, title_row):
max_widths = {}
data_copy = [dict(title_row)] + list(data)
for col in data_copy[0].keys():
max_widths[col] = max([len(str(row[col])) for row in data_copy])
cols_order = [tup[0] for tup in title_row]
@underscorephil
underscorephil / gist:3693506
Created September 10, 2012 20:09
Create Object Storage Client
function _getObjectStorageClient() {
$options = array('adapter' => ObjectStorage_Http_Client::SOCKET, 'timeout' => 10);
$host = 'https://dal05.objectstorage.softlayer.net'; // the SoftLayer Object Storage API host
$username = OBJSTOR_USER; // user name and password is display at https://manage.softlayer.com/ObjectStorage/index
$password = API_KEY;
return new ObjectStorage($host, $username, $password, $options);
}
@underscorephil
underscorephil / gist:3693460
Created September 10, 2012 20:00
Retrieve Transcode FTP Credentials
function _getFtpCredentials() {
$accountClient = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, API_USER, API_KEY);
$transcodeAccount = array_shift($accountClient->getTranscodeAccounts());
$transcodeAccountClient = SoftLayer_SoapClient::getClient('SoftLayer_Network_Media_Transcode_Account', $transcodeAccount->id, API_USER, API_KEY);
return($transcodeAccountClient->getFtpAttributes());
}
@underscorephil
underscorephil / gist:3519545
Created August 29, 2012 22:11
Cancel Multiple Servers
<?php
require_once('SoftLayer/SoapClient.class.php');
/**
* Set your SoftLayer API username and key.
*/
$apiUsername = '';
$apiKey = '';