Computing > 8 - LoadBalancers Management > Add LoadBalancer Instances

8.11 Add LoadBalancer Instances

By the Aruba WsEndUser method SetEnqueueLoadBalancerAddInstances you can add the IP addresses to load balancer. The method require to specify the LoadBalancerID and the IP addresses to add.

Parameters
ipAddresses
Type: string
Array of string values with the set of IP addresses to balance

loadBalancerID
Type: int
Load balancer identification number


/// IWsEndUser.SetEnqueueLoadBalancerAddInstances Method (c# .NET)
public static string SetEnqueueLoadBalancerAddInstances(WsEndUserClient client,
        int loadBalancerID, string[] ipAddresses)
{
    //specify the account login details 
    client.ClientCredentials.UserName.UserName = "ARU-0000";
    client.ClientCredentials.UserName.Password = "0123456789";

    StringBuilder stringBuilder = new StringBuilder();

    try
    {
        // create the request object
        LoadBalancerInstancesRequest request = new LoadBalancerInstancesRequest();
        request.LoadBalancerID = loadBalancerID;
        request.Instances =  new LoadBalancerInstance[ipAddresses.Length];
        for(int i=0; i < ipAddresses.Length; i++)
        {
            LoadBalancerInstance item  = new LoadBalancerInstance();
            item.IPAddress = ipAddresses[i];
            request.Instances[i] = item;
        }


        // call method SetEnqueueLoadBalancerAddInstances 
        // obtaining a WsResult item
        WsResult result = client.SetEnqueueLoadBalancerAddInstances(request);

        //if the call is Success print value
        if (result.Success)
        {
            // get Value returned from server
            stringBuilder.Append(" Operation ends successfully. Result Code:");
            stringBuilder.Append(result.ResultCode);
        }
        else
        {
            throw new ApplicationException(result.ResultMessage);
        }
    }
    catch (Exception ex)
    {
        // re-run the error
        throw new ApplicationException(ex.Message);
    }

    return stringBuilder.ToString();
}
/// IWsEndUser.SetEnqueueLoadBalancerAddInstances Method (JAVA)
public static String SetEnqueueLoadBalancerAddInstances(IWsEndUser client,
     int loadBalancerID, String[] ipAddresses)
{
    //specify the account login details 
    ((BindingProvider) client).getRequestContext()
     .put(BindingProvider.USERNAME_PROPERTY, "ARU-0000");
    ((BindingProvider) client).getRequestContext()
     .put(BindingProvider.PASSWORD_PROPERTY, "0123456789");
    StringBuilder StringBuilder = new StringBuilder();

    try
    {
       ArrayOfLoadBalancerInstance arrayOfLoadBalancerInstance = 
          new ArrayOfLoadBalancerInstance();
       // create the request object
       LoadBalancerInstancesRequest request = new LoadBalancerInstancesRequest();
       request.setLoadBalancerID(loadBalancerID);
       request.setInstances(arrayOfLoadBalancerInstance);
 
       List<LoadBalancerInstance> loadBalancerInstanceList = 
          arrayOfLoadBalancerInstance.getLoadBalancerInstance();
 
       for(int i=0; i <ipAddresses.length; i++)
       {
          LoadBalancerInstance item  = new LoadBalancerInstance();
          item.setIPAddress(ipAddresses[i]);
          loadBalancerInstanceList.add(item);
       }
       // call method SetEnqueueLoadBalancerAddInstances 
       // obtaining a WsResult item
       WsResult result = client.setEnqueueLoadBalancerAddInstances(request);

       //if the call is Success print value
       if (result.isSuccess())
       {
          // get Value returned from server
          StringBuilder.append(" Operation ends successfully. Result Code : ");
          StringBuilder.append(result.getResultCode());
       }
       else
       {
          throw new Exception(result.getResultMessage());
       }
    }
    catch (Exception ex)
    {
       //show error
       System.out.println(ex);
    }

    return StringBuilder.toString();
}
Version
API: v2.8 URL:https://api.dc1.computing.cloud.it/WsEndUser/v2.8/WsEndUser.svc?wsdl