Forum Discussion

alex_der_101956's avatar
alex_der_101956
Icon for Nimbostratus rankNimbostratus
Apr 21, 2006

get_persistence_record

can someone show me an example of how to use LocalLB::Pool::get_persistence_record in perl?

3 Replies

  • That method takes two arrays in and returns a 2-dimensional array. What issue are you having? Formatting the input arrays, or parsing the output arrays?

     

     

    Here's some code that might get you going. This example requests the persistence records only on a single pool. By requesting the PERSIST_MODE_NONE mode, you will receive all persistence records regardless of the mode.

     

     

     $sPool is defined elsewhere...
    $persistence_mode = "PERSIST_MODE_NONE";
    $soapResponse = $Pool->get_persistence_record
    (
      SOAP::Data->name(pool_names => [$sPool]),
      SOAP::Data->name(persistence_modes => [$persistence_mode])
    );
    &checkResponse($soapResponse);
    @PersistenceRecordLists = @{$soapResponse->result};
    for $i (0 .. $PersistenceRecordLists)
    {
      $PersistenceRecordList = $PersistenceRecordLists[$i];
      foreach $PersistenceRecord ( @{$PersistenceRecordList} )
      {
        $pool_name  = $PersistenceRecord->{"pool_name"};
        $node_server  = $PersistenceRecord->{"node_server"};
        $node_ip = $node_server->{"address"};
        $node_port = $node_server->{"port"};
        $mode  = $PersistenceRecord->{"mode"};
        $persistence_value  = $PersistenceRecord->{"persistence_value"};
        $virtual_server  = $PersistenceRecord->{"virtual_server"};
        $vs_name = $virtual_server->{"name"};
        $vs_address = $virtual_server->{"address"};
        $vs_port = $virtual_server->{"port"};
        $vs_protocol = $virtual_server->{"protocol"};
        $create_time  = $PersistenceRecord->{"create_time"};
        $age  = $PersistenceRecord->{"age"};
        print "Pool ($pool_name); Node ($node_ip:$node_port); ";
        print "Value: ($persistence_value); ";
        print "Virtual ($vs_name - $vs_address:$vs_port - $vs_protocol); ";
        print Create time: ($create_time); Age ($age)\n";
      }
    }

     

     

    *Disclaimer - this hasn't been tested yet.

     

     

    There are many ways to access 2-d arrays. Check out the perllol manpage for more examples:

     

     

    http://www.perl.com/doc/manual/html/pod/perllol.html

     

    Click here

     

     

    -Joe
  • Hi Joe,

     

     

    The problem im having is parsing the output arrays. After trying your example and other methods of accessing the 2D array from the link provided and various books, it always seems to fail at the inner loop.

     

     

    one example:

     

     

    $persistence_mode = "PERSIST_MODE_NONE";

     

    $soapResponse = $Pool->get_persistence_record

     

    (

     

    SOAP::Data->name(pool_names => [@pool_list]),

     

    SOAP::Data->name(persistence_modes => [$persistence_mode])

     

    );

     

    &checkResponse($soapResponse);

     

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

     

     

    print "$PersistenceRecordLists\n";

     

    for $i (0 .. $PersistenceRecordLists)

     

    {

     

    $PersistenceRecordList = $PersistenceRecordLists[$i];

     

    print "$PersistenceRecordList\n";

     

    for $j (0 .. ${$PersistenceRecordList}) {

     

    print "element $i $j is $pool_namestenceRecordList->[$j]\n";

     

    }

     

    }

     

     

    example output:

     

    0

     

    -1

     

     

    Is there something im missing or doing wrong? Any Ideas/help would be greatly appreciated.
  • I don't think you are doing anything wrong. Are you sure that there are values being returned back? I'd try turning on the SOAP debugging

    use SOAP::Lite + trace => qw(method debug);

    It will print out all the SOAP Requests and Responses. If your response looks something like this:

    xmlns:E="http://schemas.xmlsoap.org/soap/envelope/"

    xmlns:A="http://schemas.xmlsoap.org/soap/encoding/"

    xmlns:s="http://www.w3.org/2001/XMLSchema-instance"

    xmlns:y="http://www.w3.org/2001/XMLSchema"

    xmlns:iControl="urn:iControl"

    E:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

    xmlns:m="urn:iControl:LocalLB/Pool">

    s:type="A:Array"

    A:arrayType="iControl:LocalLB.PersistenceRecord[][0]">

    then you have zero persistence records.

    -Joe