HI,
I have to update one existing pm script with the new api. and had to print the bigip pool members in below format .
'/Common/10.116.38.51', 10.116.38.51:1935, enabled:ENABLED, availability:GREEN
'/Common/10.116.38.52', 10.116.38.52:1935, enabled:ENABLED, availability:GREEN
I have main .pm program code like below
sub locallb_get_member_v2 {
my $ENABLED_STATUS_MAP = { "ENABLED_STATUS_NONE" => "NONE", "ENABLED_STATUS_ENABLED" => "ENABLED", "ENABLED_STATUS_DISABLED" => "DISABLED", "ENABLED_STATUS_DISABLED_BY_PARENT" => "DISABLED_BY_PARENT", };
my $AVAILABILITY_STATUS_MAP = { 'AVAILABILITY_STATUS_NONE' => 'Error scenario', 'AVAILABILITY_STATUS_GREEN' => 'GREEN', 'AVAILABILITY_STATUS_YELLOW' => 'YELLOW', 'AVAILABILITY_STATUS_RED' => 'RED', 'AVAILABILITY_STATUS_BLUE' => 'BLUE', 'AVAILABILITY_STATUS_GRAY' => 'GRAY', };
my @member_lists = @{$soapResponse->result};
my @memberobjectstatus = @{$soapResponse->result};
my @status = @member_lists;
use data:dumper;
push (@status,@memberobjectstatus);
print dumper (@staus);
my %members;
foreach my $member (@status){
$members{ $status->{'address'} = $member->{'port'}};
$members{ $status}->{'enabled'} = $ENABLED_STATUS_MAP->{ $status->{'enabled_status'} } ;
$members{ $status}->{'availability'} = $AVAILABILITY_STATUS_MAP->{ $status->{'availability_status'} } ;
return \%members; }
print Dumper(@status)
Main CGI
my $membershref =
$bigip->locallb_get_member_v2( $bigip_host,
$pool );
if ( !$membershref ){
printError("Failed to find members for $pool");
}
else {
# if ( !$membershref );
print '<UL>'; # Pool Members
foreach my $member ( sort keys %{$membershref} ) {
print li(
"'$member', $membershref->{$member}->{'address'}:$membershref->{$member}->{'port'},
enabled:$membershref->{$member}->{'enabled'}, availability:$memb
ershref->{$member}->{'availability'}"
);
}
print '</UL>'; # End Pool members
IT just returns 'HASH(0xc61b00)', :, enabled:, availability:
I tried to add pint statement in the .pm file and trie dto see the object below is what I got
print dumper (@staus);
OUTPUT $VAR1 = bless( [ bless( { 'address' => '/Common/10.116.38.51', 'port' => '80' }, 'Common::AddressPort' ), bless( { 'address' => '/Common/10.116.38.52', 'port' => '80' }, 'Common::AddressPort' ) ], 'Common::AddressPort[]' ); $VAR2 = bless( [ bless( { 'availability_status' => 'AVAILABILITY_STATUS_GREEN', 'status_description' => 'Pool member is available', 'enabled_status' => 'ENABLED_STATUS_ENABLED' }, 'LocalLB::ObjectStatus' ), bless( { 'availability_status' => 'AVAILABILITY_STATUS_GREEN', 'status_description' => 'Pool member is available', 'enabled_status' => 'ENABLED_STATUS_ENABLED' }, 'LocalLB::ObjectStatus' ) ], 'LocalLB::ObjectStatus[]' );
I have to update one existing pm script with the new api. and had to print the bigip pool members in below format .
'/Common/10.116.38.51', 10.116.38.51:1935, enabled:ENABLED, availability:GREEN
'/Common/10.116.38.52', 10.116.38.52:1935, enabled:ENABLED, availability:GREEN
I have main .pm program code like below
sub locallb_get_member_v2 {
my $ENABLED_STATUS_MAP = { "ENABLED_STATUS_NONE" => "NONE", "ENABLED_STATUS_ENABLED" => "ENABLED", "ENABLED_STATUS_DISABLED" => "DISABLED", "ENABLED_STATUS_DISABLED_BY_PARENT" => "DISABLED_BY_PARENT", };
my $AVAILABILITY_STATUS_MAP = { 'AVAILABILITY_STATUS_NONE' => 'Error scenario', 'AVAILABILITY_STATUS_GREEN' => 'GREEN', 'AVAILABILITY_STATUS_YELLOW' => 'YELLOW', 'AVAILABILITY_STATUS_RED' => 'RED', 'AVAILABILITY_STATUS_BLUE' => 'BLUE', 'AVAILABILITY_STATUS_GRAY' => 'GRAY', };
my @member_lists = @{$soapResponse->result};
my @memberobjectstatus = @{$soapResponse->result};
my @status = @member_lists;
use data:dumper;
push (@status,@memberobjectstatus);
print dumper (@staus);
my %members;
foreach my $member (@status){
$members{ $status->{'address'} = $member->{'port'}};
$members{ $status}->{'enabled'} = $ENABLED_STATUS_MAP->{ $status->{'enabled_status'} } ;
$members{ $status}->{'availability'} = $AVAILABILITY_STATUS_MAP->{ $status->{'availability_status'} } ;
return \%members; }
print Dumper(@status)
Main CGI
my $membershref =
$bigip->locallb_get_member_v2( $bigip_host,
$pool );
if ( !$membershref ){
printError("Failed to find members for $pool");
}
else {
# if ( !$membershref );
print '<UL>'; # Pool Members
foreach my $member ( sort keys %{$membershref} ) {
print li(
"'$member', $membershref->{$member}->{'address'}:$membershref->{$member}->{'port'},
enabled:$membershref->{$member}->{'enabled'}, availability:$memb
ershref->{$member}->{'availability'}"
);
}
print '</UL>'; # End Pool members
IT just returns 'HASH(0xc61b00)', :, enabled:, availability:
I tried to add pint statement in the .pm file and trie dto see the object below is what I got
print dumper (@staus);
OUTPUT $VAR1 = bless( [ bless( { 'address' => '/Common/10.116.38.51', 'port' => '80' }, 'Common::AddressPort' ), bless( { 'address' => '/Common/10.116.38.52', 'port' => '80' }, 'Common::AddressPort' ) ], 'Common::AddressPort[]' ); $VAR2 = bless( [ bless( { 'availability_status' => 'AVAILABILITY_STATUS_GREEN', 'status_description' => 'Pool member is available', 'enabled_status' => 'ENABLED_STATUS_ENABLED' }, 'LocalLB::ObjectStatus' ), bless( { 'availability_status' => 'AVAILABILITY_STATUS_GREEN', 'status_description' => 'Pool member is available', 'enabled_status' => 'ENABLED_STATUS_ENABLED' }, 'LocalLB::ObjectStatus' ) ], 'LocalLB::ObjectStatus[]' );