【问题标题】:How do you upgrade a Snapshot space on Endurance storage using SoftLayer API?如何使用 SoftLayer API 升级 Endurance 存储上的快照空间?
【发布时间】:2015-12-04 21:24:21
【问题描述】:

使用 SoftLayer API,我订购了 Endurance Block Storage,它就在那里。 现在我正在尝试编写一个使用 SoftLayer API 来修改快照空间的 PHP 代码,但我不断收到此错误:

There was an error querying the SoftLayer API: Price does not have an id.

我不确定问题是什么。 下面是我用来执行此操作的一些代码:

$clientServer = SoftLayer_XmlrpcClient::getClient('SoftLayer_Product_Order', null, userID, apiKey);
$clientServer->verifyOrder($order);

据我所知,我传递的 $order 在下方,并且传递的价格 ID 是正确的。那么我错过了什么?还是我需要以其他方式执行此操作?

{
   "categoryCode" : "storage_snapshot_space",
   "complexType" : "Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
   "packageId" : 240,
   "prices" : [
      {
         "id" : 144295
      }
   ],
   "properties" : [
      {
         "name" : "orderOrigin",
         "value" : "control"
      }
   ],
   "virtualGuests" : null
}

任何帮助将不胜感激。谢谢。

【问题讨论】:

    标签: ibm-cloud-infrastructure


    【解决方案1】:

    Json 应该是这样的,其中 volumeId 是要应用升级的块存储 ID。

    {
      "complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
      "packageId": 240,
      "prices": [{
    
        "id": 144295
      }],
    
      "volumeId": 5805095
    }
    

    在 PHP 中是这样的:

    <?php
    
    require_once ('C:/scripst/getdetails/SoftLayer/SoapClient.class.php');
    
    $username = 'set me';
    $key = 'set me';
    
    
    $softLayer_product_order = SoftLayer_SoapClient::getClient('SoftLayer_Product_Order', null, $username, $key);
    
    
    $prices = array
    (
        46150
    );
    
    
    $orderPrices = array();
    
    foreach ($prices as $priceId){
        $price = new stdClass();
        $price->id = $priceId;
        $orderPrices[] = $price;
    }
    
    $packageId = 240;
    
    $volumeId = 5805095;
    
    $orderContainer = new stdClass();
    $orderContainer->packageId          = $packageId;
    $orderContainer->prices             = $orderPrices;
    $orderContainer->volumeId           = $volumeId;
    
    try {
    
        $orderTemplate = new SoapVar
        (
            $orderContainer,
            SOAP_ENC_OBJECT,
            'SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade',
            'http://api.service.softlayer.com/soap/v3/'
        );
    
        $receipt = $softLayer_product_order->verifyOrder($orderTemplate);
        print_r($receipt);
    } catch (Exception $e) {
        echo 'Unable to place the order: ' . $e->getMessage();
    }
    

    不要忘记替换价格和volumeID

    问候

    【讨论】:

    • 谢谢!这行得通!看起来我错过的主要事情是我错过了 complexType 中的“SoftLayer_”前缀。我不敢相信我错过了...再次感谢您!
    猜你喜欢
    • 1970-01-01
    • 2021-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-14
    • 1970-01-01
    • 2012-04-11
    相关资源
    最近更新 更多