Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
601 views
in Technique[技术] by (71.8m points)

ibm cloud infrastructure - How do you upgrade a Snapshot space on Endurance storage using SoftLayer API?

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);

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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
}

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();
}

Do not forget replace the prices and the volumeID

Regards


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...