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

4.1 Editing a Cloud Server

Using Aruba's WsEndUser SetEnqueueServerUpdate method you can change the resources of a virtual server, specifying the characteristics of the resources that have changed.

Parameters
server
Type: ServerUpdate
UpdateServer class object that represents the structure of the server to be edited.
The UpdateServer class contains all the useful information to complete the task of updating the virtual server, and all the related resources.

 ATTENTION: given that it is not possible to queue up more than one operation at a time on one Cloud Server, before any change is started it is necessary to verify that there are no processes in queue.
Example method that checks whether or not it is possible to queue operations to a Cloud Server.
If our method returns true, then we can run the changes to the server.
//IWsEndUser.GetServerDetails Method (c# .NET)
private static bool ServerIsEnqueueble(WsEndUserClient client, int serverId)
{
    try
    {
        //calls the GetServerDetails method,
        //getting a WsResultOfServerDetails object 
        WsResultOfServerDetails result = client.GetServerDetails(serverId);

        //if the call fails; it relaunches the error indicating the message
        if (result.Success)
        {
            //the list of information on the virtual server is
            //stored in the ServerDetails object
            ServerDetails details = result.Value;

            //checks if there are active jobs
            if (details.ActiveJobs.Count() == 0)
                return true;
            else
                return false;
        }
        else
        {
            throw new ApplicationException(result.ResultMessage);
        }
    }
    catch (Exception ex)
    {
        //relaunches the generic error 
        throw new ApplicationException(ex.Message);
    }
}
//IWsEndUser.getServerDetails Method (JAVA)
private static boolean ServerIsEnqueueble(IWsEndUser client, int serverId)
{
    boolean value = false;
    
    try
    {
        //calls the getServerDetails method,
        //getting a WsResultOfServerDetails object 
        WsResultOfServerDetails result = client.getServerDetails(serverId);

        //if the call fails; it relaunches the error indicating the message
        if (result.isSuccess())
        {
            //the list of information on the virtual server is
            //stored in the ServerDetails object
            ServerDetails details = result.getValue();

            //checks if there are jobs running
            if (details.getActiveJobs().getJob().isEmpty())
            {
                value = true;
            }
         }
        else
        {
            throw new Exception(result.getResultMessage());
        }
    }
    catch (Exception ex)
    {
        //prints the error 
        System.out.println(ex);
    }
    
    return value;
}

In case of PRO profile we can specify the properties (CPU, RAM, etc) to change. Let's look at the example of a method that performs an update operation of the CPU, RAM, and the primary virtual disk

//IWsEndUser.SetEnqueueServerUpdate Method (c# .NET)
private static void UpdateServer(WsEndUserClient client, int serverId)
{
    try
    {
        //creates a new object called serverToUpdate, ServerUpdate class
        ServerUpdate serverToUpdate = new ServerUpdate()
        {
            //the new number of CPUs  
            CPUQuantity = 4,
            //the new amount of RAM 
            RAMQuantity = 8,
            //indicates the virtual server on which to apply the update  
            ServerId = serverId,
            //comprises a list of the virtual disks that have to 
            //be updated in the dimension
            VirtualDisks = new List<VirtualDiskUpdate>()
            {
                new VirtualDiskUpdate()
                {
                    //the virtual disk on which to apply the change 
                    VirtualDiskType = VirtualDiskTypes.PrimaryVirtualDisk, 
                    //the new size of the virtual disk 
                    Size = 20,  
                    //the operation to be performed on the virtual disk
                    VirtualDiskUpdateType = VirtualDiskOperationTypes.Resize
                }
            }.ToArray()
        };

        //calls the SetEnqueueServerUpdate method,
        //getting a WsResult object 
        WsResult result = client.SetEnqueueServerUpdate(serverToUpdate);

        //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.setEnqueueServerUpdate Method (JAVA)
private static void UpdateServer(IWsEndUser client, int serverId)
{
    try
    {
        //creates a new object called serverToUpdate, ServerUpdate class 
        ServerUpdate serverToUpdate = new ServerUpdate();
        //the new number of CPUs 
        serverToUpdate.setCPUQuantity(4);
        //the new amount of RAM
        serverToUpdate.setRAMQuantity(8);
        //indicates the virtual server on which to apply the update
        serverToUpdate.setServerId(serverId);      
        //comprises a list of the virtual disks that have to 
        //be updated in size 
        ArrayOfVirtualDiskUpdate virtualDiskUpdate = new ArrayOfVirtualDiskUpdate();
        VirtualDiskUpdate diskupdate = new VirtualDiskUpdate();
        diskupdate.setSize(20);
        diskupdate.setVirtualDiskType(VirtualDiskTypes.PRIMARY_VIRTUAL_DISK);
        diskupdate.setVirtualDiskUpdateType(VirtualDiskOperationTypes.RESIZE);       
        virtualDiskUpdate.getVirtualDiskUpdate().add(diskupdate);
        serverToUpdate.setVirtualDisks(virtualDiskUpdate);
 
        //calls the setEnqueueServerUpdate method,
        //getting a WsResult object 
        WsResult result = client.setEnqueueServerUpdate(serverToUpdate);

        //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);
    }
}


In case of SMART profile we can specify the identifier of the SMART profile, the properties will be upgraded based on that profile. Here is an example:
//IWsEndUser.SetEnqueueServerUpdate Method (c# .NET)
private static void UpdateServer(WsEndUserClient client,
    int serverId, int smartPackageId)
{
    try
    {
        // create the request specifying the SMART package id
        ServerUpdate serverToUpdate = new ServerUpdate();
        serverToUpdate.SmartVMWarePackageID = smartPackageId;
               
        //calls the SetEnqueueServerUpdate method,
        //getting a WsResult object 
        WsResult result = client.SetEnqueueServerUpdate(serverToUpdate);

        //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.SetEnqueueServerUpdate Method (c# .NET)
private static void UpdateServer(WsEndUserClient client, 
        int serverId, int smartPackageId)
{
    try
    {
        ServerUpdate serverToUpdate = new ServerUpdate();
        serverToUpdate.setSmartVMWarePackageID(smartPackageId);

        //calls the SetEnqueueServerUpdate method,
        //getting a WsResult object 
        WsResult result = client.SetEnqueueServerUpdate(serverToUpdate);

        //if the call fails; it relaunches the error indicating the message
        if (!result.Success)
            throw new Exception(result.ResultMessage);
    }
    catch (Exception ex)
    {
        //relaunches the generic error
        throw new Exception(ex.getMessage());
    }
}
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