Programmer's Guide (Supporting ADX v03.1.00) Manual

Brocade Virtual ADX XML API Programmer’s Guide 813
53-1003248-01
Appendix
B
API Examples
In this appendix
“Example: Adding and binding a real server and a VIP”
“Example: Unbinding a real server from a VIP”
“Example - Provisioning real and virtual servers”
“Example - Binding a real server port to a virtual server port and saving to the startup
configuration file”
Example: Adding and binding a real server and a VIP
“Perl example”
“Java Example”
“C# example”
Perl example
#!/usr/bin/perl -w
# Path to PERL Interpreter - Replace with correct path if different from the one
used above
# Open the Test Case LOG File
open LOG,">Usecase1.log";
# Pre-Requisite PERL Modules
# Install the SOAP and other PERL Modules from CPAN if not pre-installed
(http://perl-begin.org/topics/cpan/life-with-cpan/)
use strict;
use Getopt::Long;
use MIME::Base64;
use XML::Simple;
import SOAP::Data q(name);
import SOAP::Header;
use Time::HiRes q(gettimeofday);
use XML::Twig;
# This is used to capture the SOP Request & Response Data. Do Not Change
use SOAP::Lite +trace => [ transport =>
sub
{
# This is a callback function that will be called just before
# a request is sent and immediately after a response is received
# we will use it to log all SOAP XML to and from the server
my ($http_object) = @_;
# We will either get a HTTP::Request object or a HTTP::Response object