Forum Discussion

wayney_128269's avatar
wayney_128269
Icon for Nimbostratus rankNimbostratus
Dec 23, 2005

PoolMember.set_monitor_state problem

 

So I have some code that uses PoolMember.set_monitor_state to UP\DOWN pool members. I have the same 1.1.1.1 80 combination in Pool_X and Pool_Y. When I take DOWN the 1.1.1.80 from Pool_X, it gets taken DOWN from Pool_Y also. I want to be able to only take the IP\Port DOWN from the pool I specify, not all pools. Does PoolMember.set_monitor_state do this?

 

 

thanks
  • That is not expected behavior and I just wrote an app to test it out

     

     

    Setup:

     

     

    pool_1 {10.10.10.10:80 20.20.20.20:80}

     

    pool_2 {10.10.10.10:80 20.20.20.20:80}

     

     

    If I call PoolMember->set_monitor_state() for pool_1, member 10.10.10.10:80 with a state of STATE_DISABLED, it shows as forced down only in pool_1, not in pool_2 in both iControl and the GUI.

     

     

    This could be a release-specific issue, but I find it hard to believe since this is fairly basic functionality.

     

     

    -Joe
  • By the way, here is the sample app I used to test it out (in perl).

     

     

    !/usr/bin/perl
    ----------------------------------------------------------------------------
     The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
     Software Development Kit for iControl"; you may not use this file except in
     compliance with the License. The License is included in the iControl
     Software Development Kit.
     Software distributed under the License is distributed on an "AS IS"
     basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
     the License for the specific language governing rights and limitations
     under the License.
     The Original Code is iControl Code and related documentation
     distributed by F5.
     The Initial Developer of the Original Code is F5 Networks,
     Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2004 F5 Networks,
     Inc. All Rights Reserved.  iControl (TM) is a registered trademark of F5 Networks, Inc.
     Alternatively, the contents of this file may be used under the terms
     of the GNU General Public License (the "GPL"), in which case the
     provisions of GPL are applicable instead of those above.  If you wish
     to allow use of your version of this file only under the terms of the
     GPL and not to allow others to use your version of this file under the
     License, indicate your decision by deleting the provisions above and
     replace them with the notice and other provisions required by the GPL.
     If you do not delete the provisions above, a recipient may use your
     version of this file under either the License or the GPL.
    ----------------------------------------------------------------------------
    use SOAP::Lite + trace => qw(method debug);
    use SOAP::Lite;
    use MIME::Base64;
    BEGIN {push (@INC, "..");}
    use iControlTypeCast;
    ----------------------------------------------------------------------------
     Validate Arguments
    ----------------------------------------------------------------------------
    my $sHost = $ARGV[0];
    my $sPort = $ARGV[1];
    my $sUID = $ARGV[2];
    my $sPWD = $ARGV[3];
    my $sPool = $ARGV[4];
    my $sMember = $ARGV[5];
    my $sMemberState = $ARGV[6];
    my $sProtocol = "https";
    if ( ("80" eq $sPort) or ("8080" eq $sPort) )
    {
      $sProtocol = "http";
    }
    if ( ($sHost eq "") or ($sPort eq "") or ($sUID eq "") or ($sPWD eq "") )
    {
      die ("Usage: PoolMember.pl host port uid pwd [pool_name] [pool_member_ip_port] [state]\n");
    }
    ----------------------------------------------------------------------------
     Transport Information
    ----------------------------------------------------------------------------
    sub SOAP::Transport::HTTP::Client::get_basic_credentials
    {
      return "$sUID" => "$sPWD";
    }
    $Pool = SOAP::Lite
      -> uri('urn:iControl:LocalLB/Pool')
      -> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi");
    eval { $Pool->transport->http_request->header
    (
      'Authorization' => 
        'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
    ); };
    $PoolMember = SOAP::Lite
      -> uri('urn:iControl:LocalLB/PoolMember')
      -> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi");
    $PoolMember->transport->http_request->header
    (
      'Authorization' => 
        'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
    );
    if ( "" eq $sPool )
    {
      &listPools();
    }
    elsif ( "" eq $sMember )
    {
      &listMembers($sPool);
    }
    else
    {
      &controlMember($sPool, $sMember, $sMemberState);
    }
    ----------------------------------------------------------------------------
     checkResponse
    ----------------------------------------------------------------------------
    sub checkResponse()
    {
      my ($soapResponse) = (@_);
      if ( $soapResponse->fault )
      {
        print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";
        exit();
      }
    }
    ----------------------------------------------------------------------------
     listPools
    ----------------------------------------------------------------------------
    sub listPools()
    {
      $soapResponse = $Pool->get_list();
      &checkResponse($soapResponse);
      my @pool_list = @{$soapResponse->result};
      print "Available Pools:\n";
      foreach $pool (@pool_list)
      {
        print "  $pool\n";
      }
    }
    ----------------------------------------------------------------------------
     listMembers
    ----------------------------------------------------------------------------
    sub listMembers()
    {
      my ($pool) = (@_);
       Get LBMethods
      $soapResponse = $Pool->get_member
      (
        SOAP::Data->name(pool_names => [$pool])
      );
      &checkResponse($soapResponse);
      my @memberListAofA = @{$soapResponse->result};
      print "Available members for Pool $pool\n";
      foreach $member (@{$memberListAofA[0]})
      {
        $address = $member->{"address"};
        $port = $member->{"port"};
        print "  $address:$port\n";
      }
    }
    ----------------------------------------------------------------------------
     controlMember
    ----------------------------------------------------------------------------
    sub controlMember()
    {
      my ($pool, $member, $state) = (@_);
      $monitor_state = "STATE_ENABLED";
      if ( "" eq $state )
      {
        &displayMember($pool, $member);
      }
      else
      {
        if ( ("disable" eq $state) || ("disabled" eq $state) )
        {
          $monitor_state = "STATE_DISABLED"
        }
        ($addr, $port) = split(/:/, $member, 2);
        $IPPortDefinition = 
        {
          address => $addr,
          port => $port
        };
        $MemberMonitorState = 
        {
          member => $IPPortDefinition,
          monitor_state => $monitor_state
        };
        push @MonitorStateList, [$MemberMonitorState];
        
        $soapResponse = $PoolMember->set_monitor_state
        (
          SOAP::Data->name(pool_names => [$pool]),
          SOAP::Data->name(monitor_states => [@MonitorStateList])
        );
        &checkResponse($soapResponse);
        
        print "member $pool/$member state set to $monitor_state\n";
        
        &displayMember($pool, $member);
      }
    }
    ----------------------------------------------------------------------------
     displayMember
    ----------------------------------------------------------------------------
    sub displayMember()
    {
      my ($pool, $member) = (@_);
       Get Montior State
      $soapResponse = $PoolMember->get_monitor_status
      (
        SOAP::Data->name(pool_names => [$pool])
      );
      &checkResponse($soapResponse);
      
      @MonitorStatusAofA = @{$soapResponse->result};
      @MonitorStatusList = @{$MonitorStatusAofA[0]};
      foreach $monitor_status_entry (@MonitorStatusList)
      {
        $member_def = $monitor_status_entry->{"member"};
        $addr = $member_def->{"address"};
        $port = $member_def->{"port"};
        $monitor_status = $monitor_status_entry->{"monitor_status"};
        if ( $member eq "$addr:$port" )
        {
          print "Status for member $addr:$port : $monitor_status\n";
        }
      }
    }

     

     

    -Joe