SoftLayer API: какой метод API использовать для отмены сетевых продуктов, таких как Netscaler, балансировщик нагрузки, IpsecVPN, Subnet.

Для следующих сетевых устройств: Netscaler, балансировка нагрузки, подсеть IPSecVPN,

какой правильный метод API Softlayer для отмены этих устройств?

Подходит ли «SoftLayer_Billing_Item::cancelService» для отмены их с помощью billingId?

http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService

В SoftLayer_ticket также есть метод

SoftLayer_Ticket::createCancelServerTicket http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createCancelServerTicket

Является ли SoftLayer_Ticket::createCancelServerTicket только для отмены сервера Bare Metal с использованием идентификатора сервера Bare Metal? Или я могу использовать SoftLayer_Ticket::createCancelServerTicket для отмены сетевых устройств, указав идентификатор сетевого устройства?

Спасибо.


person mnnmountain    schedule 19.11.2015    source источник


Ответы (1)


Да, SoftLayer_Billing_Item::cancelService следует использовать для отмены таких элементов, как: балансировщик нагрузки, iPsec VPN, Netscaler и т. д., даже «SoftLayer_Billing_Item::cancelItem» — это другой вариант использования.

Однако http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createCancelServerTicket нельзя использовать для услуг (например, сетевых продуктов), в документе SLDN сказано, что его следует использовать только для серверов (металлические изделия)

Вот несколько примеров отмены услуг:

Отменить «IpSec VPN» с помощью «cancelService»:

<?php
require_once(dirname(__FILE__) . '/SoftLayer/SoapClient.class.php');
/**
 * Set your SoftLayer API username and key.
 */
$apiUsername = 'set me';
$apiKey = 'set me';

/**
 * Set the service to use
 */
$ipSecService ='SoftLayer_Network_Tunnel_Module_Context';
$billingItemService = 'SoftLayer_Billing_Item';

$ipSecId = 77;


/**
 * Create a client to the API service.
 */
$ipSecClient = SoftLayer_SoapClient::getClient($ipSecService, $ipSecId, $apiUsername, $apiKey);

$mask = new SoftLayer_ObjectMask();
$mask = 'mask[id,billingItem.id]';
$ipSecClient->setObjectMask($mask);

try {
       $ipSecItem = $ipSecClient->getObject();
    $billingItemId = $ipSecItem->billingItem->id; 
    print_r($billingItemId);


    try {
        $billingItemClient = SoftLayer_SoapClient::getClient($billingItemService, $billingItemId, $apiUsername, $apiKey, $endpointUrl);
        $result = $billingItemClient->cancelService();
        print_r($result);

    } catch(Exception $e) {
        echo 'Unable to cancel the item: ' . $e->getMessage();
    }


} catch (Exception $e) {
    echo 'Failed ... Unable to get item: ' . $e->getMessage();
}

Отменить «IpSec VPN» с помощью «cancelItem»:

<?php
require_once(dirname(__FILE__) . '/SoftLayer/SoapClient.class.php');
/**
 * Set your SoftLayer API username and key.
 */
$apiUsername = 'set me';
$apiKey = 'set me';
/**
 * Set the service to use
 */
$ipSecService ='SoftLayer_Network_Tunnel_Module_Context';
$billingItemService = 'SoftLayer_Billing_Item';

$ipSecId = 77;


/**
 * Create a client to the API service.
 */
$ipSecClient = SoftLayer_SoapClient::getClient($ipSecService, $ipSecId, $apiUsername, $apiKey, $endpointUrl);
//$ipSecClient = SoftLayer_SoapClient::getClient($ipSecService, $ipSecId, $apiUsername, $apiKey);

$mask = new SoftLayer_ObjectMask();
$mask = 'mask[id,billingItem.id]';
$ipSecClient->setObjectMask($mask);

try {
    $ipSecItem = $ipSecClient->getObject();
    $billingItemId = $ipSecItem->billingItem->id; 
    print_r($billingItemId);


    try {
        $billingItemClient = SoftLayer_SoapClient::getClient($billingItemService, $billingItemId, $apiUsername, $apiKey, $endpointUrl);
        $result = $billingItemClient->cancelItem(   False,
            False,
            'No longer needed',
            'Api test');
        print_r($result);

    } catch(Exception $e) {
        echo 'Unable to cancel the item: ' . $e->getMessage();
    }


} catch (Exception $e) {
    echo 'Failed ... Unable to get item: ' . $e->getMessage();
}

Ссылки: http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelItem

person mcruz    schedule 19.11.2015