0

Softlayer Java API を使用して、1 時間ごとの Bare Metal を注文したいと考えています。https://gist.github.com/bmpotter/fe2de7f8028d73ada4e5からアイデアを取り入れました。私の手順は次のとおりです。

    Hardware hardware = new Hardware();
    Order orderTemplate = new Order();

    // 1. Set hostname, domain to hardware
    // 2. set Preset 
    Preset preset = new Preset();
    preset.setKeyName("S1270_8GB_2X1TBSATA_NORAID");
    hardware.setFixedConfigurationPreset(preset);
    // 3. Component setMaxSpeed, and added to hardware
    hardware.setPrimaryNetworkComponent()
    // 4. "UBUNTU_14_64"
    hardware.setOperatingSystemReferenceCode()

    // 1. Added Quantity to orderTemplate
    // 2. Added location to orderTemplate
    // 3. Added Hardware to orderTemplate
    // 4. Added Container, since I am see the exception
    orderTemplate.setContainerIdentifier("SoftLayer_Product_Package_Preset");

    Finally tried to verify the Order.

一般的なエラー メッセージが表示され続けます。

指定されたコンテナーが無効です: SoftLayer_Container_Product_Order。サーバーまたはサービスの注文には、一般的な基本注文コンテナーではなく、特定のコンテナー タイプが必要です。

私は何を間違っていますか?priceIds非時間単位の Bare Metal Order と同様に、を送信する必要がありますか? 注文に何が欠けているかを知るためのトラブルシューティング ガイドはありますか?

ペドロ・デビッド・フエンテス 助けてくれませんか? 価格を調べた後、これを試しました:

https://[ユーザー名]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Product_Order/verifyOrder

{
   "parameters": [
   {
     "complexType": "SoftLayer_Container_Product_Order_Hardware_Server",
     "quantity": 1,
     "location": "DALLAS",
     "packageId": 200,
     "useHourlyPricing": 1,
     "presetId": 66,
     "prices": [
     {
        "id": 37318
     }, 
     {
        "id": 34183
     }, 
     {
        "id": 26737
     }, 
     {
        "id": 34807
     }, 
     {
        "id": 25014
     }
  ],
  "hardware": [
    {
      "hostname": "myhostname",
      "domain": "mydomain.com"
    }
   ]
  }
 ]
}
{ 
    "error": "Unable to add a Graphics Processing Unit price (178119) because it is not valid for the package (200).", 
    "code": "SoftLayer_Exception_Public" 
}

JAVAコードでも再現できるので、RESTでも試してみました。

追加のロギングを含む変更されたコード:

String username = "xxxxx";
String apiKey = "xxxxx";

Location datacenter = new Location();
datacenter.setName("seo01");

Preset preset = new Preset();
preset.setKeyName("S1270_8GB_2X1TBSATA_NORAID");

Component networkComponent = new Component();
networkComponent.setMaxSpeed(100L);

Hardware hardware = new Hardware();
hardware.setDatacenter(datacenter);
hardware.setHostname("xxxxx_xxxxx_BM_HOURLY");
hardware.setDomain("xxxx.xxx");
hardware.setHourlyBillingFlag(true);
hardware.setFixedConfigurationPreset(preset);
List<Component> networkComponents = hardware.getNetworkComponents();
networkComponents.add(networkComponent);
hardware.setOperatingSystemReferenceCode("CENTOS_LATEST");

ApiClient client = new RestApiClient().withCredentials(username, apiKey).withLoggingEnabled();
Hardware.Service hardwareService = Hardware.service(client); 
try
{  
  Gson gson = new Gson();
  Hardware hardwarePlaced = hardwareService.createObject(hardware);
  System.out.println("createObject: " + gson.toJson(hardwarePlaced));
}
catch(Exception e)
{
    System.out.println("Error: " + e);  
}

次のエラーが表示されます: 本文のリンクで POST を実行しています: {"parameters":[{"complexType":"SoftLayer_Hardware","hostname":"xxxxx_xxxxx_BM_HOURLY","domain":"xxxx.xxx","fixedConfigurationPreset":{ "complexType":"SoftLayer_Product_Package_Preset","keyName":"S1270_8GB_2X1TBSATA_NORAID"},"datacenter":{"complexType":"SoftLayer_Location","name":"seo01"},"hourlyBillingFlag":true,"networkComponents":[ {"complexType":"SoftLayer_Network_Component","maxSpeed":100}],"operatingSystemReferenceCode":"CENTOS_LATEST"}]} 本文のリンクで 500 を取得しました: {"error":"パッケージ (200) に対して有効でないため、グラフィック処理ユニットの価格 (178119) を追加できません。","code":"SoftLayer_Exception_Public"} エラー: com.softlayer.api.ApiException$Internal: グラフィックを追加できませんパッケージ (200) に対して有効でないため、処理単価 (178119)。 (コード: SoftLayer_Exception_Public、ステータス: 500)

4

2 に答える 2

0

BM サーバーの注文に関するこのドキュメントは、 http://sldn.softlayer.com/blog/bpotter/ordering-bare-metal-servers-using-softlayer-apiに役立ちます。

プリセットを注文する例を次に示します。

import java.util.List;
import com.softlayer.api.*;
import com.softlayer.api.service.Hardware;
import com.softlayer.api.service.Location;
import com.softlayer.api.service.network.Component;
import com.softlayer.api.service.product.Order;
import com.softlayer.api.service.product.pkg.Preset;
import com.google.gson.Gson;

public class OrderPreSetBMS2
{
  public static void main( String[] args )
  {
    String user = "set me";
    String apiKey = "set me";

    Location datacenter = new Location();
    datacenter.setName("seo01");

    Preset preset = new Preset();
    preset.setKeyName("S1270_8GB_2X1TBSATA_NORAID");

    Component networkComponent = new Component();
    networkComponent.setMaxSpeed(100L);


    Hardware hardware = new Hardware();
    hardware.setDatacenter(datacenter);
    hardware.setHostname("simplebmi");
    hardware.setDomain("test.com");
    hardware.setHourlyBillingFlag(true);
    hardware.setFixedConfigurationPreset(preset);
    List<Component> networkComponents = hardware.getNetworkComponents();
    networkComponents.add(networkComponent);
    hardware.setOperatingSystemReferenceCode("UBUNTU_14_64");

    ApiClient client = new RestApiClient().withCredentials(user, apiKey);
    Hardware.Service hardwareService = Hardware.service(client); 
    Order.Service orderService = Order.service(client); 

    try
    {
      //Change generateOrderTemplate method by createObject when you are ready to order the server. 
      com.softlayer.api.service.container.product.Order productOrder = hardwareService.generateOrderTemplate(hardware);
      Gson gson = new Gson();
      System.out.println(gson.toJson(productOrder));
    }
    catch(Exception e)
    {
        System.out.println("Error: " + e);  
    }
  }
}
于 2016-09-13T16:21:48.807 に答える