2016-01-06 86 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中獲取它您可以使用我發送給您的最後一個代碼並更改掩碼 –

相關問題