As the depletion of IPv4 space draws nearer we have added a new requirement when placing an order which contains addtional IP addresses. In addition to the usual suspects you will need to add an additional array to your order container object: itemCategoryQuestionAnswers.
One of the SL developers, Kien Phan, was kind enough to provide the example which can be found at the bottom of this post, but for the johnny-on-the-spots out there you can get a list of the possible questions with an Object Mask of questions for SoftLayer_Product_Item_Category with a categoryId of 14(secondary IP addresses).
And if you happen to have your API username and key handy you can follow the link:
https://api.softlayer.com/rest/v3/SoftLayer_Product_Item_Category/14/getObject.xml?objectMask=questions.description
-Phil
<?php | |
require_once dirname(__FILE__) . '/SoftLayer/SoapClient.class.php'; | |
/** | |
* Your SoftLayer API username. | |
* | |
* @var string | |
*/ | |
$apiUsername = 'API_USERNAME'; | |
/** | |
* Your SoftLayer API key. | |
* | |
* Generate one at https://manage.softlayer.com/Administrative/apiKeychain | |
* | |
* @var string | |
*/ | |
$apiKey = 'API_KEY'; | |
/** | |
* Create the skeleton SoftLayer_Container_Product_Order_Virtual_Guest (CCI) object and populate | |
* the necessary properties. | |
*/ | |
$virtualGuestOrder = new stdClass(); | |
/** | |
* The id of the SoftLayer_Product_Package you wish to order. | |
* | |
* In this case the CCI package is 46 | |
* | |
* @var int | |
*/ | |
$virtualGuestOrder->packageId = 46; | |
/** | |
* Where you'd like your new CCI provisioned. | |
* | |
* This can either be the id of the datacenter you wish your new server to be provisioned | |
* in or the string 'FIRST_AVAILABLE' if you have no preference where your server is provisioned. | |
* | |
* Location id 3 = Dallas | |
* Location id 18171 = Seattle | |
* Location id 37473 = Washington, D.C. | |
* | |
* @var mixed | |
*/ | |
$virtualGuestOrder->location = 37473; | |
/** | |
* The number of CCIs you wish to order in this configuration. | |
* | |
* @var int | |
*/ | |
$virtualGuestOrder->quantity = 1; | |
/** | |
* Build a skeleton SoftLayer_Virtual_Guest (CCI) object to model the hostname and domain | |
* we want for our CCI. If you set $quantity greater then 1 then you need to define one | |
* hostname and domain pair per CCI you wish to order. | |
*/ | |
$fqdns = array( | |
array('hostname' => 'api-order-ipv4-justification', 'domain' => 'example.com'), | |
); | |
$virtualGuestOrder->virtualGuests = array(); | |
foreach ($fqdns as $fqdn) { | |
$virtualGuest = new stdClass(); | |
$virtualGuest->hostname = $fqdn['hostname']; | |
$virtualGuest->domain = $fqdn['domain']; | |
$virtualGuestOrder->virtualGuests[] = $virtualGuest; | |
} | |
/** | |
* The id's of the items you wish to order for your CCI. | |
* | |
* Every item in SoftLayer's product catalog is assigned an id. Use these ids to tell the | |
* SoftLayer API which options you want in your new server. Use the getActivePackages() | |
* method in the SoftLayer_Account API service to get a list of available item and price | |
* options per available package. | |
* | |
* @var array | |
*/ | |
$itemPriceIds = array( | |
1641, // 1641 -- 2 x 2.0 GHz Cores [Computing Instance] | |
1647, // 1647 -- 8 GB [Ram] | |
905, // 905 -- Reboot / Remote Console [Remote Management] | |
273, // 273 -- 100 Mbps Public & Private Networks [Uplink Port Speeds] | |
125, // 125 -- Unlimited Bandwidth (100 Mbps Uplink) [Public Bandwidth] | |
21, // 21 -- 1 IP Address [Primary IP Addresses] | |
23, // 23 -- 8 Additional IPs | |
1639, // 1639 -- 100 GB (SAN) [First Disk] | |
1685, // 1685 -- CentOS 5 - Minimal Install (64 bit) [Operating System] | |
55, // 55 -- Host Ping [Monitoring] | |
57, // 57 -- Email and Ticket [Notification] | |
58, // 58 -- Automated Notification [Response] | |
420, // 420 -- Unlimited SSL VPN Users & 1 PPTP VPN User per account [VPN Management - Private Network] | |
418, // 418 -- Nessus Vulnerability Assessment & Reporting [Vulnerability Assessments & Management] | |
); | |
/** | |
* Convert our item price list into an array of skeleton SoftLayer_Product_Item_Price | |
* objects. These objects contain much more than ids, but SoftLayer's ordering system | |
* only needs the price's id to know what you want to order. | |
*/ | |
$virtualGuestOrder->prices = array(); | |
foreach ($itemPriceIds as $itemPriceId) { | |
$price = new stdClass(); | |
$price->id = $itemPriceId; | |
$virtualGuestOrder->prices[] = $price; | |
} | |
/** | |
* Add the required IPv4 justification Q/A's to the order container | |
*/ | |
$virtualGuestOrder->itemCategoryQuestionAnswers = array(); | |
// the item category question answers | |
$itemCategoryQuestionAnswer = new stdClass(); | |
$itemCategoryQuestionAnswer->categoryId = 14; | |
$itemCategoryQuestionAnswer->categoryCode = 'sec_ip_addresses'; | |
$itemCategoryQuestionAnswer->questionId = 14; | |
$itemCategoryQuestionAnswer->answer = '2'; | |
$virtualGuestOrder->itemCategoryQuestionAnswers[] = $itemCategoryQuestionAnswer; | |
$itemCategoryQuestionAnswer = new stdClass(); | |
$itemCategoryQuestionAnswer->categoryId = 14; | |
$itemCategoryQuestionAnswer->categoryCode = 'sec_ip_addresses'; | |
$itemCategoryQuestionAnswer->questionId = 15; | |
$itemCategoryQuestionAnswer->answer = '4'; | |
$virtualGuestOrder->itemCategoryQuestionAnswers[] = $itemCategoryQuestionAnswer; | |
$itemCategoryQuestionAnswer = new stdClass(); | |
$itemCategoryQuestionAnswer->categoryId = 14; | |
$itemCategoryQuestionAnswer->categoryCode = 'sec_ip_addresses'; | |
$itemCategoryQuestionAnswer->questionId = 16; | |
$itemCategoryQuestionAnswer->answer = 'Brief description/explanation of the need for additional IPs.'; | |
$virtualGuestOrder->itemCategoryQuestionAnswers[] = $itemCategoryQuestionAnswer; | |
$itemCategoryQuestionAnswer = new stdClass(); | |
$itemCategoryQuestionAnswer->categoryId = 14; | |
$itemCategoryQuestionAnswer->categoryCode = 'sec_ip_addresses'; | |
$itemCategoryQuestionAnswer->questionId = 9; | |
$itemCategoryQuestionAnswer->answer = "Jonathan Doe"; | |
$virtualGuestOrder->itemCategoryQuestionAnswers[] = $itemCategoryQuestionAnswer; | |
$itemCategoryQuestionAnswer = new stdClass(); | |
$itemCategoryQuestionAnswer->categoryId = 14; | |
$itemCategoryQuestionAnswer->categoryCode = 'sec_ip_addresses'; | |
$itemCategoryQuestionAnswer->questionId = 10; | |
$itemCategoryQuestionAnswer->answer = "Network Guru"; | |
$virtualGuestOrder->itemCategoryQuestionAnswers[] = $itemCategoryQuestionAnswer; | |
$itemCategoryQuestionAnswer = new stdClass(); | |
$itemCategoryQuestionAnswer->categoryId = 14; | |
$itemCategoryQuestionAnswer->categoryCode = 'sec_ip_addresses'; | |
$itemCategoryQuestionAnswer->questionId = 11; | |
$itemCategoryQuestionAnswer->answer = "jdoe@emaildomain.com"; | |
$virtualGuestOrder->itemCategoryQuestionAnswers[] = $itemCategoryQuestionAnswer; | |
$itemCategoryQuestionAnswer = new stdClass(); | |
$itemCategoryQuestionAnswer->categoryId = 14; | |
$itemCategoryQuestionAnswer->categoryCode = 'sec_ip_addresses'; | |
$itemCategoryQuestionAnswer->questionId = 12; | |
$itemCategoryQuestionAnswer->answer = "214.555.5555"; | |
$virtualGuestOrder->itemCategoryQuestionAnswers[] = $itemCategoryQuestionAnswer; | |
$itemCategoryQuestionAnswer = new stdClass(); | |
$itemCategoryQuestionAnswer->categoryId = 14; | |
$itemCategoryQuestionAnswer->categoryCode = 'sec_ip_addresses'; | |
$itemCategoryQuestionAnswer->questionId = 13; | |
$itemCategoryQuestionAnswer->answer = '1'; | |
$virtualGuestOrder->itemCategoryQuestionAnswers[] = $itemCategoryQuestionAnswer; | |
/** | |
* Now we are ready to place the order | |
*/ | |
try { | |
// Get the SoftLayer_Product_Order SOAP client | |
$soapClient = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $apiUsername, $apiKey); | |
// Next re-declare the order object as a SOAP encoded variable | |
$virtualGuestOrder = new SoapVar( | |
$virtualGuestOrder, | |
SOAP_ENC_OBJECT, | |
'SoftLayer_Container_Product_Order_Virtual_Guest', | |
'http://api.service.softlayer.com/soap/v3/' | |
); | |
/** | |
* Now place the order; if successful, a receipt object (SoftLayer_Container_Product_Order_Receipt) | |
* will be returned. The receipt object's 'placedOrder' property will contain the information of the | |
* successfully created order. | |
*/ | |
$receipt = $soapClient->placeOrder($virtualGuestOrder); | |
print_pre($receipt, 'RECEIPT'); | |
} catch (Exception $e) { | |
// error handling code here | |
print_pre($e, 'EXCEPTION'); | |
} | |
/** | |
* Convenience function to debug out to a web browser | |
*/ | |
function print_pre($data, $title = null, $return = false) | |
{ | |
$data = print_r($data,true); | |
$output = ''; | |
if ($title) $output .= "<b>{$title}</b><br>"; | |
if ($return) { | |
$output .= '<div style="font-family: courier; border: 1px solid black; background-color: #eee; white-space: pre;">'.htmlspecialchars($data).'</div>'; | |
return $output; | |
} else { | |
$output .= '<textarea rows="20" cols="85" style="width: 100%;" readonly>'.htmlspecialchars($data).'</textarea><br>'; | |
echo $output; | |
} | |
} |