Phone sales support +39 0575 05077
  Phone technical support +39 0575 0508
 
Computing > 4 - Advanced manipulation of the items > Editing the network configuration

4.1.07 Editing the network configuration

Using Aruba's WsEndUser SetEnqueueAssociateIpAddress method you can associate one or more IPAddresses reserved to the account indicated during authentication with a network adapter. The association of the IP address to a network adapter operation cannot be completed if the IPAddress or the network adapter does not exist or does not belong to the specified account, or if the virtual server is not Running or Stopped.
Similarly, the association of IPAddress and network adapter operation will not be successful if the IPAddress is already associated with a VLAN, or if there is an operation queued, in relation to the resource in question, with a status other than Error or Completed.

Before proceeding we need to retrieve the information we need to be run as parameters to our example method.
The ResourceId of the NetworkAdapter and ResourceIds of public IPs purchased and not yet associated.

Example method that retrieves the ResourceId of the NetworkAdapter associated with the server and the public IPs associated with it.
//IWsEndUser.GetServerDetails Method (c# .NET)
private static String GetServerNetworkAdapters(WsEndUserClient client, int serverId)
{
    //a StringBuilder class object is created
    StringBuilder sb = new StringBuilder();

    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;

            sb.AppendLine("Network adapters");
            foreach (NetworkAdapter na in details.NetworkAdapters)
            {
                sb.AppendLine("\t id: " + na.Id);
                sb.AppendLine("\t\t Mac address: " + na.MacAddress);
                sb.AppendLine("\t\t IP addresses: ");

                foreach (IPAddress ip in na.IPAddresses.ToList())
                {
                    sb.AppendLine("\t\t\t " + ip.Value);
                }

                sb.AppendLine("\t\t type: " + na.NetworkAdapterType);
                if (na.VLan != null)
                    sb.AppendLine("\t\t VLan name: " + na.VLan.Name);
            }
        }
        else
        {
            throw new ApplicationException(result.ResultMessage);
        }
    }
    catch (Exception ex)
    {
        //relaunches the generic error
        throw new ApplicationException(ex.Message);
    }

    return sb.ToString();
}
//IWsEndUser.getServerDetails Method (JAVA)
private static String GetServerNetworkAdapters(IWsEndUser client, int serverId)
{
    //a StringBuilder class object is created
    StringBuilder sb = new StringBuilder();

    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 object ServerDetails
            ServerDetails details = result.getValue();
                        
            sb.append("Network adapters: ");

            for (NetworkAdapter na : details.getNetworkAdapters().getNetworkAdapter())
            {
                sb.append("\t id: ").append(na.getId().toString());
                sb.append("\t\t Mac address: ").append(na.getMacAddress());
                sb.append("\t\t IP addresses: ");
                                
                for (IPAddress ip : na.getIPAddresses().getIPAddress())
                {
                    sb.append("\t\t\t ").append(ip);
                }

                sb.append("\t\t type: ").append(na.getNetworkAdapterType().value());
                if (na.getVLan() != null)
                {
                    sb.append("\t\t VLan name: ").append(na.getVLan().getName());
                }
            }
        }
        else
        {
            throw new Exception(result.getResultMessage());
        }
    }
    catch (Exception ex)
    {
        //prints the error
        System.out.println(ex);
    }

    return sb.toString();
}

Example method that recovers the ResourceIds for the public IPs purchased.
//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 virtual IPs in the IPAddress list
            //got from Aruba's WsEndUser method
            listOfPurchasedIPAddress = result.Value.ToList<IPAddress>();
            foreach (var ipaddress in listOfPurchasedIPAddress)
            {
                Console.WriteLine(ipaddress.ServerId);
                Console.WriteLine(ipaddress.ResourceId);
                Console.WriteLine(ipaddress.Value);
                Console.WriteLine(ipaddress.SubNetMask);
                Console.WriteLine(ipaddress.Gateway);                       
            }
        }
    }
    catch (Exception ex)
    {
        //relaunches the error
        throw new ApplicationException(ex.Message);
    }

    //returns the IPAddress got list
    return listOfPurchasedIPAddress;
}
//IWsEndUser.getPurchasedIpAddresses Method (JAVA)
private static <IPAddress> GetPurchasedIpAddress(IWsEndUser client)
{
    <IPAddress> listOfPurchasedIPAddress = new Array<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 IPAddress got list
    return listOfPurchasedIPAddress;
}

