Computing > 8 - LoadBalancers Management > Add LoadBalancer Rule

8.09 Add LoadBalancer Rule

By the Aruba WsEndUser method SetAddLoadBalancerRule you can add a rule to load balancer. The method require to specify the rule’s parameters.

Parameters
loadBalancerID
Type: int
Load balancer identification number

newRule
Type: LoadBalancerRule
The rule to add to balancer.


/// IWsEndUser.SetAddLoadBalancerRule Method (c# .NET)
public static string SetAddLoadBalancerRule(WsEndUserClient client,
    int loadBalancerID, LoadBalancerRule newRule)
{
    //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
        AddLoadBalancerRuleRequest request = 
            new AddLoadBalancerRuleRequest();
        request.LoadBalancerID = loadBalancerID;
        request.NewLoadBalancerRule = newRule;

        // call method SetAddLoadBalancerRule 
        // obtaining a WsResult item
        WsResult result = client.SetAddLoadBalancerRule(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.SetAddLoadBalancerRule Method (JAVA)
public static String SetAddLoadBalancerRule(IWsEndUser client,
    int loadBalancerID, LoadBalancerRule newRule)
{
    //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
    {
        // create the request object
        AddLoadBalancerRuleRequest request = new AddLoadBalancerRuleRequest();
        request.setLoadBalancerID(loadBalancerID);
        request.setNewLoadBalancerRule(newRule);

        // call method SetAddLoadBalancerRule 
        // obtaining a WsResult item
        WsResult result = client.setAddLoadBalancerRule(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