Configuration API

Command line API

The command line alohactl2 is a utility dedicated to manage load balancing configuration.

Syntax Jump to heading

The syntax for alohactl2 is as follows:

nix
sudo alohactl2 [-S <scope>|-T <transactionid>] <command> [param] [--<attribute> <value>|--reset-<attribute>]
nix
sudo alohactl2 [-S <scope>|-T <transactionid>] <command> [param] [--<attribute> <value>|--reset-<attribute>]

The parameters are as follows.

Parameter Description
<scope> Scope name within which to run the command
<transactionid> Transaction ID to run the command
<command> Command to run
<attribute> List provided by the object type

If a command must be applied through a transaction or a scope, precede any parameter with the following options as appropriate:

  • -S <scope> for a scope
  • -T <transactionid> for a transaction

Note also:

Return codes:

Standard error:

  • Warning / information messages

Attribute output (one attribute per line):

  • + for a configured attribute
  • - if default is used
  • ? if attribute is configured but value is not supported by the current API version

Exit codes Jump to heading

Global errors Jump to heading

Exit Code Description
1 Syntax error/unknown option
2 Missing scope
3 Missing transaction ID
4 Missing transaction ID or scope

Normal errors Jump to heading

Exit Code Description
20 Transaction does not exist
21 Defaults does not exist
22 Object does not exist
23 Object already exists
24 Mandatory parameter not set
25 Invalid parameter value

Lock error Jump to heading

Exit Code Description
100 API is locked, retry later

Apply errors Jump to heading

Exit Code Description
101 Invalid configuration (original is restored)
102 New configuration apply failure (original is restored and re-applied)

Transaction management errors Jump to heading

Exit Code Description
110 Corrupted transaction
111 Unable to create transaction
112 Unable to create transaction module context
113 Unable to prepare commit
114 Unable to backup configuration to attempt a commit
115 Unable to install new configuration

Critical errors Jump to heading

Exit Code Description
120 Unable to restore original configuration
121 Unable to apply original restored configuration
122 Unable to save configuration on flash or sync on a peer

Information Jump to heading

Information Description
Action alohactl parameters
API version version

Scopes Jump to heading

A scope is a portion of the configuration. It is identified by a name composed of alphanumeric characters.

A specific scope name is reserved: root. It can access any configuration which is outside of a scope.

Info

Each scope is independent, which makes the API multitenant.

Info

The HAProxy ALOHA GUI LB Admin tab can modify the root scope only.

It is not possible to list existing scopes through the alohactl2 command.

In a HAProxy configuration, a scope is identified by begin and end tags.

All frontends and backends between these tags are prefixed by the scope name.

Example:

An HAProxy configuration for a scope called bob:

haproxy
defaults bob:l7_begin
frontend bob:newservice
[...]
default_backend bob:newfarm
backend bob:newfarm
[...]
defaults bob:l7_end
haproxy
defaults bob:l7_begin
frontend bob:newservice
[...]
default_backend bob:newfarm
backend bob:newfarm
[...]
defaults bob:l7_end

Create a scope Jump to heading

To create a scope, apply a configuration either atomically or through a transaction to a new scope name.

Delete a scope Jump to heading

To delete a scope, remove all configuration belonging to the scope.

Transactions Jump to heading

Transactions allow multiple configuration changes in one atomic operation.

Each transaction is identified by a unique identifier composed of alphanumeric characters (example: BrwClcc76t).

  • Each request can be executed either atomically or as part of a transaction

  • Both atomic requests and transactions apply only on a single scope

  • An atomic request immediately applies the changes to the files

  • A transaction must be started before issuing a load of requests; then it can be either committed or canceled

  • Canceling a transaction makes no change to files and drops the entire load of requests from the beginning of the transaction

  • Committing a transaction consecutively applies the changes to the files for the entire load of requests from the beginning of the transaction

Info

A transaction must belong to a scope.

Action alohactl2 parameters
list all transaction-list
cancel all transaction-flush
start -S <scope> transaction-begin
commit -T <transactionid> transaction-commit
cancel -T <transactionid> transaction-cancel
run an atomic command in a scope -S <scope> <command> <parameters>
run an atomic command in a transaction -T <transactionid> <command> <parameters>

where:

Variable Description
<scope> scope identifier
<transactionid> transaction unique identifier
<command> and <parameters> actions to perform

When committing a transaction, the following happens:

  1. It creates a working context from current configuration.

  2. It replays all update actions recorded on the transaction identified on the newly recreated context. Next, there are two options:

    • If replay is successful: configuration is locked, validated, applied, and finally unlocked.

    • If an error occurs during the locked phase, it processes a configuration rollback and lock is removed.

L7 farms Jump to heading

Must be applied through a transaction or a scope.

Action alohactl2 parameters
List available L7 farms l7-farm-list
Delete all available L7 farms l7-farm-flush
Display an L7 farm configuration l7-farm-dump <farmname>
Create an L7 farm l7-farm-create <farmname> [--<attribute> <value>]
Update an L7 farm l7-farm-update <farmname> [--<attribute> <value>|--reset-<attribute>]
Delete an L7 farm l7-farm-delete <farmname>

