duanping2695 2016-06-17 15:41
浏览 68
已采纳

SoftLayer API:需要php示例代码来验证power 8服务器的订单(包ID 242)[关闭]

Can somebody please provide sample php code to verify order for power 8 servers (package Id 242).

The power8 servers seems using presetIds. Will the parameters for SoftLayer_Product_Order.verifyOder(...) be similar to the ones for hourly baremetal server ?

  • 写回答

1条回答 默认 最新

  • dongyue934001 2016-06-17 20:22
    关注

    Hourly pricing is not available for package id: 242 This script could help you to verify an order for Power8 server.

    <?php
    /**
     * This script verify an order for a Power8 Server using a preset Id.
     * 
     * The presets are used to simplify ordering by eliminating the need
     * for price ids when submitting orders.
     * Also when the order contains a preset id, it is not possible
     * to configure VLANs in the order.
     * 
     * Important manual pages:
     * @see http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order/verifyOrder
     * @see http://sldn.softlayer.com/reference/services/SoftLayer_Product_Package/getItemPrices
     * @see http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Hardware_Server
     * 
     * @license <http://sldn.softlayer.com/wiki/index.php/License>
     * @author SoftLayer Technologies, Inc. <sldn@softlayer.com>
     */
    // Change the path of your PHP client
    require_once ('C:\softlayer-api-php-client-master\src\SoapClient.php');
    
    // Your SoftLayer API username and key.
    $username = 'set me';
    $key = 'set me';
    
    $service = 'SoftLayer_Product_Order';
    
    $client = \SoftLayer\SoapClient::getClient($service, null, $username, $key);
    
    // The hostname and domain values required for the server.
    $hardwareNode = new \stdClass();
    $hardwareNode->hostname = 'tested_power8_server';
    $hardwareNode->domain = 'test.com';
    $orderHardware = array
    (
        $hardwareNode
    );
    
    // The items used for this server.
    // The items can be obtained using the next method: SoftLayer_Product_Package::getItemPrices
    $prices = array
    (
            50357,    // bandwidth id needs to be filled since its not part of the preset configuration
            641       // port-speed id needs to be filled since its not part of the preset configuration
    );
    $orderPrices = array();
    foreach ($prices as $priceId){
        $price = new \stdClass();
        $price->id = $priceId;
        $orderPrices[] = $price;
    }
    
    // The values used for the container (i.e. Power8 server) that's going to be verified.
    $location = 'DALLAS09';
    $packageId = 242;
    /*
     * To get the list of presets run the SoftLayer_Product_Packag::getActivePresets method
     * The values for preset Id are:
     * 80 for POWER8 C812L-S
     * 82 for POWER8 C812L-M
     * 84 for POWER8 C812L-L
     * 86 for POWER8 C812L- SSD
     */
    $presetId = 80; 
    $quantity = 1;
    $primaryDiskPartitionId = 1;
    $useHourlyPricing = false; // Hourly pricing is not available
    $complexType = 'SoftLayer_Container_Product_Order_Hardware_Server';
    
    $orderContainer = new \stdClass();
    $orderContainer->location               = $location;
    $orderContainer->packageId              = $packageId;
    $orderContainer->presetId               = $presetId;
    $orderContainer->prices                 = $orderPrices;
    $orderContainer->quantity               = $quantity;
    $orderContainer->hardware               = $orderHardware;
    $orderContainer->primaryDiskPartitionId = $primaryDiskPartitionId;
    $orderContainer->useHourlyPricing       = $useHourlyPricing;
    $orderContainer->complexType            = $complexType;
    
    try 
    {
        $verifiedOrderContainer = $client->verifyOrder($orderContainer);
        print_r($verifiedOrderContainer);
    } 
    catch (\Exception $e) 
    {
        die('Unable to verify order: ' . $e->getMessage());
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 windows2019+nginx+php耗时久
  • ¥15 labelme打不开怎么办
  • ¥35 按照图片上的两个任务要求,用keil5写出运行代码,并在proteus上仿真成功,🙏
  • ¥15 免费的电脑视频剪辑类软件如何盈利
  • ¥30 MPI读入tif文件并将文件路径分配给各进程时遇到问题
  • ¥15 pycharm中导入模块出错
  • ¥20 Ros2 moveit2 Windows环境配置,有偿,价格可商议。
  • ¥15 有关“完美的代价”问题的代码漏洞
  • ¥15 请帮我看一下这个简易化学配平器的逻辑有什么问题吗?
  • ¥15 暴力法无法解出,可能要使用dp和数学知识