Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device.
Atlassian cookies and tracking notice, (opens new window)
Atlassian uses cookies to improve your browsing experience, perform analytics and research, and conduct advertising. Accept all cookies to indicate that you agree to our use of cookies on your device. Atlassian cookies and tracking notice, (opens new window)
🔍 Discover Our Product Documentation

Barracuda Load Balancer
Results will update as you type.
  • What's New in the Barracuda Load Balancer
  • Deployment Options
  • Getting Started
  • Services
  • Traffic Management
  • Global Server Load Balancing
  • Networking
  • Certificate Management
  • Monitoring
  • Maintenance
  • Tools and Add-Ins
  • APIs
    • Automation API Guide
      • API Descriptions
      • Sample Program - Changing Real Server Status to Maintenance Mode
      • Sample Program - Multiple Functions
  • Barracuda Load Balancer Hardware
  • Downloads

    You‘re viewing this with anonymous access, so some content might be blocked.
    /
    Sample Program - Multiple Functions
    Updated Jan 08

    Sample Program - Multiple Functions

    Jan 08, 2026
    Subscribe

    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 – 10.5.126.63 should be the WAN IP address of the Barracuda Load Balancer, 192.168.132.214 is the VIP address of a Service, and 15.15.15.11 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

    sample.pl

    #!/usr/bin/perl
    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 (
                'https://10.5.126.63/cgi-mod/api.cgi?password=admin',
                'lwp_useragent' => $ua );
    my $result;

    #Add a Service
    $result = $xmlrpc->call('service.add',
          {name=>'xml_rpc_test',
          vip=>'192.168.132.214',
          protocol=>'TCP',
          port=>'21',
          type=>'L4'});
    print Dumper ($result);

    #Add a Real Server
    $result = $xmlrpc->call('server.add',
          {vip=>'192.168.132.214:21:TCP',ip => '15.15.15.11',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',
        {vip=>'192.168.132.214:21:TCP',
        port=>'21',
        ip => '15.15.15.11',
        action=>'maintenance'});
    print Dumper ($result);

    #Show Service status and Real Server state

    $result = $xmlrpc->call('service.show',
        {vip=>'192.168.132.214:21:TCP',
        port=> '21', ip=> '15.15.15.11',
        show=> $service_show});
    print Dumper ($result);

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

    #Delete the Service
    $result = $xmlrpc->call('service.delete',
        {vip=>'192.168.132.214',
        port=>'21',
        protocol=>'TCP'});
    print Dumper ($result);

     

    Related Articles
    • Automation API Guide

    • API Descriptions

    • Sample Program - Changing Real Server Status to Maintenance Mode


    We value your feedback.
    If you have questions, suggestions, or feedback on our documentation, contact the Campus Product Documentation team.
    For general product inquiries or technical support, please contact the global Barracuda Support team.

    {"serverDuration": 11, "requestCorrelationId": "6979f71c32b0451198b1a4427b6921f4"}