Forum Discussion
mfreeman451_606
Nimbostratus
Apr 22, 2009problem using LocalLB.Pool.add_member
I'm having trouble trying to add a member to an existing pool. The code I have seems to run fine with no errors, but when I login to the F5 through the GUI I don't see my new member showing up in the pool.
I read the previous topic regarding this and tried the same stuff you guys had suggested and I get the same result, code runs but it doesn't appear to be added.
Here is the code:
test.pl:
my $members = {
member =>
{ address => '10.0.0.1',
port => '80'
},
};
my $member = { address => "10.0.0.1", port => 80 };
my $pool_name = 'pool_mfreeman';
my $res = $local_pool->add_pool_member(
names => $pool_name,
member => $members,
) or die "Couldn't add pool member $pool_name\n";
Module.pm:
sub add_pool_member {
my $self = shift;
my %args = @_;
my $pool_names = $args{'names'};
my $member = $args{'member'};
my $pool = $self->{'object'};
my $soap_response = $pool->add_member(
SOAP::Data->name( pool_names => $pool_names ),
SOAP::Data->name( members => [$member] ),
);
die "Bad SOAP response!" unless ($self->check_response($soap_response));
print "Added pool member\n";
print Dumper($member) . "\n";
print "==\n";
}
Result:
Added pool member
$VAR1 = {
'member' => {
'address' => '172.16.144.198',
'port' => '80'
}
};
==
Called with URN: urn:iControl:LocalLB/Pool
--
Thoughts?
5 Replies
- mfreeman451_606
Nimbostratus
Here is some debug output. I thought maybe the same thing happening here http://devcentral.f5.com/Default.aspx?tabid=53&forumid=1&tpage=1&view=topic&postid=1961619617 was happening to me, but I see that my soapEnc type is an array?
−
−
pool_mfreeman
−
−
−
10.0.0.1
80 - mfreeman451_606
Nimbostratus
looks like i just needed:
pool_names => [$pool_names]
I didn't think it needed it in list context since it was just a string.. maybe the docs are broken or I'm tired :> - Actually, I don't think that code will work either as you are only passing in a 1-d array for the members. The prototype for the methods is:
LocalLB.PoolMember.add_member( in String [] pool_names, in Common__IPPortDefinition [] [] members );
pool_names is a 1-d array of pools you want to add members to. members is a 2-d array of members to add (one for each pool in the pool_names array).
I just whipped up a script that will add a addr:port to a pools member list.http://devcentral.f5.com/Wiki/default.aspx/iControl/PerlAddPoolMember.html
Click here
Hope this helps...
-Joe - mfreeman451_606
Nimbostratus
This code is working perfect and I don't need to do all that stuff with creating temporary arrays or whatever..
Either way, it looks like both of our ways work.
add a member to a pool
my $members = {
member =>
{ address => '10.10.138.254',
port => '22'
},
member2 =>
{ address => '10.10.138.253',
port => '22'
},
};
my $res = $local_pool->add_pool_member(
names => $pool_name,
member => $members,
) or die "Couldn't add pool member $pool_name\n";
sub add_pool_member {
my $self = shift;
my %args = @_;
my $pool_names = $args{'names'};
my $member = $args{'member'};
my $pool = $self->{'object'};
my $soap_response = $pool->add_member(
SOAP::Data->name( pool_names => [$pool_names] ),
SOAP::Data->name( members => [$member] ),
);
die "Bad SOAP response!" unless ($self->check_response($soap_response));
} - Good deal, glad it's working. Figured the full script might help others as well.
-Joe
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
