-1

我基本上是按照此处发布的内容在裸机服务器上订购 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
}
4

1 回答 1

0

你是对的,额外的属性“networkType”和“numOfTabs”是这个错误的原因。

使用这些属性显示的错误:

{
"error": "The property 'networkType' is not valid for 'SoftLayer_Container_Product_Order_Network_Storage_Backup_Evault_Vault'."
"code": "SoftLayer_Exception_Public"
}

{
"error": "The property 'numOfTabs' is not valid for 'SoftLayer_Container_Product_Order_Network_Storage_Backup_Evault_Vault'."
"code": "SoftLayer_Exception_Public"
}

如果您删除它们,订单将成功运行。

以下是删除这些属性的 REST 示例:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder.json

Method: POST

{
  "parameters": [
    {
   "complexType" : "SoftLayer_Container_Product_Order_Network_Storage_Backup_Evault_Vault",
   "hardware" : [
      {
         "id" : "149654",
         "notes" : "Bare Metal"
      }
   ],
   "location" : "449500",
   "packageId" : 0,
   "prices" : [
      {
         "id" : "83867"
      }
   ],
   "quantity" : 1,
   "useHourlyPricing" : 0
}
  ]
}

参考:

http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Network_Storage_Backup_Evault_Vault

编辑

但是如果订单仍然有错误,我们需要检查其他类型的可能问题。例如,其中之一可能是我们使用的金属条有问题。我们可以查看它是否可能有活动的交易正在运行,从而停止我们的订单。要获取此服务器是否有活动事务,请执行:

https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Hardware/149654/getObject?objectMask=activeTransaction.transactionGroup

Method: GET 
where: “149654” is the Hardware_id.

如果 Bar 金属有活跃的交易,结果将显示如下:

"serviceProviderResourceId": 149654
"globalIdentifier": "aaaaaa-aaaa-aaaa-8851-c3c68f764a4e"
"hardwareFunction": {
"code": "WEBSVR"
"description": "Web Server"
"id": 3
}-
"hardwareStatus": {
"id": 8
"status": "RECLAIM"
}-
"managedResourceFlag": false
"networkManagementIpAddress": "11.11.11.11"
"primaryBackendIpAddress": "10.44.44.44"
"primaryIpAddress": "50.50.50.50"
"activeTransaction": {
"createDate": "2016-01-15T08:54:04-06:00"
"elapsedSeconds": 10328
"guestId": null
"hardwareId": 149654
"id": 1234567
"modifyDate": "2016-01-15T12:45:31-06:00"
"statusChangeDate": "2016-01-15T10:07:22-06:00"
"transactionGroup": {
"averageTimeToComplete": "641.64"
"name": "Reclaim Server"
}-
"transactionStatus": {
"averageDuration": "162.31"
"name": "XX_ERASEDRIVES"
}-
}
于 2016-01-15T16:51:37.653 回答