Forum Discussion
Brian_Herr_1028
Nimbostratus
Dec 07, 2004Perl: How to get the values of enumerated types
It seems that any enumerated value queried using SOAP::Lite and iControlTypeCast.pm (from the SDK) returns the value of 1.
I'm not able to get any value other than 1 from LocalLB/PoolMe...
Dec 07, 2004
Here's the prototype for the LocalLB::PoolMember::get_object_status
method.
struct IPPortDefinition {
String address;
long port
};
struct ObjectStatus {
AvailabilityStatus availability_status;
EnabledStatus enabled_status;
String status_description;
};
struct MemberObjectStatus {
IPPortDefinition member;
ObjectStatus object_status;
};
MemberObjectStatus[][] get_object_status(
in String[] pool_names
);
The method takes as input an array of pool names and returns a two dimensional array. This is an array of pool member object status for each pool passed in. Thus you need to peel off both layers of this array to get at the data.
Here's some code that illustrates the usage (feel free to change the way the arrays are accessed, etc). It takes as input an array of pool names and prints out the object status of the members in those pools.
----------------------------------------------------------------
getMemberStatus
----------------------------------------------------------------
sub getMemberStatus()
{
my @pool_list = @_;
$soapResponse = $PoolMember->get_object_status
(
SOAP::Data->name(pool_names => [@pool_list])
);
&checkResponse($soapResponse);
@MemberObjectStatusAofA = @{$soapResponse->result};
Loop over pools
for $i ( 0 .. $MemberObjectStatusAofA )
{
print "Member status for pool @pool_list[$i]\n";
Loop over pool members within the pool
$MemberObjectStatusArray = $MemberObjectStatusAofA[$i];
for $j ( 0 .. ${$MemberObjectStatusArray} )
{
$MemberObjectStatus = $MemberObjectStatusAofA[$i][$j];
$member = $MemberObjectStatus->{"member"};
$address = $member->{"address"};
$port = $member->{"port"};
$object_status = $MemberObjectStatus->{"object_status"};
$availability_status = $object_status->{"availability_status"};
$enabled_status = $object_status->{"enabled_status"};
$status_description = $object_status->{"status_description"};
print "\tMember: $address:$port\n";
print "\t\tavailability: $availability_status\n";
print "\t\tenabled: $enabled_status\n";
print "\t\tdescription: $status_description\n";
}
}
}
If you need a good primer for multi-dimensional arrays, check this document out.
BTW, all enums in 9.0 are now by string value which should make them much easier to work with.
-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