如何使用SoftLayer API升级Endurance存储上的快照空间? [英] How do you upgrade a Snapshot space on Endurance storage using SoftLayer API?

查看:63
本文介绍了如何使用SoftLayer API升级Endurance存储上的快照空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Using SoftLayer API, I've ordered an Endurance Block Storage and it's there. Now I am trying to write a PHP code that will use SoftLayer API to modify Snapshot space, but I keep getting this error:

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

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

And I am not sure what the issue is. Below is bit of code that I am using to do this:

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

据我所知,我传递的$ order在下面,我传递的价格ID是正确的.那我想念什么呢?还是我需要以其他方式做到这一点?

And the $order that I pass is below and the price ID I pass is correct as far as I know. So what am I missing? Or do I need to do this in different way?

{
   "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
}

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

Any help will be appreciated. Thank you.

推荐答案

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

The Json should be something like this, where the volumeId is the block storage id where the upgrade will be applied.

{
  "complexType": "SoftLayer_Container_Product_Order_Network_Storage_Enterprise_SnapshotSpace_Upgrade",
  "packageId": 240,
  "prices": [{

    "id": 144295
  }],

  "volumeId": 5805095
}

在PHP中,它是这样的:

In PHP it would be like this:

<?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

Do not forget replace the prices and the volumeID

致谢

这篇关于如何使用SoftLayer API升级Endurance存储上的快照空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