Forum Discussion

Michael_57183's avatar
Michael_57183
Icon for Nimbostratus rankNimbostratus
Feb 06, 2012

set Session Status using LocalLB::SessionStatus

Hi,

 

 

I'm trying to set a node's session status using the iControl API on a BIGIP v11.1.0 server.

 

 

Looking through the API documentation, I found LocalLB::Pool::set_member_session_enabled_state. This function takes the following inputs:

 

 

 

1. pool_names(String []) = The pool names to which the specified members belong.

 

 

2. members (AddressPort [] []) = The pool members to modify.

 

3. session_states (EnabledState [] [])

 

 

 

 

The third parameter, session_states, is of type Common::EnabledState, which has the following possible values:

 

 

 

A) 0 = STATE_DISABLED

 

B) 1 = STATE_ENABLED

 

 

 

 

However, (and this is where I get lost) this differs from the response returned by LocalLB::Pool::get_member_session_status. This get function returns a LocalLB::SessionStatus, which has the following possible values:

 

 

 

A) 0 = SESSION_STATUS_ENABLED

 

B) 1 = SESSION_STATUS_DISABLED

 

C) 2 = SESSION_STATUS_FORCED_DISABLED

 

D) 3 = SESSION_STATUS_ADDRESS_DISABLED

 

 

 

The AskF5 Knowledge Base article on Best Practice for "Disabling nodes or pool members for maintenance", describes the difference between

 

 

 

* a "disabled" pool member/node and

 

* a "forced offline" pool member/node

 

 

 

It looks to me that these are SESSION_STATUS_DISABLED and SESSION_STATUS_FORCED_DISABLED, respectfully.

 

 

 

Is there a way to set the Session Status of a node such that you can explicitly specify whether the node should become "disabled" or "forced offline"?

 

 

 

Or can someone otherwise explain the discrepancy between the returned value from get_member_session_status() and the input value to set_member_session_enabled_state()?

 

 

 

TIA

 

