Brocade Virtual ADX XML API Programmer’s Guide (Supporting ADX v03.1.00) User Manual

Page 825

Advertising
background image

Brocade Virtual ADX XML API Programmer’s Guide

815

53-1003248-01

Example: Adding and binding a real server and a VIP

B

my $context = ""; # When passed through command line options, overrides the

context used in the script

# Get the command arguments and check if any of the parameters must be overridden

by user specified values

# Command Line Usage:

# perl Usecase1.pl [--dut=ADX IP] [--username=ADX Login Username]

[--password=password] [--context=Context Name] [--transport=http/https]

GetOptions (

"dut:s" => \$dut,

"username:s" => \$username,

"password:s" => \$password,

"context:s" => \$context,

"transport:s" => \$transport

);

# Use the stored values if they are not meant to be overridden

# Values can be hard-coded here too, instead of passing in CLI

$dut = "10.37.53.198" if ($dut eq "");

$username = "admin" if ($username eq "");

$password = "brocade" if ($password eq "");

$context= "" if ($context eq "");

$transport = "http" if ($transport eq "");

# Create a SOAP Object to connect to the SOAP Service on the DUT

my $slbsoap = SOAP::Lite->new (proxy => "$transport://$dut/WS/SLB");

my $syssoap = SOAP::Lite->new (proxy => "$transport://$dut/WS/SYS");

# Transport header with network credential

eval

{

$slbsoap->transport->http_request->header('Authorization:' => 'Basic ' .

encode_base64("$username:$password"));

$syssoap->transport->http_request->header('Authorization:' => 'Basic ' .

encode_base64("$username:$password"));

};

# Set the URN and other properties of the SOAP Objects

$slbsoap->uri('urn:webservicesapi');

$slbsoap->ns('urn:webservicesapi', 'urn');

$slbsoap->outputxml('true'); # Set this to false if SOM object is required instead

of XML output.

$slbsoap->envprefix('slbsoapenv');

$slbsoap->encprefix('slbsoapenc');

$slbsoap->autotype (0);

$syssoap->uri('urn:webservicesapi');

$syssoap->ns('urn:webservicesapi', 'urn');

$syssoap->outputxml('true'); # Set this to false if SOM object is required instead

of XML output.

$syssoap->envprefix('slbsoapenv');

$syssoap->encprefix('slbsoapenc');

$syssoap->autotype (0);

my $request_time;

my $response_time;

my $xml_result;

# Build the SOAP Header using the Context Name

my $slbsoap_header = SOAP::Header->name('urn:RequestHeader' =>

\SOAP::Header->value(SOAP::Header->name('context' => "$context")));

#### Create a Real Server ####

Advertising