Forum Discussion

Ramya_68133's avatar
Ramya_68133
Icon for Nimbostratus rankNimbostratus
Sep 23, 2013

Get _object status

Hi Joe Pruitt ,

 

I just tried to add one more method along get_member_v2 to pull all the details like address,port, availability , status along with get_object status and I dont see anything getting returned. Any suggestions on my code

 

my $poollist =
  $LBPool->get_member_v2(
    SOAP::Data->name( pool_names => [$poolname] ) );
  checkResponse($poollist);
  my @poolmemberdefinitionAofA = @{ $poollist->result };
  my $soapResponse =
     $LBPool->get_member_object_status(
       SOAP::Data->name( pool_names => [$poolname], members => [@poolmemberdefinitionAofA] ) );

  print $soapResponse;
  my %members;
  my @statusAofA = @{ $soapResponse->result };
  my @statusA = @{ $statusAofA[0] };
  foreach my $status (@statusA) {
    $members{ $status->{"address"}} =  $status->{"port"};
    $members{'enabled'} = {$status->{'enabled_status'}};
    $members{'availability'} = {$status->{'availability'}};
  }
  return \%members;
}

2 Replies

  • Ok, had to look at it twice... For parameters, you need to wrap them all with individual "SOAP::Data" elements. Your calling code to get_member_object_status() should look something like this:

     

    my $soapResponse = $LBPool->get_member_object_status(
      SOAP::Data->name(pool_names => [$poolname]),
      SOAP::Data->name(members => [@poolmemberdefinitionAofA])
    );
    &checkResponse($soapResponse);

    See if that gets you any further...

     

    -Joe

     

  • The Address and Port is not part of the ObjectStatus structure returned from the get_member_object_status() method. You have that information that you passed in with the members parameter. Here's a chunk of code that goes from getting the pool list with get_list(), getting the members with get_members_v2(), getting the object status with get_member_object_status(), and then prints out the results.

     

    my $soapResponse = $Pool->get_list();
    &checkResponse($soapResponse);
    my @pool_list = @{$soapResponse->result};
    
     Get a list of pool members
    $soapResponse = $Pool->get_member_v2
    (
      SOAP::Data->name(pool_names => [@pool_list])
    );
    &checkResponse($soapResponse);
    my @member_lists = @{$soapResponse->result};
    
     Query member object status
    $soapResponse = $Pool->get_member_object_status(
      SOAP::Data->name(pool_names => [@pool_list]),
      SOAP::Data->name(members => [@member_lists])
    );
    &checkResponse($soapResponse);
    my @MemberObjectStatusAofA = @{$soapResponse->result};
    
     Print out summary
    for $i (0 .. $pool_list)
    {
      my $pool = @pool_list[$i];
      my @memberA = @{$member_lists[$i]};
      my @memberObjectStatusA = @{$MemberObjectStatusAofA[$i]};  
    
      print "POOL $pool\n";
    
      for $j (0 .. $memberA)
      {
        my $member = @memberA[$j];
        my $addr = $member->{"address"};
        my $port = $member->{"port"};
    
        my $memberObjectStatus = @memberObjectStatusA[$j];
        my $availability_status = $memberObjectStatus->{"availability_status"};
        my $enabled_status = $memberObjectStatus->{"enabled_status"};
        my $status_description = $memberObjectStatus->{"status_description"};
    
        print "+ MEMBER ${addr}:${port}\n";
        print "  | AVAILABILITY : ${availability_status}\n";
        print "  | ENABLED      : ${enabled_status}\n";
        print "  | DESCRIPTION  : ${status_description}\n";
      }
    }

    Running the above code, prints the following results:

     

    POOL /Common/p.prd.app1
    + MEMBER /Common/10.10.10.10:80
      | AVAILABILITY : AVAILABILITY_STATUS_BLUE
      | ENABLED      : ENABLED_STATUS_ENABLED
      | DESCRIPTION  : Pool member does not have service checking enabled
    + MEMBER /Common/10.10.10.11:80
      | AVAILABILITY : AVAILABILITY_STATUS_BLUE
      | ENABLED      : ENABLED_STATUS_ENABLED
      | DESCRIPTION  : Pool member does not have service checking enabled
    POOL /Common/p.prd.app2
    + MEMBER /Common/10.10.10.20:80
      | AVAILABILITY : AVAILABILITY_STATUS_RED
      | ENABLED      : ENABLED_STATUS_ENABLED
      | DESCRIPTION  : Pool member has been marked down by a monitor
    + MEMBER /Common/10.10.10.21:80
      | AVAILABILITY : AVAILABILITY_STATUS_GREEN
      | ENABLED      : ENABLED_STATUS_ENABLED
      | DESCRIPTION  : Pool member is available

    Hope this is enough to get you going...

     

    -Joe