We use cookies on our website to ensure we provide you with the best experience on our website. By using our website, you agree to the use of cookies for analytics and personalized content.This website uses cookies. More Information
It seems like your browser didn't download the required fonts. Please revise your security settings and try again.
Barracuda Load Balancer

Sample Program - Multiple Functions

  • Last updated on

This program uses most of the API calls described in the article API Descriptions. It performs the following functions:

  • Adds a Service and a Real Server;
  • Shows the Service and Real Server state before and after setting the state of the Real Server to maintenance mode;
  • Deletes the Real Server and the Service.

You can copy and paste this code into a file and save it as sample.pl. Edit the IP addresses – should be the WAN IP address of the Barracuda Load Balancer, is the VIP address of a Service, and is the IP address of a Real Server. Change the password to the API password for the Barracuda Load Balancer.

To run sample.pl, at a command prompt type:
perl sample.pl


use strict;
use warnings;

use XML::RPC;
use LWP::UserAgent;
use Data::Dumper;

my $ua = LWP::UserAgent->new ;

$ua->timeout( 60 ) ;

# Create the XML::RPC object
my $xmlrpc = XML::RPC->new (
            'lwp_useragent' => $ua );
my $result;

#Add a Service
$result = $xmlrpc->call('service.add',
print Dumper ($result);

#Add a Real Server
$result = $xmlrpc->call('server.add',
      {vip=>'',ip => '',port => '21'});
print Dumper ($result);

my $service_show = 'status/state' ;
#Show all Services and Real Servers state
$result = $xmlrpc->call('service.show', {show=> $service_show});

print Dumper ($result);

#Change Real Server status to maintenance mode (could be one of disable/enable/maintenance)
$result = $xmlrpc->call('server.change_state',
    ip => '',
print Dumper ($result);

#Show Service status and Real Server state

$result = $xmlrpc->call('service.show',
    port=> '21', ip=> '',
    show=> $service_show});
print Dumper ($result);

#Delete the Real Server
$result = $xmlrpc->call('server.delete',
    ip => '',
    port => '21'});
print Dumper ($result);

#Delete the Service
$result = $xmlrpc->call('service.delete',
print Dumper ($result);


Related Articles
Last updated on