Forum Discussion

kennemt_50219's avatar
kennemt_50219
Icon for Nimbostratus rankNimbostratus
Sep 20, 2011

set_priority (perl)

Hey all,

I'm fairly new to iControl, and I'm trying to write a perl script to dynamically alter member priorities in . I'm working with LTM version 10.2.1 so I have to use the PoolMember interface rather than Pool. Using scripts from codeshare as a model, this is the meat of what I've come up with. Unfortunately, although it doesn't throw any errors, it also doesn't appear to do anything. Can anybody tell me what I'm missing?

$Pool = SOAP::Lite
  -> uri('urn:iControl:LocalLB/PoolMember')
  -> proxy("$sProtocol://$ichost/iControl/iControlPortal.cgi");
$Pool->transport->http_request->header (
  'Authorization' => 'Basic ' . MIME::Base64::encode("$UID:$PWD", '')
);


my $member = {
  address => "10.100.125.18",
  port => "443"
};

my $member_priority = (
  member => $member,
  priority => "2"
);

push @memberPriorityList, $member_priority;
push @memberPriorityLists, @memberPriorityList;

$soapResponse = $Pool->set_priority (
  SOAP::Data->name(pool_names => ["testpool-443"]),
  SOAP::Data->name(priorities => [@memberPriorityLists])
);

4 Replies

  • My code formatting seems to have gotten mangled, going to try again for readability.

     

     

    $Pool = SOAP::Lite -> uri('urn:iControl:LocalLB/PoolMember') -> proxy("$sProtocol://$ichost/iControl/iControlPortal.cgi");

     

     

    $Pool->transport->http_request->header ( 'Authorization' => 'Basic ' . MIME::Base64::encode("$UID:$PWD", '') );

     

     

    my $member = { address => "10.100.125.18", port => "443" };

     

     

    my $member_priority = ( member => $member, priority => "2" );

     

     

    push @memberPriorityList, $member_priority;

     

    push @memberPriorityLists, @memberPriorityList;

     

     

    $soapResponse = $Pool->set_priority ( SOAP::Data->name(pool_names => ["testpool-443"]), SOAP::Data->name(priorities => [@memberPriorityLists]) );
  • Perl can be somewhat odd when it comes to casting arrays, especially when dealing with the SOAP::Lite module and their internal types. Try casting the second array and see if that makes a difference.

    Also, I notice you used parenthesis instead of curly braces when defining the member_priority variable. Not sure if that will work or not.

    Try something like this:

    my $member = { address => "10.100.125.18", port => "443" };
    my $member_priority = { member => $member, priority => "2" };
    push @memberPriorityList, $member_priority;
    push @memberPriorityLists, [@memberPriorityList];
    $soapResponse = $Pool->set_priority(
      SOAP::Data->name(pool_names => ["testpool443"]),
      SOAP::Data->name(priorities => [@MemberPriorityLists])
    );

    Note: I haven't tested this but I'm pretty sure that's the issue.

    You can always turn on SOAP::Lite debugging with:

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

    It will print out the request and response SOAP/XML messages that can help determine whether something is being cast correctly.

    Hope this helps!

    -Joe

  • Sure enough, I made those changes and that seemed to fix it. Thanks for pointing those out!