2016-01-06 66 views
0

我有一个虚拟服务器和一个与虚拟服务器相关的EVault。 看起来很容易使用EVault,我需要订购EVault插件之一,例如Oracle的EVault插件。如何以编程方式订购这些EVault插件之一,以及如何以编程方式取消它?如何使用SoftLayer API以编程方式订购EVault插件?

它有点像升级到EVault,我使用SoftLayer_Network_Storage_Backup_Evault API调用诸如upgradeVolumeCapacity()来升级磁盘大小之一?

或者更像是放置一个全新的插件订单,并且订单 需要了解EVault实例以及可能的主机?

一些示例代码(PHP首选),以订购这些EVault插件之一和取消将非常感激。谢谢。

PS。如果Bare Metal服务器的进程/ API /输入不同,请包含该信息。

回答

1

您需要使用方法placeOrder在这里的代码命令插件:

<?php 

require_once ('/SoftLayer/SoapClient.class.php'); 

$username = 'set me'; 
$key = 'set me'; 

// Create a SoftLayer API client object 
$softLayer_product_order = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $username, $key); 

# Build a skeleton SoftLayer_Hardware object. 
# The object contains the hardware ID of the 
# Bare Metal server wich will contain the Evault 
# If you want use a Virtual Server instead a 
# Bare Metal server build a skeleton SoftLayer_Virtual_Guest object 
$virtualGuests = new stdClass(); 
$virtualGuests->id = 9066729; 
$orderVirtualGuest = array 
(
    $virtualGuests, 
); 

# The current location where the Evault is. 
$location = "449494"; 
$packageId = 0; 

// Build a skeleton SoftLayer_Product_Item_Price object. 
// The object contains the price ID of the Evaul plugin 
// you wish order. 
// To get the list of prices call the Softlayer_Product_Package::getItems method 
$prices = array 
(
    1146, 
); 

// Convert our item 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. 
$orderPrices = array(); 

foreach ($prices as $priceId){ 
    $price = new stdClass(); 
    $price->id = $priceId; 
    $orderPrices[] = $price; 
} 

// Build a SoftLayer_Container_Product_Order_Network_Storage_Backup_Evault_Vault object containing 
// the order you wish to place. 
$orderTemplate = new stdClass(); 
$orderTemplate->location   = $location; 
$orderTemplate->packageId  = $packageId; 
$orderTemplate->prices   = $orderPrices; 
$orderTemplate->virtualGuests = $orderVirtualGuest; 

print_r($orderTemplate); 

// Place the order. 
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', 
     '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. 
    $receipt = $softLayer_product_order->verifyOrder($orderTemplate); 
    print_r($receipt); 
} catch (Exception $e) { 
    echo 'Unable to place server order: ' . $e->getMessage(); 
} 

取消插件是比较复杂的,它只能通过票证取消。如果您尝试取消billingItem它将无法正常工作。您可以创建一个标准票并要求取消该插件。在这里创建的门票为例:

<?php 
/** 
* Create Standard Ticket 
* 
* This script creates a standard support ticket and It is assigned to master User. 
* The ticket is created with the subject Id:1001 (Accounting Request) 
* 
* Important manual pages: 
* @see http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createStandardTicket 
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Ticket 
* @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Utility_File_Attachment 
* 
* @license <http://sldn.softlayer.com/wiki/index.php/license> 
* @author SoftLayer Technologies, Inc. <[email protected]> 
*/ 

require_once "C:/Php/SoftLayer/SoftLayer/SoapClient.class.php"; 

/** 
* Your SoftLayer API username 
* @var string 
*/ 
$username = "set me"; 

/** 
* Your SoftLayer API key 
* Generate one at: https://control.softlayer.com/account/users 
* @var string 
*/ 
$apiKey = "set me"; 

/** 
* Declare parameters for the ticket 
* @var string $contents 
* @var int $attachmentId 
* @var string $rootPassword 
* @var string $controlPanelPassword 
* @var string $accessPort 
* @var string $attachmentType 
* @var int $subjectId 
* @var string $title 
*/ 
$contents = "This is for test"; 
$attachmentId = null; 
$rootPassword = ""; 
$controlPanelPassword = ""; 
$accessPort = ""; 
$attachmentType = ""; 
$subjectId = 1001; 
$title = "This is for test"; 

// Create a SoftLayer API client object for "SoftLayer_Account" and "SoftLayer_Ticket" services 
$accountService = SoftLayer_SoapClient::getClient("SoftLayer_Account", null, $username, $apiKey); 
$ticketService = SoftLayer_SoapClient::getClient("SoftLayer_Ticket", null, $username, $apiKey); 

// Get Id for the Master User 
$accountService -> setObjectMask("mask[masterUser]"); 
$account = $accountService -> getObject(); 

// Build a skeleton SoftLayer_Ticket object containing the data of the ticket to submit. 
$templateObject = new stdClass(); 
$templateObject -> assignedUserId = $account -> masterUser -> id; 
$templateObject -> subjectId = $subjectId; 
$templateObject -> title = $title; 

try { 
    $standardTicket = $ticketService -> createStandardTicket($templateObject, $contents, $attachmentId, $rootPassword, $controlPanelPassword, $accessPort, $attachmentType); 
    print_r($standardTicket); 
} catch(Exception $e) { 
    echo "Unable to create standard ticket: " . $e -> getMessage(); 
} 

你可以把你的票以下内容: 请启动EVault的插件取消:

结算ID:000000 取消日期:即日起 取消注

要获得插件的开票项目,您可以使用此代码:

<?php 

require_once ('/SoftLayer/SoapClient.class.php'); 

$username = 'set me'; 
$key = 'set me'; 

# The orderid of your evault plugin 
$orderId = 6566891; 

// Create a SoftLayer API client object 
$accountClient = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, $username, $key); 
$cancelClient = SoftLayer_SoapClient::getClient('SoftLayer_Billing_Item', null, $username, $key); 


// setting a filter to get the billling items which category code is evault_plugin 
$filter = new stdClass(); 
$filter->allBillingItems = new stdClass(); 
$filter->allBillingItems->categoryCode = new stdClass(); 
$filter->allBillingItems->categoryCode->operation = 'evault_plugin'; 
$accountClient->setObjectFilter($filter); 

# Declaring an object mask to get the order id 
$objectMask = "mask[orderItem[order]]"; 
$accountClient->setObjectMask($objectMask); 

# Getting the billing items 
$billingItems = $accountClient->getAllBillingItems(); 

# looking for the billing item to cancel 
$billingItemToCancel = null; 
foreach ($billingItems as &$billingItem) { 
    if ($billingItem->orderItem->order->id == $orderId){ 
     $billingItemToCancel = $billingItem; 
     break; 
    } 
} 

print_r($billingItemToCancel); 
+0

谢谢你的回答。我没有找到找到EVault的位置ID的方法。我有一个单独的发布。也许你知道如何?这是我的新帖子的链接[获取EVault的位置](http://stackoverflow.com/questions/34641103/how-to-find-location-of-an-evault-using-softlayer-api) – KHP

+0

尝试使用此掩码=掩码[orderItem [location,order]]从billingItem中获取它您可以使用我发送给您的最后一个代码并更改掩码 –

相关问题