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

4.1.05 Deleting 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 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
Delete The virtual disk to be deleted is the primary disk of the virtual server

Let's look at an example of a method that deletes the virtual disk subsequent to the primary one.

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

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

        //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 DeleteVirtualDisk(IWsEndUser client, int serverId)
{
    try
    {
        //creates a new object called diskToDelete, VirtualDiskUpdate class
        VirtualDiskUpdate diskToDelete = new VirtualDiskUpdate();
        diskToDelete.setVirtualDiskUpdateType(VirtualDiskOperationTypes.DELETE);
        diskToDelete.setVirtualDiskType(VirtualDiskTypes.ADDITIONAL_VIRTUAL_DISK_1);
                
        //calls the setEnqueueVirtualDiskManage method,
        //getting a WsResult object
        WsResult result = client.setEnqueueVirtualDiskManage(serverId, diskToDelete);

        //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