6 Replies

  • Check out this article I wrote on how you programmatically configure the three-way-toggle setting for the state of a pool member ("enabled", "disabled", or "forced offline").

     

     

    http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/369/iControl-Apps--20--Server-Control.aspx

     

     

    Note. the methods in this article were in the PoolMember interface. In v11, that interface was deprecated and the methods were moved into the Pool interface (as you've used in your example).

     

     

    Let me know if it still doesn't make sense and I'll try to clarify things a bit more.

     

     

    -Joe

     

  • Hi Joe,

     

     

    Thanks for the link; the table does an excellent job explaining how the Toggle State is derived from the Monitor & Session States (State or Status?).

     

     

    I'm still a little confused on

     

    1. which monitor_status responses translate to STATE_ENABLED or STATE_DISABLED, and

     

    2. which session_status responses translate to STATE_ENABLED or STATE_DISABLED

     

     

    According to the LocalLB::MonitorStatus documentation, there exists 9 possible monitor statuses, none of which are "STATE_ENABLED" or "STATE_DISABLED":

     

    0. MONITOR_STATUS_UNCHECKED

     

    1. MONITOR_STATUS_CHECKING

     

    2. MONITOR_STATUS_UP

     

    3. MONITOR_STATUS_DOWN

     

    4. MONITOR_STATUS_FORCED_DOWN

     

    5. MONITOR_STATUS_MAINT

     

    6. MONITOR_STATUS_ADDRESS_DOWN

     

    7. MONITOR_STATUS_DOWN_BY_IRULE

     

    8. MONITOR_STATUS_DOWN_WAIT_FOR_MANUAL_RESUME

     

     

    My best guess is that "MONITOR_STATUS_UP" should be considered "STATE_ENABLED" and all others should be considered "STATE_DISABLED". Does this logic make sense? Are there any "best practice recommendation" or precedents set from preexisting get_toggle_state() scripts on how to interpret each of these monitor statuses?

     

     

    Also, according to the , there exists 4 possible monitor statuses, none of which are "STATE_ENABLED" or "STATE_DISABLED":

     

    0. SESSION_STATUS_ENABLED

     

    1. SESSION_STATUS_DISABLED

     

    2. SESSION_STATUS_FORCED_DISABLED

     

    3. SESSION_STATUS_ADDRESS_DISABLED

     

     

    Again, my best guess here is that "SESSION_STATUS_ENABLED" should be considered "STATE_ENABLED" and all others should be considered "STATE_DISABLED". Is this correct?

     

     

    TIA

     

    -Michael
  • I am a beginner on doing perl scirpt using iControl, I am trying to modify a perl script poolToggle.pl download from F5 DevCentral samples with replacing the methods deprecated in v11.0, "set_member_session_enabled_state" is one of the methods I used to replace the "set_session_enabled_state". As there is one more parameter "members" required, I have used "get_member_v2" method to return the member list from the pool. And I am encountering error "Cannot convert a struct to a string" when the scripting running at below sub routine.

     

     

    error message: SOAP-ENV:Server Cannot convert a struct to a string.

     

     

    I have added some print actions for indicating the point of failure, and it should be at set_member_session_enabled_state, would you kindly help to advise how to fix the error? Many thanks.

     

    ==============

     

    sub setPoolMemberStates()

     

    {

     

    my ($pool, $state) = (@_);

     

     

    Get a list of pool members

     

    $soapResponse = $Pool->get_member_v2

     

    (

     

    SOAP::Data->name(pool_names => [$pool])

     

    );

     

    &checkResponse($soapResponse);

     

    @member_lists = @{$soapResponse->result};

     

    print "got member lists";

     

     

    Extract the 1st list for the single pool passed in.

     

    @member_list = @{@member_lists[0]};

     

     

    build parameters for set_session_enabled_state();

     

    foreach $member_def (@member_list)

     

    {

     

    $address = $member_def->{"address"};

     

    $port = $member_def->{"port"};

     

    $member = { address => $address, port => $port };

     

    $MemberSessionState =

     

    {

     

    member => $member,

     

    session_state => $state

     

    };

     

    push @MemberSessionStateList, $MemberSessionState;

     

    }

     

    push @MemberSessionStateLists, [@MemberSessionStateList];

     

    print "members session state array built";

     

    Set the session enabled state

     

    $soapResponse = $Pool->set_member_session_enabled_state

     

    (

     

    SOAP::Data->name(pool_names => [$pool]),

     

    SOAP::Data->name(members => [@member_lists]),

     

    SOAP::Data->name(session_states => [@MemberSessionStateLists])

     

    );

     

    &checkResponse($soapResponse);

     

    print "session state done";

     

    build parameters for set_monitor_state();

     

    foreach $member (@member_list)

     

    {

     

    $MemberMonitorState =

     

    {

     

    member => $member,

     

    monitor_state => $state

     

    };

     

    push @MemberMonitorStateList, $MemberMonitorState;

     

    }

     

    push @MemberMonitorStateLists, [@MemberMonitorStateList];

     

    print "action on monitror state";

     

    set the monitor state

     

    $soapResponse = $Pool->set_member_monitor_state

     

    (

     

    SOAP::Data->name(pool_names => [$pool]),

     

    SOAP::Data->name(members => [@member_lists]),

     

    SOAP::Data->name(monitor_states => [@MemberMonitorStateLists])

     

    );

     

    &checkResponse($soapResponse);

     

    }

     

  • I am a beginner on doing perl scirpt using iControl, I am trying to modify a perl script poolToggle.pl download from F5 DevCentral samples with replacing the methods deprecated in v11.0, "set_member_session_enabled_state" is one of the methods I used to replace the "set_session_enabled_state". As there is one more parameter "members" required, I have used "get_member_v2" method to return the member list from the pool. And I am encountering error "Cannot convert a struct to a string" when the scripting running at below sub routine.

     

     

    error message: SOAP-ENV:Server Cannot convert a struct to a string.

     

     

    I have added some print actions for indicating the point of failure, and it should be at set_member_session_enabled_state, would you kindly help to advise how to fix the error? Many thanks.

     

    ==============

     

    sub setPoolMemberStates()

     

    {

     

    my ($pool, $state) = (@_);

     

     

    Get a list of pool members

     

    $soapResponse = $Pool->get_member_v2

     

    (

     

    SOAP::Data->name(pool_names => [$pool])

     

    );

     

    &checkResponse($soapResponse);

     

    @member_lists = @{$soapResponse->result};

     

    print "got member lists";

     

     

    Extract the 1st list for the single pool passed in.

     

    @member_list = @{@member_lists[0]};

     

     

    build parameters for set_session_enabled_state();

     

    foreach $member_def (@member_list)

     

    {

     

    $address = $member_def->{"address"};

     

    $port = $member_def->{"port"};

     

    $member = { address => $address, port => $port };

     

    $MemberSessionState =

     

    {

     

    member => $member,

     

    session_state => $state

     

    };

     

    push @MemberSessionStateList, $MemberSessionState;

     

    }

     

    push @MemberSessionStateLists, [@MemberSessionStateList];

     

    print "members session state array built";

     

    Set the session enabled state

     

    $soapResponse = $Pool->set_member_session_enabled_state

     

    (

     

    SOAP::Data->name(pool_names => [$pool]),

     

    SOAP::Data->name(members => [@member_lists]),

     

    SOAP::Data->name(session_states => [@MemberSessionStateLists])

     

    );

     

    &checkResponse($soapResponse);

     

    print "session state done";

     

    build parameters for set_monitor_state();

     

    foreach $member (@member_list)

     

    {

     

    $MemberMonitorState =

     

    {

     

    member => $member,

     

    monitor_state => $state

     

    };

     

    push @MemberMonitorStateList, $MemberMonitorState;

     

    }

     

    push @MemberMonitorStateLists, [@MemberMonitorStateList];

     

    print "action on monitror state";

     

    set the monitor state

     

    $soapResponse = $Pool->set_member_monitor_state

     

    (

     

    SOAP::Data->name(pool_names => [$pool]),

     

    SOAP::Data->name(members => [@member_lists]),

     

    SOAP::Data->name(monitor_states => [@MemberMonitorStateLists])

     

    );

     

    &checkResponse($soapResponse);

     

    }

     

  • I believe the error is coming from the 3rd "session_states" parameter. The API calls for a 2-d array of Common.EnabledState enums.

    https://devcentral.f5.com/wiki/iControl.LocalLB__Pool__set_member_session_enabled_state.ashx

     set_member_session_enabled_state(
        in String [] pool_names,
        in Common__AddressPort [] [] members,
        in EnabledState [] [] session_states
    );
    

    EnabledState is an enum with a value of "STATE_ENABLED" or "STATE_DISABLED". You are passing in what looks like a 2-d array of structures containing a member and state.

    The server is most likely trying to parse the value of the enum and is coming across a structure instead.

    -Joe

  • Hi Joe

     

     

    Yes, it is right, the problem is fixed, after I changed the parameter to a simple 2D array of EnabledState value. Thanks so much for your advice.

     

     

    Best regards,

     

    Ben