Phone sales support +39 0575 05077
  Phone technical support +39 0575 0508
 
Computing > 2 - Manipulating the items > Creating a Cloud Server

2.1 Creating a Cloud Server

How to create a Cloud Server

Using Aruba's WsEndUser SetEnqueueServerCreation method you can create a virtual server by specifying the characteristics of the various resources it comprises.

First, we should choose which "OSTemplateId" to utilize by recalling the method GetHypervisors which returns the various types of servers (hypervisors) with the related associated configurations (templates). The second thing to do once you have selected the "OSTemplateId" is set the resources. To set the resources we should use two different approaches based on server type as follow:
  • server PRO: we should set the resources properties inside the requet object sent to the server creation method.
  • server SMART: we can use the resources associated to a package profile. This profile is specified by the property SmartVMWarePackageID. The value of this property should be one returned value by the method GetPreConfiguredPackages. The value to use is the PackageID

Example of a method that allows us to retrieve all the necessary information
//IWsEndUser.GetHypervisors Method Method (c# .NET)
private static void GetHpervisors(WsEndUserClient client)
{
    WsResultOfArrayOfHypervisor hypervisors = client.GetHypervisors();
    foreach (Hypervisor hypervisor in hypervisors.Value)
    {
        Console.WriteLine(hypervisor.HypervisorType);
        Console.WriteLine(hypervisor.HypervisorServerType);

        //get active template
        IEnumerable activeTemplates = hypervisor.Templates
          .Where(p => p.TemplateSellingStatus == TemplateSellingStatus.OnSale);

        foreach (TemplateDetails template in activeTemplates)
        {
            Console.WriteLine("... " + template.Id + " - "
                + template.Name + " - " + template.Description + " - "
                + template.ProductId + " - " + template.TemplateType + " - "
                + template.ToolsAvailable);

            foreach (ResourceBound resourceBound in template.ResourceBounds)
            {
                Console.WriteLine("... ... " + resourceBound.Default + " - "
                    + resourceBound.Min + " - " + resourceBound.Max + " - "
                    + resourceBound.ResourceType);
            }
        }
    }
}
//IWsEndUser.GetHypervisors Method Method (JAVA)
private static void GetHpervisors(IWsEndUser client)
{
    WsResultOfArrayOfHypervisor result = client.getHypervisors();
    
    //retrieves the list of Hypervisors from the resulting object  
    for (Hypervisor hypervisor: result.getValue().getHypervisor())
    {
        System.out.println(hypervisor.getHypervisorType().value());
        System.out.println(hypervisor.getHypervisorServerType().value());

        //retrieves the list of associated templates       
        for (TemplateDetails template: 
                hypervisor.getTemplates().getTemplateDetails())
        {
            if (template.getTemplateSellingStatus() == TemplateSellingStatus.OnSale)
            {  
               System.out.println("... " + template.getId() + " - "
                    + template.getName() + " - " 
                    + template.getDescription() + " - "
                    + template.getProductId() + " - " 
                    + template.getTemplateType().value() + " - "
                    + template.isToolsAvailable());

                //retrieves the list of associated resources           
                for (ResourceBound resourceBound: 
                     template.getResourceBounds().getResourceBound())
                {
                   System.out.println("... ... " 
                        + resourceBound.getDefault() + " - "
                        + resourceBound.getMin() + " - " 
                        + resourceBound.getMax() + " - "
                        + resourceBound.getResourceType().value());
               }
            }
        }
    }    
}
Once we have retrieved the information we need we will move on to create the PRO server.
Later on we will see three examples of configuring the same server, but with different network configurations.
In the example we will create a server with the following characteristics:
server administration pwd: Passw@ord
OSTemplateId: 5 [which corresponds to a Hypervisor: VMware (Linux CentOS 5.6 - 64bit)]
4 processors
8 G memory
a primary disk of 10 G
a secondary disk of 50 G

