对于以下网络设备: Netscaler、负载平衡、IPSecVPN子网、
哪种是取消这些设备的正确Softlayer API方法?
用billingId取消它们,"SoftLayer_Billing_Item::cancelService“是正确的吗?
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是否仅用于取消使用裸机服务器Id的裸机服务器?或者,我是否可以通过提供网络设备Id来使用SoftLayer_Ticket::createCancelServerTicket取消网络设备?
谢谢。
发布于 2015-11-20 02:51:43
是的,SoftLayer_Billing_Item::cancelService应该用来取消诸如:负载均衡器、iPsec虚拟专用网、Netscaler等项目,即使“SoftLayer_Billing_Item::cancelItem”是其他选项也可以使用。
然而,http://sldn.softlayer.com/reference/services/SoftLayer_Ticket/createCancelServerTicket不能用于服务(例如网络产品),SLDN文件说它只能用于服务器(金属棒)
以下是一些取消服务的示例:
使用“IpSec”取消“cancelService VPN”:
<?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”取消“cancelItem VPN”:
<?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
https://stackoverflow.com/questions/33807756
复制相似问题