Forum Discussion
sean_87481
Nimbostratus
Jan 12, 2009Getting VS list with name, address, port
Hello!
In perl, I am able to successfully use the get_list() method to get a list of virtual servers, but I want to pull out the address and port information as well.
It seems that the VirtualServer->get_list() method only returns a list of names, and there doesn't seem to be an input parameter to pass in.
Any suggestions? I've been fiddling with it a while now, and am not making any headway. (NOTE: icontrol newbie).
Thanks,
Sean Swift
3 Replies
- Virtual Servers are identified by their user friendly screen names. The get_list() method returns that list of names. If you want to get the destination for the virtual (ip and port), then you'll want to pass a list of virtual names that you want to query into the LocalLB.VirtualServer.get_destination() method.
http://devcentral.f5.com/wiki/default.aspx/iControl/LocalLB__VirtualServer__get_destination.html
Click here
Most of our methods work this way. There are get_list types methods to return all the objects and then you'll pass that into the various accessor methods (get_* and set_*) to retrieve the attributes of the object.
Some code (not perl) for the get_destination() method can be found in this post:http://devcentral.f5.com/Default.aspx?tabid=53&forumid=1&postid=31065&view=topic
Click here
Feel free to post again if you need help the fun and games that is Perl B-).
-Joe - sean_87481
Nimbostratus
Okay, so here's my code snippet:
$soapResponse = $VirtualServer->get_list();
@g_vs_list = @{$soapResponse->result};
$stuff=$VirtualServer->get_destination(
SOAP::Data->name( virtual_servers => \@g_vs_list )
);
print "Address: " . $stuff[0][0] . "\n";
I'm definitely getting the results back, because $stuff is the correct size (number of entries). I think I'm just not accessing the subelements correctly.
The definitely says that a struct (which is an array) is returned. I'm assuming that the struct is returned in an array, so to access the first element address is $stuff[0][0] and port would be $stuff[0][1]. I also tried $stuff[0]->{"address"}, but that didn't work either.
Any suggestions?
Sean - You'll likely want to cast $stuff to an array
$soapResponse = $VirtualServer->get_destination( SOAP::Data->name(virtual_servers => [@g_vs_list]) ); @dest_list = @{$soapResponse->result}; foreach $IPPortDef (@dest_list) { $addr = $IPPortDef->{"address"}; $port = $IPPortDef->{"port"}; print "$addr:$port\n"; }
I don't have access to my BIG-IP to test this out right now so I'm not sure if there are any typo. But I did find one of my old scripts that uses that method. I just added it to the iControl CodeShare.http://devcentral.f5.com/wiki/default.aspx/iControl/PerlVirtualShow.html
url]http://devcentral.f5.com/wiki/default.aspx/iControl/PerlVirtualShow.html">Click here
Hopefully that gives you enough to go by.
-Joe
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