where:

Variable Description
<farmname> name of an L7 farm
<attribute> an L7 farm attribute

L7 servers Jump to heading

Must be applied through a transaction or a scope.

Action alohactl2 parameters
List available servers in an L7 farm l7-server-list <farmname>
Delete all available L7 servers l7-server-flush <farmname>
Display an L7 server configuration l7-server-dump <farmname> <servername>
Create an L7 server l7-server-create <farmname> <servername> [--<attribute> <value>]
Update an L7 server l7-server-update <farmname> <servername> [--<attribute> <value>|--reset-<attribute>]
Delete an L7 server l7-server-delete <farmname> <servername>

where:

Variable Description
<farmname> name of an L7 farm
<servername> name of a L7 server
<attribute> an L7 farm attribute

L7 services Jump to heading

Must be applied through a transaction or a scope.

Action alohactl2 parameters
List available servers in an L7 service l7-service-list <servicename>
Delete all available L7 service l7-service-flush <servicename>
Display an L7 service configuration l7-service-dump <servicename>
Create an L7 service l7-service-create <servicename> [--<attribute> <value>]
Update an L7 service l7-service-update <servicename> [--<attribute> <value>|--reset-<attribute>]
Delete an L7 service l7-service-delete <servicename>

where:

Variable Description
<servicename> name of a L7 service
<attribute> an L7 service attribute

L7 listeners Jump to heading

Must be applied through a transaction or a scope.

Action alohactl2 parameters
List available listeners in an L7 service l7-listener-list <L7 servicename>
Delete all available listeners l7-listener-flush <L7 servicename>
Display an L7 listener configuration l7-listener-dump <L7 servicename> <listenername>
Create an L7 listener l7-listener-create <L7 servicename> <listenername>[--<attribute> <value>]
Update an L7 listener l7-listener-update <L7 servicename> <listenername>[--<attribute> <value>|--reset-<attribute>]
Delete an L7 listener l7-listener-delete <L7 servicename> <listenername>

where:

Variable Description
<servicename> name of a L7 service
<listenername> name of a L7 listener
<attribute> an L7 listener attribute

L7 rules Jump to heading

Must be applied through a transaction or a scope.

Action alohactl2 parameters
List rules by type l7-<objecttype>-<ruletype>-list <objectname>
Delete all rules by type l7-<objecttype>-<ruletype>-flush <objectname>
Display a rule configuration l7-<objecttype>-<ruletype>-show <objectname> <number>
Create a rule l7-<objecttype>-<ruletype>-create <objectname> <number> [--<attribute> <value>]
Update a rule l7-<objecttype>-<ruletype>-update <objectname> <number> [--<attribute> <value>|--reset-<attribute>]
Delete a rule l7-<objecttype>-<ruletype>-delete <objectname> <number>

where:

Variable Description
<objecttype> can be one of:
- service - if the rule applies to a L7 service
- farm - if the rule applies to a L7 farm
<objectname> name of the object to apply the action on
<ruletype> depends on <objecttype>

For service object type:

- tcpreqconn - with the following list: L7 tcpreqconn rule attributes
- tcpreqcont - with the following list: L7 tcpreqcont rule attributes
- httpreq - with the following list: L7 httpreq rule parameters
- redirect - with the following list: L7 redirect rule parameters
- usefarm - with the following list: L7 usefarm rule parameters

For farm object type:

- tcpreqcont - with the following list: L7 tcpreqcont rule attributes
- httpreq - with the following list: L7 httpreq rule parameters
- redirect - with the following list: L7 redirect rule parameters
- useserver - with the following list: L7 useserver rule parameters
- tcprspcont - with the following list: L7 tcprspcont rule parameters
- tcpcheck - with the following list: L7 tcpcheck rule parameters
<number> can be one of:
- tail - get the first rule of the list
- head - get the last rule of the list
- a positive integer - get the rule indicated by the integer

When deleting a rule, the following applies:

  • To delete the latest rule of the list, set to tail

  • To delete the first rule of the list, set to either 1 or head

  • To delete the Xth rule, set to X

When creating a new rule, the following applies:

  • To add a rule at the bottom of the list, set to tail

  • To add a rule at the top of the list, set to either 1 or head

  • To insert a rule before Xth one, set to X

L4 farms Jump to heading

Must be applied through a transaction or a scope.

Action alohactl2 parameters
List farms l4-farm-list
Delete all farms l4-farm-flush
Display configuration l4-farm-dump <farmname>
Create a farm l4-farm-create <farmname> [--<attribute> <value>]
Update a farm l4-farm-update <farmname> [--<attribute> <value>|--reset-<attribute>]
Delete a farm l4-farm-delete <farmname>

where:

Variable Description
<farmname> name of an L4 farm
<attribute> an L4 farm attribute

L4 servers Jump to heading

Must be applied through a transaction or a scope.

