Forum Discussion

Scott_Delk_4899's avatar
Scott_Delk_4899
Icon for Nimbostratus rankNimbostratus
Aug 03, 2006

C# Disable Pool Members

Well I looked at some of the Pearl Script examples but im not a pearl buff so I didn't get too far. What im looking for is possibly some kind of easy function such as

 

 


//pool_member exmaple: "192.168.0.5:4444"
bool disable_poolmember(string[] pool, string[] pool_member)
{
    //Code Here
    return success;
}

 

 

Im not sure if its going to be as simple as this. Is there a way to disable a pool_member from commandline?

4 Replies

  • Look at the "toggle Pool Member" sample in the iControl CodeShare.

     

     

    It will show you how to query a pool member's state and then set it to the opposite. You should be able to repurpose that logic to do what you want. The Code flow is the same whether you are using Perl, .NET, or Axis (Java).

     

     

    -Joe
  • Well I looked at the Perl and used the following code:

     

    
    public void enable_poolmember(string sHostname, string sPort, string sUsername, 
        string sPassword, string sDomain, string[] pool_name, string pool_member_ip, 
        long pool_member_port)
    {
        System.Net.ServicePointManager.CertificatePolicy = this;
        updateConnectionInfo(sHostname, sPort, sUsername, sPassword, sDomain);
        PoolMember.LocalLBPoolMemberMemberSessionState[][] ses_state = 
        new LocalLBPoolMemberMemberSessionState[1][];
        ses_state[0] = new PoolMember.LocalLBPoolMemberMemberSessionState[1];
        ses_state[0][0] = new PoolMember.LocalLBPoolMemberMemberSessionState();
        ses_state[0][0].member = new PoolMember.CommonIPPortDefinition();
        ses_state[0][0].member.address = pool_member_ip;
        ses_state[0][0].member.port = pool_member_port;
        ses_state[0][0].session_state = CommonEnabledState.STATE_ENABLED;
                
        PoolMember.set_session_enabled_state(pool_name, ses_state);
    }

     

     

    and I am getting the error:

     

     

    
    !SoapHeaderException was unhandled
    Exception caught in LocalLB::PoolMember::set_session_enabled_state()
    Exception: Common::OperationFailed
            primary_error_code : 16908342 (0x01020036)

     

     

    any ideas?
  • Your code looks good. I tested your logic and it worked when passing in valid arguments (valid pool members for a given pool name). When I changed my pool member value to one that isn't currently defined in the passed in pool, I received the same exception:

     

     

    Exception: Exception caught in LocalLB::PoolMember::set_session_enabled_state()
    Exception: Common::OperationFailed
            primary_error_code   : 16908342 (0x01020036)
            secondary_error_code : 0
            error_string         : 01020036:3: The requested pool member (catbert-ht
    tp 10.10.10.10 http) was not found.

     

     

    Not sure why the secondary_error_code and error_string were omitted from your exception but that clearly points out that the 16908324 error is for a not found pool member.

     

     

    Verify your parameters with your configuration and give it another shot.

     

     

    -Joe
  • I figured it out. The pool member name that I was passing through was in Uppercase and I guess the pool_names are case sensative so im just grabbing a pool member list and looping through them.

    
    for (int i = 0; i < pool_list.Length; i++)
    {
        if (pool_list.ToString().ToUpper() == pool_name[0].ToString().ToUpper())
        {
            //now that I have pool_list.ToString() I will now have the correct
            //pool_name to pass
        }
    }