我正在尝试使用Softlayer java API实现修改设备配置。 此过程与采购订单类似。是否有任何特定的API来升级和降级设备?我找到了虚拟客户端的getUpgradeRequest()。如果您提供任何示例代码或API指南将有所帮助。 谢谢 Modify Device Configuration Page
readonly parameters="PATH=/usr/bin AWS_ACCESS_KEY_ID=XXX AWS_SECRET_ACCESS_KEY=XXX .."
env -i $parameters npm run init_test_tenant
答案 0 :(得分:0)
以下是升级VSI的Java示例。例如:
import java.util.ArrayList;
import java.util.List;
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.Property;
import com.softlayer.api.service.product.item.Price;
import com.softlayer.api.service.virtual.Guest;
import com.softlayer.api.service.container.product.order.virtual.guest.Upgrade;
public class UpgradeVirtualGuest {
public static void main(String[] args) {
String username = "set me";
String apikey = "set me";
// Set the Virtual Guest to upgrade
Long vsiId = new Long(11498369);
// Declare item prices. In this case I’m updating the RAM
// Please set the new item Price
Long[] prices = { new Long(1641)};
List<Property> properties = new ArrayList<Property>();
Property maintenance = new Property();
maintenance.setName("MAINTENANCE_WINDOW");
maintenance.setValue("2015-10-05T9:00:00-05:00");
properties.add(maintenance);
Guest vsi = new Guest();
vsi.setId(vsiId);
String containerIdentifier = "SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade";
// Create a SoftLayer API client object
ApiClient client = new RestApiClient().withCredentials(username, apikey).withLoggingEnabled();
/*
* Set up Order template
*/
Upgrade upgradeOrder = new Upgrade();
upgradeOrder.setContainerIdentifier(containerIdentifier);
upgradeOrder.getProperties().addAll(properties);
upgradeOrder.getVirtualGuests().add(0, vsi);
// Add Item prices to list
for (Long i : prices) {
Price price = new Price();
price.setId(new Long(i));
upgradeOrder.getPrices().add(price);
}
try
{
Order orderResult = com.softlayer.api.service.product.Order.service(client).verifyOrder(upgradeOrder);
System.out.println("order successfully verified: " + orderResult);
} catch (Exception e) {
System.out.println(e);
}
}
}
如何获取虚拟客户端升级的可用价格? 执行:
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[virtual_guest_ID]/getUpgradeItemPrices
Method: GET
<强>参考文献:强>
https://forums.softlayer.com/forum/softlayer-developer-network/general-discussion/84916-changing-virtual-guest-maxmemory (这是一个很快就会过时的论坛,但它现在对你有所帮助) https://sldn.softlayer.com/es/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order
其他示例:
https://softlayer.github.io/php/upgrade_virtual_guest/ https://gist.github.com/underscorephil/3790139 https://github.com/softlayer/softlayer-java/blob/master/examples/src/main/java/com/softlayer/api/example/OrderVirtualServer.java https://softlayer.github.io/
此致