Example No.1 a network card with public IDs automatically assigned
//IWsEndUser.SetEnqueueServerCreation Method (c# .NET)
private static void CreateServer(WsEndUserClient client)
{
    try
    {
        //creates a new object called serverToCreate, NewServer class 
        NewServer serverToCreate = new NewServer()
        {
            AdministratorPassword = "Passw@ord",
            CPUQuantity = 4,
            Name = "NewServer01",
            OSTemplateId = 5,
            RAMQuantity = 8,
            VirtualDisks = new List<VirtualDiskDetails>(){
                new VirtualDiskDetails ()
                { 
                    Size = 10, VirtualDiskType = VirtualDiskTypes.PrimaryVirtualDisk
                },
                new VirtualDiskDetails ()
                {
                    Size = 50, VirtualDiskType = VirtualDiskTypes.AdditionalVirtualDisk1
                },
            }.ToArray(),
            Note = "Server creato tramite chiamata a WSEndUser"
        };

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

        //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.setEnqueueServerCreation Method (JAVA)
private static void CreateServer(IWsEndUser client)
{
    try
    {
        //creates a new object called serverToCreate, NewServer class 
        NewServer serverToCreate = new NewServer();
        serverToCreate.setAdministratorPassword("Passw@ord");
        serverToCreate.setCPUQuantity(4);
        serverToCreate.setName("NewServer01");
        serverToCreate.setOSTemplateId(5);
        serverToCreate.setRAMQuantity(8);
        serverToCreate.setNote("Server created by means of a call to WSEndUser");
              
        //prepares the information on the virtual disks to be associated with the server
        ArrayOfVirtualDiskDetails virtualDiskDetails = new ArrayOfVirtualDiskDetails();
        VirtualDiskDetails disk1 = new VirtualDiskDetails();
        disk1.setSize(10);
        disk1.setVirtualDiskType(VirtualDiskTypes.PRIMARY_VIRTUAL_DISK);
        VirtualDiskDetails disk2 = new VirtualDiskDetails();
        disk2.setSize(50);
        disk2.setVirtualDiskType(VirtualDiskTypes.ADDITIONAL_VIRTUAL_DISK_1);
        virtualDiskDetails.getVirtualDiskDetails().add(disk1);
        virtualDiskDetails.getVirtualDiskDetails().add(disk2);       
        serverToCreate.setVirtualDisks(virtualDiskDetails);
        
        //calls the setEnqueueServerCreation method,
        //getting a WsResult object
        WsResult result = client.setEnqueueServerCreation(serverToCreate);

        //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);
    }
}
If we want to create a SMART server we should get a valid value to assign to the property SmartVMWarePackageID. These values can be by achieved the method GetPreConfiguredPackages
// IWsEndUser.GetPreConfiguredPackages Method (c# .NET)
public static String GetPreConfiguredPackages(WsEndUserClient client)
{
    //a StringBuilder class object is created
    StringBuilder sb = new StringBuilder();

    try
    {
        GetPreConfiguredPackagesRequest request = new GetPreConfiguredPackagesRequest();
        request.HypervisorType = HypervisorTypes.All;

        //calls the GetPreConfiguredPackages method, 
        //getting a WsResultOfArrayOfCloudPackage object 
        WsResultOfArrayOfCloudPackage result = client.GetPreConfiguredPackages(request);

        if (result.Success)
        {
            sb.AppendLine("Configured Packages: ");

            //gets the cost of the servers' components
            foreach (CloudPackage cp in result.Value)
            {
                sb.AppendLine("PackageID: " + cp.PackageID);
                sb.AppendLine("- Price: " + cp.Price);
                sb.AppendLine("- Description: " + cp.Descriptions[0]);
                sb.AppendLine("- Cpu Quantity: " + cp.CpuQuantity);
                sb.AppendLine("- Billing Type: " + cp.BillingType);
                sb.AppendLine("- Hdd0Quantity: " + cp.Hdd0Quantity);
            }
        }
        else
        {
            throw new ApplicationException(result.ResultMessage);
        }
    }             
    catch (Exception ex)
    {
        //relaunches the generic error 
        throw new ApplicationException(ex.Message);
    }

    return sb.ToString();
}
// IWsEndUser.GetPreConfiguredPackages Method JAVA)
public static String GetPreConfiguredPackages(IWsEndUser client)
{
    //a StringBuilder class object is created
    StringBuilder sb = new StringBuilder();

    try
    {
        GetPreConfiguredPackagesRequest request = new GetPreConfiguredPackagesRequest();
        request.setHypervisorType(HypervisorTypes.ALL);

        //calls the GetPreConfiguredPackages method, 
        //getting a WsResultOfArrayOfCloudPackage object 
        WsResultOfArrayOfCloudPackage result = client.getPreConfiguredPackages(request);

            if (result.isSuccess())            
        {
            sb.append("Configured Packages: ");

            //gets the cost of the servers' components
            for (CloudPackage cp: result.getValue())
            {
                sb.append("\nPackageID: " + cp.getPackageID());
                sb.append("\n\t- Price: " + cp.getPrice());
                sb.append("\n\t- Description: " + cp.getDescriptions());
                sb.append("\n\t- Cpu Quantity: " + cp.getCpuQuantity());
                sb.append("\n\t- Billing Type: " + cp.getBillingType());
                sb.append("\n\t- Hdd0Quantity: " + cp.getHdd0Quantity());
            }
        }
        {
            throw new Exception(result.getResultMessage());
        }
    }             
    catch (Exception ex)
    {
        //prints the error 
        System.out.println(ex);
    }

    return sb.toString();
}
Example No.2 a network card with a Virtual Switch
To find out how to buy a Virtual Switch go to: Virtual Switch
Example method for retrieving the ResourceId of a previously purchased VLAN
//IWsEndUser.GetPurchasedVLans Method (c# .NET)
private List<VLan> GetPurchasedVLans(WsEndUserClient client)
{
    List<VLan> listOfPurchasedVlan = new List<VLan>();

    try
    {
        //calls the GetPurchasedVLans method, 
        //getting a WsResult object 
        WsResultOfArrayOfVLan result = client.GetPurchasedVLans();

        //checks that the call was successful  
        if (result.Success)
        {
            //stores the VLANs returned in the VLAN list 
            //from Aruba's WsEndUser method 
            listOfPurchasedVlan = result.Value.ToList();
            foreach (var vlan in listOfPurchasedVlan)
            {
                Console.WriteLine(vlan.ResourceId);
            }
        }
    }
    catch (Exception ex)
    {
        //relaunches the error 
        throw new ApplicationException(ex.Message);
    }

    //returns the VLANs got list 
    return listOfPurchasedVlan;
}
//IWsEndUser.GetPurchasedVLans Method (JAVA)
private static List<VLan> GetPurchasedVLans(IWsEndUser client)
{
    List<VLan> listOfPurchasedVlan = new ArrayList<VLan>();

    try
    {
        //calls the GetPurchasedVLans method, 
        //getting a WsResult object 
        WsResultOfArrayOfVLan result = client.getPurchasedVLans();

        //checks that the call was successful 
        if (result.isSuccess())
        {
            //stores the VLANs returned in the VLAN list 
            //from Aruba's WsEndUser method 
            listOfPurchasedVlan = result.getValue().getVLan();
            for (VLan vlan : listOfPurchasedVlan)
            {
                System.out.println(vlan.getResourceId());
                System.out.println(vlan.getName());
                System.out.println(vlan.getVlanCode());
                for (int serverId : vlan.getServerIds().getInt())
                {
                    System.out.println(serverId);
                }
            }
        }
    }
    catch (Exception ex)
    {
        //prints the error 
        System.out.println(ex);
    }

    //returns the VLANs got list 
    return listOfPurchasedVlan;
}
//IWsEndUser.SetEnqueueServerCreation Method (c# .NET)
private static void CreateServerVLAN(WsEndUserClient client)
{
    try
    {
        //creates a new object called serverToCreate, NewServer class
        NewServer serverToCreate = new NewServer()
        {
            AdministratorPassword = "Passw@ord",
            CPUQuantity = 4,
            Name = "NewServer01",
            OSTemplateId = 5,
            RAMQuantity = 8,
            VirtualDisks = new List<VirtualDiskDetails>(){
                new VirtualDiskDetails ()
                { 
                    Size = 10, VirtualDiskType = VirtualDiskTypes.PrimaryVirtualDisk
                },
                new VirtualDiskDetails ()
                {
                    Size = 50, VirtualDiskType = VirtualDiskTypes.AdditionalVirtualDisk1
                },
            }.ToArray(),
            Note = "Server created by means of a call to WSEndUser",
            NetworkAdaptersConfiguration = new List<NetworkAdapterConfiguration>()
            {
                new NetworkAdapterConfiguration ()
                {
                    NetworkAdapterType = NetworkAdapterTypes.Ethernet0,
                    PrivateVLan = new PrivateVLanDetails()
                    {
                        IPAddress = "95.110.154.9",
                        SubNetMask = "255.255.255.0",
                        PrivateVLanResourceId = 43654
                    },
                }
            }.ToArray()
        };

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

        //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.setEnqueueServerCreation Method (JAVA)
private static void CreateServerVLan(IWsEndUser client, int vlanId)
{
    try
    {
        //creates a new object called serverToCreate, NewServer class 
        NewServer serverToCreate = new NewServer();
        serverToCreate.setAdministratorPassword("Passw@ord");
        serverToCreate.setCPUQuantity(4);
        serverToCreate.setName("NewServer01");
        serverToCreate.setOSTemplateId(5);
        serverToCreate.setRAMQuantity(8);
        serverToCreate.setNote("Server created by means of a call to WSEndUser");
        
        //prepares the information on the virtual servers to be associated with the server
        ArrayOfVirtualDiskDetails virtualDiskDetails = new ArrayOfVirtualDiskDetails();
        VirtualDiskDetails disk1 = new VirtualDiskDetails();
        disk1.setSize(10);
        disk1.setVirtualDiskType(VirtualDiskTypes.PRIMARY_VIRTUAL_DISK);
        VirtualDiskDetails disk2 = new VirtualDiskDetails();
        disk2.setSize(50);
        disk2.setVirtualDiskType(VirtualDiskTypes.ADDITIONAL_VIRTUAL_DISK_1);
        virtualDiskDetails.getVirtualDiskDetails().add(disk1);
        virtualDiskDetails.getVirtualDiskDetails().add(disk2);        
        serverToCreate.setVirtualDisks(virtualDiskDetails);
        
        //prepares the information on the network cards to be associated with the server
        ArrayOfNetworkAdapterConfiguration adapterDetails = 
                new ArrayOfNetworkAdapterConfiguration();
        NetworkAdapterConfiguration adatper = new NetworkAdapterConfiguration();
        PrivateVLanDetails vlan = new PrivateVLanDetails();
        vlan.setPrivateVLanResourceId(vlanId);
        vlan.setIPAddress("95.110.154.9");
        vlan.setSubNetMask("255.255.255.0");
        adatper.setPrivateVLan(vlan);
        adapterDetails.getNetworkAdapterConfiguration().add(adatper);               
        serverToCreate.setNetworkAdaptersConfiguration(adapterDetails);
        
        //calls the setEnqueueServerCreation method,
        //getting a WsResult object  
        WsResult result = client.setEnqueueServerCreation(serverToCreate);

        //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);
    }
}
Example No.3 a network card with a Public IP
To find out how to purchase a Public IP go to: Purchasing a Public IP
Example method to retrieve the ResourceID of a previously purchased public IP
//IWsEndUser.GetPurchasedIpAddresses Method (c# .NET)
private static List<IPAddress> GetPurchasedIpAddress(WsEndUserClient client)
{
    List<IPAddress> listOfPurchasedIPAddress = new List<IPAddress>();

    try
    {
        //calls the GetPurchasedIpAddresses method, 
        //getting a WsResultOfArrayOfIPAddress object
        WsResultOfArrayOfIPAddress result = client.GetPurchasedIpAddresses();
        
        //checks that the call was successful  
        if (result.Success)
        {
            //stores the public IPs in the IPAddress list
            //got from Aruba's WsEndUser method  
            listOfPurchasedIPAddress = result.Value.ToList();
            foreach (var ipaddress in listOfPurchasedIPAddress)
            {
                Console.WriteLine(ipaddress.ResourceId);
            }
        }
    }
    catch (Exception ex)
    {
        //relaunches the error 
        throw new ApplicationException(ex.Message);
    }

    //returns the IPAddresses got list 
    return listOfPurchasedIPAddress;
}
//IWsEndUser.GetPurchasedIpAddresses Method (JAVA)
private static List<IPAddress> GetPurchasedIpAddress(IWsEndUser client)
{
    List<IPAddress> listOfPurchasedIPAddress = new ArrayList<IPAddress>();

    try
    {
        //calls the GetPurchasedIpAddresses method, 
        //getting a WsResultOfArrayOfIPAddress object
        WsResultOfArrayOfIPAddress result = client.getPurchasedIpAddresses();
        
        //checks that the call was successful 
        if (result.isSuccess())
        {
            //stores the public IPs in the IPAddress list
            //got from Aruba's WsEndUser method  
            listOfPurchasedIPAddress = result.getValue().getIPAddress();
            for (IPAddress ipaddress : listOfPurchasedIPAddress)
            {
                System.out.println(ipaddress.getServerId());
                System.out.println(ipaddress.getResourceId());
                System.out.println(ipaddress.getValue());
                System.out.println(ipaddress.getSubNetMask());
                System.out.println(ipaddress.getGateway());                       
             }
        }
    }
    catch (Exception ex)
    {
        //prints the error 
        System.out.println(ex.getMessage());
    }

    //returns the IPAddresses got list 
    return listOfPurchasedIPAddress;
}
//IWsEndUser.SetEnqueueServerCreation Method (c# .NET)
private static void CreateServerIPPublic(WsEndUserClient client)
{
    try
    {
        //creates a new object called serverToCreate, NewServer class 
        NewServer serverToCreate = new NewServer()
        {
            AdministratorPassword = "Passw@ord",
            CPUQuantity = 4,
            Name = "NewServer01",
            OSTemplateId = 5,
            RAMQuantity = 8,
            VirtualDisks = new List<VirtualDiskDetails>(){
                new VirtualDiskDetails ()
                { 
                    Size = 10, VirtualDiskType = VirtualDiskTypes.PrimaryVirtualDisk
                },
                new VirtualDiskDetails ()
                {
                    Size = 50, VirtualDiskType = VirtualDiskTypes.AdditionalVirtualDisk1
                },
            }.ToArray(),
            Note = "Server created using call to WSEndUser",
            NetworkAdaptersConfiguration = new List<NetworkAdapterConfiguration>()
            {
                new NetworkAdapterConfiguration()
                {
                    NetworkAdapterType = NetworkAdapterTypes.Ethernet0,
                    PublicIpAddresses = new List<PublicIpAddressDetails>()
                    {
                        new PublicIpAddressDetails()
                        {
                            PrimaryIPAddress = true,
                            PublicIpAddressResourceId = 2647
                        }
                    }.ToArray(),
                }
            }.ToArray()
        };

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

        //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.setEnqueueServerCreation Method (JAVA)
private static void CreateServerIPPublic(IWsEndUser client, int ipId)
{
    try
    {
        //creates a new object called serverToCreate, NewServer class 
        NewServer serverToCreate = new NewServer();
        serverToCreate.setAdministratorPassword("Passw@ord");
        serverToCreate.setCPUQuantity(4);
        serverToCreate.setName("NewServer01");
        serverToCreate.setOSTemplateId(5);
        serverToCreate.setRAMQuantity(8);
        serverToCreate.setNote("Server created using a call to WSEndUser");
        
        //prepares the information on the virtual servers to be associated with the server
        ArrayOfVirtualDiskDetails virtualDiskDetails = new ArrayOfVirtualDiskDetails();
        VirtualDiskDetails disk1 = new VirtualDiskDetails();
        disk1.setSize(10);
        disk1.setVirtualDiskType(VirtualDiskTypes.PRIMARY_VIRTUAL_DISK);
        VirtualDiskDetails disk2 = new VirtualDiskDetails();
        disk2.setSize(50);
        disk2.setVirtualDiskType(VirtualDiskTypes.ADDITIONAL_VIRTUAL_DISK_1);
        virtualDiskDetails.getVirtualDiskDetails().add(disk1);
        virtualDiskDetails.getVirtualDiskDetails().add(disk2);
        serverToCreate.setVirtualDisks(virtualDiskDetails);
        
        //prepares the information on the network cards to be associated with the server
        ArrayOfNetworkAdapterConfiguration adapterDetails = 
                new ArrayOfNetworkAdapterConfiguration();
        NetworkAdapterConfiguration adatper = new NetworkAdapterConfiguration();
        ArrayOfPublicIpAddressDetails ipaddress = new ArrayOfPublicIpAddressDetails();
        PublicIpAddressDetails publicIp = new PublicIpAddressDetails();
        publicIp.setPrimaryIPAddress(true);
        publicIp.setPublicIpAddressResourceId(ipId);
        ipaddress.getPublicIpAddressDetails().add(publicIp);
        adatper.setPublicIpAddresses(ipaddress);
        adapterDetails.getNetworkAdapterConfiguration().add(adatper);               
        serverToCreate.setNetworkAdaptersConfiguration(adapterDetails);
        
        //calls the setEnqueueServerCreation method,
        //getting a WsResult object 
        WsResult result = client.setEnqueueServerCreation(serverToCreate);

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