Skip to content

Instantly share code, notes, and snippets.

@softlayer
Created September 15, 2010 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save softlayer/581472 to your computer and use it in GitHub Desktop.
Save softlayer/581472 to your computer and use it in GitHub Desktop.
<?php
/**
* Order a control panel license for a virtual private server (VPS).
*
* Build a SoftLayer_Container_Product_Order_Software_Component_Virtual object
* for a new control panel license order and pass it to the
* SoftLayer_Product_Order API service to order it. See below for more details.
*
* This assumes the SoftLayer API PHP client
* <http://github.com/softlayer/softlayer-api-php-client> is installed in the
* directory '/SoftLayer' in this script's path and that you wish to use the
* SOAP client instead of our XML-RPC client.
*
* Important manual pages:
* http://sldn.softlayer.com/reference/datattypes/SoftLayer_Container_Product_Order_Software_Component_Virtual
* http://sldn.softlayer.com/reference/datatypes/SoftLayer_Network_Subnet_IpAddress
* http://sldn.softlayer.com/reference/datatypes/SoftLayer_Product_Item_Price
* http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
* http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/placeOrder
*
* @license <http://sldn.softlayer.com/article/License>
* @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
* @see <https://manage.softlayer.com/Sales/orderAdditionalServices/virtualLicense>
*/
require_once(dirname(__FILE__) . '/SoftLayer/SoapClient.class.php');
/**
* Your SoftLayer API username.
*
* @var string
*/
$username = 'set me!';
/**
* Your SoftLayer API key.
*
* Generate one at https://manage.softlayer.com/Administrative/apiKeychain
*
* @var string
*/
$key = 'set me too!';
/**
* The id of the SoftLayer_Product_Item_Price entry corresponding to the type
* of control panel license you wish to order.
*
* Item prices represent individual items in the SoftLayer product catalog. The
* items below represent the different control panel licene options available
* for
*
* 1453 - Parallels Plesk Panel 9 (Linux Virtuozzo) 100 Domain w/ Power Pack
* 1457 - Parallels Plesk Panel 9 (Windows Virtuozzo) 100 Domain w/ Power Pack
* 958 - Plesk 8 (Latest) - Linux Virtuozzo 100 Domain w/ Power Pack
* 963 - Plesk 8 (Latest) - Windows Virtuozzo 100 Domain w/ Power Pack
* 1454 - Parallels Plesk Panel 9 (Linux Virtuozzo) Unlimited Domain w/ Power
* Pack
* 1458 - Parallels Plesk Panel 9 (Windows Virtuozzo) Unlimited Domain w/ Power
* Pack
* 1434 - Plesk 8 (Latest) - Linux Virtuozzo Unlimited Domain w/ Power Pack
* 1326 - Plesk 8 (Latest) for VPS - Linux - 100 Domain w/ Power Pack
* 1396 - Plesk 8 (Latest) for VPS - Windows - 100 Domain w/ Power Pack
* 1451 - Parallels Plesk Panel 9 for VPS (Linux) 100 Domain w/ Power Pack
* 1460 - Parallels Plesk Panel 9 for VPS (Windows) 100 Domain w/ Power Pack
* 1455 - Parallels Plesk Panel 9 for VPS (Linux) Unlimited Domain w/ Power Pack
* 1461 - Parallels Plesk Panel 9 for VPS (Windows) Unlimited Domain w/ Power
* Pack
* 203 - cPanel for VPS
* 204 - cPanel for Virtuozzo and OpenVZ
* 206 - cPanel for VPS with Fantastico and RVskin
* 205 - cPanel for Virtuozzo and OpenVZ with Fantastico and RVskin
*
* @var int
*/
$priceId = null;
/**
* The ids of the IP address that you want to create control panel licenses for.
*
* @var array
*/
$endPointIpAddressIds = array();
/**
* The number of licenses you wish to order
*
* @var int;
*/
$quantity = 1;
// Build a SoftLayer_Container_Product_Order_Software_Component_Virtual object
// containing the order you wish to place. Software licenses belong to the
// "Control Panels for VPS" package, whaich has the id 10. Since this order is
// for one item with no sub-options you only have to set a single price id in
// this order.
$orderTemplate = new stdClass();
$orderTemplate->packageId = 10;
$orderTemplate->prices = array();
$orderTemplate->prices[0] = new stdClass();
$orderTemplate->prices[0]->id = $priceId;
$orderTemplate->endPointIpAddressIds = $endPointIpAddressIds;
$orderTemplate->quantity = $quantity;
// Create a SoftLayer API client object to the SoftLayer_Product_Order service.
$client = SoftLayer_SoapClient::getClient
(
'SoftLayer_Product_Order',
null,
$username,
$key
);
// Place the order for the new license.
try {
// Re-declare the order template as a SOAP variable, so the SoftLayer
// ordering system knows what type of order you're placing.
$orderTemplate = new SoapVar
(
$orderTemplate,
SOAP_ENC_OBJECT,
'SoftLayer_Container_Product_Order_Software_Component_Virtual',
'http://api.service.softlayer.com/soap/v3/'
);
// verifyOrder() will check your order for errors. Replace this with a call
// to placeOrder() when you're ready to order. Both calls return a receipt
// object that you can use for your records.
//
// Once your order is placed it'll go through SoftLayer's approval and
// provisioning process. When it's done you'll have a new
// license ready to import into Plesk or a new cPanel license for your IP
// addresses.
$receipt = $client->verifyOrder($orderTemplate);
print_r($receipt);
} catch (Exception $e) {
echo 'Unable to place license order: ' . $e->getMessage();
}
@robbiet480
Copy link

How do you get the IP Address id's referenced by $endPointIpAddressIds?

@underscorephil
Copy link

@robbiet480: gah, just saw this...

Probably wwwaaayyy to late to the party but:

In this specific case i was just throwing them in manually to the array. You could also get them on the hardware/guest service by calling getObject with a mask for networkVlans->subnets->ipaddresses->ipaddress->id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment