我尝试使用java的静态子网顺序示例执行此操作: How to Set EndpointIPAddress in ordering subnet using java
并基于python代码修改它以订购portabale子网: SoftLayer API: Ordering Subnet
但是,我得到了异常,表明订单配置错误,而且是针对静态而非预期的便携式网络:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:294)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.softlayer.api.ApiException$Internal: An endpoint IP Address is required to order a static subnet.(code: SoftLayer_Exception_Public, status: 500)
at com.softlayer.api.ApiException.fromError(ApiException.java:16)
at com.softlayer.api.RestApiClient$ServiceProxy.logAndHandleResponse(RestApiClient.java:258)
at com.softlayer.api.RestApiClient$ServiceProxy.invokeService(RestApiClient.java:300)
at com.softlayer.api.RestApiClient$ServiceProxy.invoke(RestApiClient.java:466)
at com.sun.proxy.$Proxy29.verifyOrder(Unknown Source)
at com.tieto.tecong.slcli.App.main(App.java:82)
这是我使用的java代码:
package com.tieto.tecong.slcli;
import com.softlayer.api.ApiClient;
import com.softlayer.api.RestApiClient;
import com.softlayer.api.service.container.product.Order;
import com.softlayer.api.service.container.product.order.network.Subnet;
import com.softlayer.api.service.product.item.Price;
public class App
{
public static void main( String[] args )
{
ApiClient client = new RestApiClient().withCredentials("sdffds", "sdfsfd");
Long[] prices = {13983L};
Long quantity = 4L;
Long vlanId = 1360265L;
Long packageId = 0L;
String containerIdentifier = "SoftLayer_Container_Product_Order_Network_Subnet";
Subnet newOrder = new Subnet();
newOrder.setContainerIdentifier(containerIdentifier);
newOrder.setPackageId(packageId);
newOrder.setQuantity(quantity);
newOrder.setEndPointVlanId(vlanId);
for (Long i : prices) {
Price price = new Price();
price.setId(new Long(i));
newOrder.getPrices().add(price);
}
Order orderResult = com.softlayer.api.service.product.Order.service(client).verifyOrder(newOrder);
System.out.println("order successfully verified: " + orderResult);
}
}
答案 0 :(得分:0)