We can now implement the method to associate a public IP with our server.
//IWsEndUser.SetEnqueueAssociateIpAddress Method (c# .NET)
private static void EnqueueAssociateIpAddress(
    WsEndUserClient client, int[] ipAddresssourceId, int networkAdapterId)
{
    try
    {
        //calls the SetEnqueueAssociateIpAddress method,
        //getting a WsResult object
        WsResult result = client.SetEnqueueAssociateIpAddress(
            ipAddresssourceId, networkAdapterId);

        //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.setEnqueueAssociateIpAddress Method (JAVA)
private static void EnqueueAssociateIpAddress(
    IWsEndUser client, int[] ipAddresssourceId, int networkAdapterId)
{
    try
    {
        //populates the array type to be passed on to the method
        ArrayOfint arrayofint = new ArrayOfint();
        for (int ip : ipAddresssourceId)
        {
            arrayofint.getInt().add(ip);
        }
        
        //calls the setEnqueueAssociateIpAddress method,
        //getting a WsResult object
        WsResult result = client.setEnqueueAssociateIpAddress(
            arrayofint, networkAdapterId);

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

The same is true to deassociate a public IP, first we need to retrieve the data, as seen above.
We can now implement the method to deassociate a public IP from our server.
//IWsEndUser.SetEnqueueDeassociateIpAddress Method (c# .NET)
private static void EnqueueDeassociateIpAddress(
    WsEndUserClient client, int[] ipAddresssourceId, int networkAdapterId)
{
    try
    {
        //calls the SetEnqueueDeassociateIpAddress method,
        //getting a WsResult object
        WsResult result = client.SetEnqueueDeassociateIpAddress(
            ipAddresssourceId, networkAdapterId);

        //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.setEnqueueDeassociateIpAddress Method (JAVA)
private static void EnqueueDeassociateIpAddress(
    IWsEndUser client, int[] ipAddresssourceId, int networkAdapterId)
{
    try
    {
        //populates the array type to be passed on to the method
        ArrayOfint arrayofint = new ArrayOfint();
        for (int ip : ipAddresssourceId)
        {
            arrayofint.getInt().add(ip);
        }
        
        //calls the setEnqueueDeassociateIpAddress method,
        //getting a WsResult object
        WsResult result = client.setEnqueueDeassociateIpAddress(
            arrayofint, networkAdapterId);

        //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 method that recovers the ResourceIds for the virtual switches purchased.
//IWsEndUser.GetPurchasedVLans Method
private static List<VLan> GetPurchasedVLans(WsEndUserClient client)
{
    List<VLan> listOfPurchasedVlan = new List<VLan>();

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

        //checks that the call was successful
        if (result.Success)
        {
            //stores in the returned VLANs list
            //from Aruba's WsEndUser method
            listOfPurchasedVlan = result.Value.ToList<VLan>();
            foreach (VLan vlan in listOfPurchasedVlan)
            {
                Console.WriteLine(vlan.ResourceId);
                Console.WriteLine(vlan.Name);
                Console.WriteLine(vlan.VlanCode);
                foreach (int serverId in vlan.ServerIds)
                    Console.WriteLine(serverId);
            }
        }
    }
    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;
}

We can now implement the method to associate a virtual switch with our server.
//IWsEndUser.SetEnqueueAssociateVLan Method (c# .NET)
private static void EnqueueAssociateVLan(
    WsEndUserClient client, int vLanesourceId, int networkAdapterId)
{
    try
    {
        //calls the SetEnqueueAssociateVLan method,
        //getting a WsResult object
        WsResult result = client.SetEnqueueAssociateVLan(
            vLanesourceId, networkAdapterId);

        //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.setEnqueueAssociateVLan Method (JAVA)
private static void EnqueueAssociateVLan(
    IWsEndUser client, int vLanesourceId, int networkAdapterId)
{
    try
    {
        //calls the setEnqueueAssociateVLan method,
        //getting a WsResult object
        WsResult result = client.setEnqueueAssociateVLan(
            vLanesourceId, networkAdapterId);

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

The same is true to deassociate a virtual switch, first we need to retrieve the data, as seen above.
We can now implement the method to deassociate a virtual switch from our server.
//IWsEndUser.SetEnqueueDeassociateVLan Method (c# .NET)
private static void EnqueueDeassociateVLan(
    WsEndUserClient client, int vLanesourceId, int networkAdapterId)
{
    try
    {
        //calls the SetEnqueueDeassociateVLan method,
        //getting a WsResult object
        WsResult result = client.SetEnqueueDeassociateVLan(
            vLanesourceId, networkAdapterId);

        //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.setEnqueueDeassociateVLan Method (JAVA)
private static void EnqueueDeassociateVLan(
    IWsEndUser client, int vLanesourceId, int networkAdapterId)
{
    try
    {
        //calls the setEnqueueDeassociateVLan method,
        //getting a WsResult object
        WsResult result = client.setEnqueueDeassociateVLan(
            vLanesourceId, networkAdapterId);

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

Bookmark and Share