我正在努力寻找一种方法来使用 Java 语言在 Softlayer(每小时)上使用 GPU 订购 Bare Metal Server。有一些关于此的片段消息,但我找不到 Java 的完整示例。以目前的信息,我应该终于可以得到目标了,但时间会被浪费掉。:(
我在哪里可以获得这样的 Java 示例?
我正在努力寻找一种方法来使用 Java 语言在 Softlayer(每小时)上使用 GPU 订购 Bare Metal Server。有一些关于此的片段消息,但我找不到 Java 的完整示例。以目前的信息,我应该终于可以得到目标了,但时间会被浪费掉。:(
我在哪里可以获得这样的 Java 示例?
看这个例子:
package restapp.examples;
import java.util.ArrayList;
import java.util.List;
import com.softlayer.api.*;
import com.softlayer.api.service.Hardware;
import com.softlayer.api.service.hardware.Server;
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.item.Price;
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("ams01");
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).withLoggingEnabled();
Hardware.Service hardwareService = Hardware.service(client);
Order.Service orderService = Order.service(client);
try
{
com.softlayer.api.service.container.product.Order productOrder = hardwareService.generateOrderTemplate(hardware);
Gson gson = new Gson();
System.out.println(gson.toJson(productOrder));
com.softlayer.api.service.container.product.Order order = orderService.verifyOrder(productOrder);
Gson gson2 = new Gson();
System.out.println(gson2.toJson(order));
}
catch(Exception e)
{
System.out.println("Error: " + e);
}
}
}
基本上这就是您需要更改参数值以查看调用方法http://sldn.softlayer.com/reference/services/SoftLayer_Hardware_Server/getCreateObjectOptions所需的有效配置的想法
还要检查 createObject 方法的文档http://sldn.softlayer.com/reference/services/softlayer_hardware_server/createobject