2016-01-06 2 views
0

У меня есть виртуальный сервер и EVault, связанный с Virtual Server. Похоже, что использовать EVault легко, мне нужно заказать один из плагинов EVault, таких как плагин EVault для Oracle. Как программно заказать один из этих плагинов EVault и как его программно отменить?Как заказать плагин EVault программным путем с помощью API SoftLayer?

Это как обновление до EVault, где я делаю один из вызовов API SoftLayer_Network_Storage_Backup_Evault, таких как upgradeVolumeCapacity(), чтобы обновить размер диска?

Или это больше похоже на размещение нового заказа для плагина, а заказ должен знать об экземпляре EVault и, возможно, о хосте?

Некоторые примеры кода (предпочитаемый php) для заказа одного из этих плагинов EVault и отмены будут действительно оценены. Спасибо.

PS. Если процесс/API/вход отличается для сервера Bare Metal, пожалуйста, включите эту информацию.

ответ

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 плагин:

Billing 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. Для этого у меня есть отдельная публикация. Может быть, вы знаете, как это сделать? Это ссылка на мое новое сообщение о [получении местоположения EVault] (http://stackoverflow.com/questions/34641103/how-to-find-location-of-an-evault-using-softlayer-api) – KHP

+0

Попробуйте чтобы получить его из billingItem с помощью этой маски = mask [orderItem [location, order]] Вы можете использовать последний код, который я вам отправил, и изменить маску –

Смежные вопросы