Phone sales support +39 0575 05077
  Phone technical support +39 0575 0508
 

4.1.04 Resizing a virtual disk

Using Aruba's WsEndUser SetEnqueueVirtualDiskManage method you can queue a virtual disk management operation (Job).

Parameters
serverId
Type: int
System.Int32 type value which represents the unique identifier of the virtual server on which to perform the virtual disk management operation.
disk
Type: VirtualDiskUpdate
VirtualDiskUpdate class object which represents the virtual disk on which to perform the management operation. The VirtualDiskUpdate class contains all the useful information to complete the requested operation, depending on the type of operation task to be performed.

The virtual disk management operation can only be completed if the virtual server is not stopped, archived or deleting. Once the operation is queued you will not be able to queue other operations until the first one is complete.
There are also additional conditions for which a Virtual Disk management operation cannot be carried out:

Operation Condition
Resize The virtual disk to be resized is smaller or larger in size than the limits set by template

Let's look at an example of a method that changes the size of the virtual disk following that of the primary one

//IWsEndUser.SetEnqueueVirtualDiskManage Method (c# .NET)
private static void ResizeVirtualDisk(WsEndUserClient client, int serverId)
{
    try
    {
        //creates a new object called diskToResize,
        //VirtualDiskUpdate class 
        VirtualDiskUpdate diskToResize = new VirtualDiskUpdate()
        {
            Size = 20,
            VirtualDiskUpdateType = VirtualDiskOperationTypes.Resize,
            VirtualDiskType = VirtualDiskTypes.AdditionalVirtualDisk1,
        };

        //calls the SetEnqueueVirtualDiskManage method,
        //getting a WsResult object 
        WsResult result = client.SetEnqueueVirtualDiskManage(serverId, diskToResize);

        //if the call fails; it relaunches the error indicating the message 
        if (!result.Success)
            throw new ApplicationException(result.ResultMessage);
    }
    catch (Exception ex)
    {
        //relaunches the generic error 
        throw new ApplicationException(ex.Message);
    }
}
//IWsEndUser.setEnqueueVirtualDiskManage Method (JAVA)
private static void ResizeVirtualDisk(IWsEndUser client, int serverId)
{
    try
    {
        //creates a new object called diskToResize, VirtualDiskUpdate class 
        VirtualDiskUpdate diskToResize = new VirtualDiskUpdate();
        diskToResize.setVirtualDiskUpdateType(VirtualDiskOperationTypes.RESIZE);
        diskToResize.setVirtualDiskType(VirtualDiskTypes.ADDITIONAL_VIRTUAL_DISK_1);
        diskToResize.setSize(20);
                
        //calls the setEnqueueVirtualDiskManage method,
        //getting a WsResult object 
        WsResult result = client.setEnqueueVirtualDiskManage(serverId, diskToResize);

        //if the call fails; it relaunches the error indicating the message 
        if (!result.isSuccess())
        {
            throw new Exception(result.getResultMessage());
        }
    }
    catch (Exception ex)
    {
        //prints the error
        System.out.println(ex);
    }
}

Version
API: v2.8 URL: https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl
See also

API: v2.8 URL: https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl