我基本上是按照此处发布的内容在裸机服务器上订购 EVault: 在 SoftLayer 中订购 EVault 备份的示例代码
它适用于 Virtual Guest,但在裸机服务器上调用 verifyOrder 时失败,并显示如下错误消息:
There was an error querying the SoftLayer API: EVault orders must be tied to exactly 1 server.
这是我拥有的输入类型,我只指定了 1 个硬件,我不明白为什么它认为我没有确切的 1 个服务器。
stdClass Object
(
[location] => 168642
[packageId] => 0
[prices] => Array
(
[0] => stdClass Object
(
[id] => 22747
)
)
[quantity] => 1
[useHourlyPricing] =>
[hardware] => Array
(
[0] => stdClass Object
(
[id] => 168137
)
)
)
这是我用来测试的 PHP 代码。(我已经删除了一些初始的 require 语句)。它引用每小时的裸机服务器,示例中显示的所有数据都是真实的,除了 $apiUsername 和 $apiKey:
<?php
$apiUsername = 'xxxxx';
$apiKey = 'xxxxx';
$hardware = new stdClass();
$hardware->id = 168137;
$orderHardware = array
(
$hardware
);
# The location for the Evault
$location = "168642";
$packageId = 0;
$quantity = 1;
$prices = array
(
22747,
);
// Convert our item list into an array of skeleton
$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->quantity = $quantity;
$orderTemplate->useHourlyPricing = false;
$orderTemplate->hardware = $orderHardware;
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_Network_Storage_Backup_Evault_Vault',
'http://api.service.softlayer.com/soap/v3/'
);
$softLayer_product_order = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $apiUsername, $apiKey);
$receipt = $softLayer_product_order->verifyOrder($orderTemplate);
print_r($receipt);
} catch (Exception $e) {
echo 'Unable to place server order: ' . $e->getMessage();
}
?>
这是我收集的裸机服务器(168137)数据
GET https://api.softlayer.com/rest/v3/SoftLayer_Hardware/168137/getObject.json?objectMask=activeTransaction.transactionGroup
{
"accountId" : 79###,
"bareMetalInstanceFlag" : 0,
"domain" : "x.net",
"fullyQualifiedDomainName" : "x.x.net",
"globalIdentifier" : "2###-##a-4#7-a##6-ed##5",
"hardwareFunction" : {
"code" : "WEBSVR",
"description" : "Web Server",
"id" : 3
},
"hardwareStatus" : {
"id" : 5,
"status" : "ACTIVE"
},
"hardwareStatusId" : 5,
"hostname" : "xxxxx",
"id" : 168137,
"managedResourceFlag" : false,
"manufacturerSerialNumber" : "S0#####2009275E",
"networkManagementIpAddress" : "10.##.###.###",
"notes" : "",
"primaryBackendIpAddress" : "10.##.###.###",
"primaryIpAddress" : "198.##.###.###",
"privateIpAddress" : "10.##.###.###",
"provisionDate" : "2016-01-15T09:20:55-06:00",
"serialNumber" : "ASL####",
"serviceProviderId" : 1,
"serviceProviderResourceId" : 168137
}