I am trying to implement Modify Device Configuration using Softlayer java API. This process will be a similar process as purchase order. Is there any specific API to upgrade and
Below is a Java example to upgrade a VSI. For Example:
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);
}
}
}
How to get the available prices for the Virtual guest to upgrade? Execute:
https://[username]:[apikey]@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[virtual_guest_ID]/getUpgradeItemPrices
Method: GET
References:
https://forums.softlayer.com/forum/softlayer-developer-network/general-discussion/84916-changing-virtual-guest-maxmemory (This is a forum that will be outdated soon, but it help you now) https://sldn.softlayer.com/es/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade http://sldn.softlayer.com/reference/services/SoftLayer_Product_Order
Other examples:
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/
Regards