Control API Structures

A Structure is a complex datatype that contains several parameters. For example, the key configuration settings for a Virtual Server are represented by a VirtualServer.BasicInfo structure that defines the port, protocol, and default pool for that Virtual Server:

VirtualServer.BasicInfo

 

# This structure contains the basic information for a virtual server. It is used when creating

# a server, or modifying the port, protocol or default pool of a server.

 

struct VirtualServer.BasicInfo {

   # The port to listen for incoming connections on.

   Integer port;

 

   # The protocol that this virtual server handles.

   VirtualServer.Protocol protocol;

 

   # The default pool that traffic to this virtual server will go

   # to.

   String default_pool;

}

This structure contains three elements; an integer (the port number), an enumeration (the protocol: VirtualServer.Protocol) and a string (the name of the default pool).

The method VirtualServer.addVirtualServer() takes a VirtualServer.BasicInfo structure that can be constructed as follows:

my $basicInfo = {

port => '443',

protocol => 'https',

default_pool => 'Server Pool 1'

};

$res = $conn->addVirtualServer( [ $vsName ], [ $basicInfo ] );

If you call the method VirtualServer.getBasicInfo(), it will return a corresponding array of VirtualServer.BasicInfo structures that can be unpacked as follows:

$res = $conn->getBasicInfo( [ $vsName ] );

my $r = @{$res->result}[0];

 

print "Virtual Server $vsName:\n";

print " port $r->{port}, protocol $r->{protocol}, " .

"pool $r->{default_pool}\n";

The following code sample illustrates how to create a virtual server and manage the BasicInfo structure:

#!/usr/bin/perl -w

 

use SOAP::Lite 0.6;

 

# Provide our own Deserializer so to deserialize enums correctly

BEGIN {

package MyDeserializer;

@MyDeserializer::ISA = 'SOAP::Deserializer';

sub typecast {

my( $self, $val, $name, $attrs, $children, $type ) = @_;

if( $type && $type =~ m@http://soap.zeus.com/zxtm/@) {

return $val;

}

return undef;

};

}

 

# This is the url of the Admin Server

my $admin_server = 'https://user:password@hostname:9090';

 

# The virtual server to create

my $vsName = $ARGV[0] or die "No vs specified";

my $conn = SOAP::Lite

-> ns('http://soap.zeus.com/zxtm/1.0/VirtualServer/')

-> proxy("$admin_server/soap")

-> deserializer( MyDeserializer->new )

-> on_fault( sub {

my( $conn, $res ) = @_;

die ref $res?$res->faultstring:$conn->transport->status; } );

# Construct the basic info structure

my $basicInfo = {

port => '443',

protocol => 'https',

default_pool => 'discard'

};

 

$res = $conn->addVirtualServer( [ $vsName ], [ $basicInfo ] );

 

$res = $conn->getBasicInfo( [ $vsName ] );

my $r = @{$res->result}[0];

 

print "Virtual Server $vsName:\n";

print " port $r->{port}, protocol $r->{protocol}, " .

"pool $r->{default_pool}\n";