Action alohactl2 parameters
List available servers in a farm l4-server-list <farmname>
Delete all servers from a farm l4-server-flush <farmname>
Display server configuration l4-server-dump <farmname> <servername>
Create a server l4-server-create <farmname> <servername> [--<attribute> <value>]
Update a server l4-server-update <farmname> <servername> [--<attribute> <value>|--reset-<attribute>]
Delete a server l4-server-delete <farmname> <servername>

where:

Variable Description
<farmname> name of an L4 farm
<servername> name of a L4 server
<attribute> an L4 farm attribute

Complete example Jump to heading

Configuration through a transaction Jump to heading

To create a new frontend ft_web that points to a new backend bk_web in scope root using the API and following the procedure below:

  1. Create the backend

  2. Add srv1 to the backend

  3. Add srv2 to the backend

  4. Create the frontend

  5. Add a listener to the frontend

There are two options:

  • Use the atomic method: The configuration is updated, applied, and the load balancer is reloaded after each step.

  • Use a transaction: A single configuration update is processed. The load balancer is reloaded only once.

Create a new transaction in the scope root:

nix
sudo alohactl2 -S root transaction-begin
nix
sudo alohactl2 -S root transaction-begin
output
text
vZ9bBZiQcp
output
text
vZ9bBZiQcp

Create the backend bk_web:

nix
sudo alohactl2 -T vZ9bBZiQcp l7-farm-create bk_web --balance roundrobin --protocol http --log enabled --log-format http --http-xff-header-insert enabled --http-cookie enabled --http-cookie-name bkweb --http-cookie-mode set-silent --http-cookie-nocache enabled --check-interval 3 --check-rise 2 --check-fall 3 --adv-check http --adv-check-http-method HEAD --adv-check-http-uri / --server-inactivity-timeout 25 --connect-timeout 4
nix
sudo alohactl2 -T vZ9bBZiQcp l7-farm-create bk_web --balance roundrobin --protocol http --log enabled --log-format http --http-xff-header-insert enabled --http-cookie enabled --http-cookie-name bkweb --http-cookie-mode set-silent --http-cookie-nocache enabled --check-interval 3 --check-rise 2 --check-fall 3 --adv-check http --adv-check-http-method HEAD --adv-check-http-uri / --server-inactivity-timeout 25 --connect-timeout 4

Add srv1 in the backend:

nix
sudo alohactl2 -T vZ9bBZiQcp l7-server-create bk_web srv1 --address 192.168.1.21 --port 80 --max-connections 1000 --weight 10 --http-cookie-id srv1 --check enabled
nix
sudo alohactl2 -T vZ9bBZiQcp l7-server-create bk_web srv1 --address 192.168.1.21 --port 80 --max-connections 1000 --weight 10 --http-cookie-id srv1 --check enabled

Add srv2 in the backend:

nix
sudo alohactl2 -T vZ9bBZiQcp l7-server-create bk_web srv2 --address 192.168.1.22 --port 80 --max-connections 1000 --weight 10 --http-cookie-id srv2 --check enabled
nix
sudo alohactl2 -T vZ9bBZiQcp l7-server-create bk_web srv2 --address 192.168.1.22 --port 80 --max-connections 1000 --weight 10 --http-cookie-id srv2 --check enabled

Create the service ft_web:

nix
sudo alohactl2 -T vZ9bBZiQcp l7-service-create ft_web --protocol http --log enabled --log-format http --client-inactivity-timeout 25 --max-connections 1000 --default-farm bk_web
nix
sudo alohactl2 -T vZ9bBZiQcp l7-service-create ft_web --protocol http --log enabled --log-format http --client-inactivity-timeout 25 --max-connections 1000 --default-farm bk_web

Create the listener for the L7 service:

nix
sudo alohactl2 -T vZ9bBZiQcp l7-service-create ft_web --protocol http --log enabled --log-format http --client-inactivity-timeout 25 --max-connections 1000 --default-farm bk_web
nix
sudo alohactl2 -T vZ9bBZiQcp l7-service-create ft_web --protocol http --log enabled --log-format http --client-inactivity-timeout 25 --max-connections 1000 --default-farm bk_web

Create the listener for the L7 service:

nix
sudo alohactl2 -T vZ9bBZiQcp l7-listener-create ft_web http --port 80 --address 0.0.0.0
nix
sudo alohactl2 -T vZ9bBZiQcp l7-listener-create ft_web http --port 80 --address 0.0.0.0

Commit the transaction:

nix
sudo alohactl2 -T vZ9bBZiQcp transaction-commit
nix
sudo alohactl2 -T vZ9bBZiQcp transaction-commit

Save configuration in a cluster Jump to heading

Save the configuration on the master:

nix
sudo alohactl2 global-save
nix
sudo alohactl2 global-save

Push the master configuration to the slave configuration:

nix
sudo alohactl2 global-push
nix
sudo alohactl2 global-push

From the master configuration, tell the slave to save its configuration:

nix
sudo alohactl2 global-remote-save
nix
sudo alohactl2 global-remote-save

Do you have any suggestions on how we can improve the content of this page?