Forum Discussion

Michel_van_der_'s avatar
Michel_van_der_
Icon for Nimbostratus rankNimbostratus
Jun 04, 2003

Another SOAP::Lite newbie question

How would I go about translating some predefined constants,

such as
ITCMLocalLB.LBMethod
?

Looking through the wsdl file, it would appear this is only defined

with documentation, not in anyway by which I could translate e.g.

'predictive_member' to '7'. stubmaker.pl was no help.

Thoughts?
  • Thanks. I'll do something similar to what you suggest, obviously a simple

     

    back-forth mapping is easy to accomplish.

     

     

    Thanks.
  • There are several ways to go about this. We've used both of them in the SDK sample code.

     

     

    In sdk/support/SOAP/LocalLB/LocalLBPool.pl we used a hash map to convert values to names

     

     

     
     my $LBMethodMap = 
         { 
             0 => "Round Robin", 
             1 => "Ratio", 
             2 => "Fastest", 
             3 => "Least Connections", 
             4 => "Ratio Member", 
             5 => "Least Connections Member", 
             6 => "Observed Member", 
             7 => "Predictive Member", 
             8 => "Observed Node Address", 
             9 => "Predictive Node Address", 
             10 => "Dynamic Ratio", 
         }; 
      
     And reference it in the code as like list 
     ---------------------------------------------------------------------------- 
      Get the load balancing method for the given pool 
     ---------------------------------------------------------------------------- 
     sub getPoolLBMethod() 
     { 
         my ($poolName) = @_; 
         my $lbMethod; 
         my $soap_response = 
             $soap->get_lb_method 
             ( 
                 SOAP::Data->name ( pool_name => $poolName ) 
             ); 
         if ( $soap_response->fault ) 
         { 
             print $soap_response->faultcode, "\n"; 
             print $soap_response->faultstring, "\n"; 
             exit(""); 
         } 
         else 
         { 
             $lbMethod = $soap_response->result; 
         } 
         return $LBMethodMap->{$lbMethod}; 
     } 
     

     

     

    You could also create global variables and reference them accordingly.

     

     
     my $LB_METHOD_ROUND_ROBIN = 0; 
     my $LB_METHOD_RATIO = 1; 
     my $LB_METHOD_FASTEST = 2; 
     my $LB_METHOD_LEAST_CONN = 3; 
     my $LB_METHOD_RATIO_MEMBER = 4; 
     my $LB_METHOD_LEAST_CONN_MEMBER = 5; 
     my $LB_METHOD_OBSERVED_MEMBER = 6; 
     my $LB_METHOD_PREDICTIVE_MEMBER = 7; 
     my $LB_METHOD_OBSERVED_NODE_ADDR = 8; 
     my $LB_METHOD_PREDICTIVE_NODE_ADDR = 9; 
     my $LB_METHOD_DYNAMIC_RATIO = 10; 
      
     my $soap_response = 
         soap->set_lb_method 
             ( 
                 SOAP::Data->name ( pool_name => $poolName ), 
                 SOAP::Data->name ( lb_method => $LB_METHOD_ROUND_ROBIN) 
             ); 
     

     

     

    -Joe
  • Guess I didn't make myself very clear. If those numbers ever change, my

     

    code would break. It would be nice if I could pick up the numbers by name (and if the code

     

    could actually be generated from the wsdl file and by extension get that done).

     

     

    I saw the code, but it seems a little hokey to have it defined in the wsdl file, on the F5 device,

     

    etc.

     

     

    Random thoughts, as usual.