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

Page 824

Advertising
background image

814

Brocade Virtual ADX XML API Programmer’s Guide

53-1003248-01

Example: Adding and binding a real server and a VIP

B

if (ref($http_object) eq "HTTP::Request")

{

# We have a Request object. We need to make it pretty for log readability

my $content = $http_object->content;

my $twig = XML::Twig->new(pretty_print=>'indented');

$twig->parse($content);

$content = $twig->sprint;

print LOG "\nSOAP Request\n------------\n" . $content . "\n\n";

}

elsif (ref($http_object) eq "HTTP::Response")

{

# We have a Response object.

print LOG "SOAP Response\n-------------\n" . $http_object->content . "\n";

}

}];

# Function to record the time at the start of a SOAP Request.

# Do Not Change

sub start_timer

{

#Get the Seconds and Microseconds

my ($st_sec,$st_usec) = gettimeofday();

return "$st_sec:$st_usec";

}

# Function to return the elapsed time after a SOAP Response is recieved

# Do Not Change

sub get_elapsed_time

{

my ($end_sec,$end_usec) = gettimeofday();

my $start_time = shift;

my $exec_time = "";

my ($st_sec,$st_usec) = split(/:/,$start_time);

my $total_seconds = $end_sec - $st_sec;

my $total_useconds = $end_usec - $st_usec;

my $total_mseconds = $total_useconds / 1000;

$total_mseconds =~ /(\d+)\.(\d+)/;

if ($total_seconds < 60)

{

$exec_time = "0m $total_seconds" ."s " . "$1ms";

}

else

{

my $mins = int($total_seconds / 60);

my $secs = $total_seconds % 60;

$exec_time = "$mins" . "m $secs" ."s " . "$1ms";

}

return $exec_time;

}

# Initialize the parameters that will be used in GetOptions

# Do Not Change

my $dut = ""; # When passed through command line options, overrides the DUT IP

used in the script

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

Username used in the script

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

Password used in the script

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

Transport Type (HTTP/HTTPS) used in the script

Advertising