Avi Load Balancer can be managed through GUI, RESTful API, or CLI. Both the GUI and CLI are built on top of the API, which means every CLI command maps to a corresponding API call (or calls) to be run.

Interfacing to Avi Load Balancer through CLI Commands

In Avi Load Balancer, there are three entities with which the authorized user can have a CLI-based conversation:

  1. A Controller’s Linux operating system

  2. Avi Load Balancer processes running on a Controller

  3. An SE’s Linux operating system

Conversations with the first two entities are common. Conversations of the third kind are infrequent and typically undertaken by customer support personnel for troubleshooting purposes.

CLI Conversations with the Controller’s Operating System

Below is a command-line example:

The one argument (user@hostname) passed to the ssh command is a combination of admin and the Controller’s IP address, 10.144.130.195. Every Avi Load Balancer Controller recognizes the admin user; others can be defined if necessary. The response to the password prompt is not echoed. However, in this example, it is represented by XXXXX.

The bash command-line interpreter gives access to the Controller’s underlying operating system and file system. One use case would be to analyze various logs in the /opt/avi/log and /var/log/upstart directories.

$>ssh [email protected]
Avi Cloud Controller
Avi Networks software, Copyright (C) 2013-2017 by Avi Networks, Inc.
All rights reserved.
Management:   100.65.9.10/20        UP
Gateway:      100.65.15.254         UP
[email protected]@100.65.9.10
Avi Cloud Controller
Avi Networks software, Copyright (C) 2013-2017 by Avi Networks, Inc.
All rights reserved.
Management:   100.65.9.10/20        UP
Gateway:      100.65.15.254         UP
[email protected]@100.65.9.10
Avi Cloud Controller
Avi Networks software, Copyright (C) 2013-2017 by Avi Networks, Inc.
All rights reserved.
Management:   100.65.9.10/20        UP
Gateway:      100.65.15.254         UP
[email protected]'s password:
The copyrights to certain works contained in this software are
owned by other third parties and used and distributed under
license. Certain components of this software are licensed under
the GNU General Public License (GPL) version 2.0 or the GNU
Lesser General Public License (LGPL) Version 2.1. A copy of each
such license is available at
http://www.opensource.org/licenses/gpl-2.0.php and
http://www.opensource.org/licenses/lgpl-2.1.php
Last login: Wed Apr  5 16:24:41 2023 from 100.65.1.5
admin@100-65-9-10:~$

CLI Conversations with Avi Load Balancer Processes Running on the Controller

Avi Load Balancer-specific commands are not directly accessible from the Controller’s bash interface.

Enter the Avi Load Balancer shell command-line interpreter by typing the shell command in response to the bash prompt and input the login credentials as follows:

shell
Login: admin
Password: XXXXX

In response to the shell prompt, press the Tab key twice to reveal the commands specific to Avi Load Balancer. In the CLI snippet shown below, TABTAB represents the Tab key pressed twice.

TABTAB
attach          forcedelete     reprogram       terminal
clear           gslb            resync          test
configure       import          retryplacement  upgrade
controller      migrate         rollback        upload
convert         nsx             rotatekeys      upload_to_avi
debug           passwd          scalein         verifylogin
delete          reboot          scaleout        vinfra
do              rediscover      show            watch
exec            redistribute    switchover
export          reimage         switchto

The show command helps analyze various issues and collect information. For example, show virtualservice my-vs displays essential data about the virtual service named my-vs.

For insight into what the aforementioned commands do, see CLI Top-Level Commands.

To exit the Avi Load Balancer shell and return to the Controller’s bash prompt, type bash.

bash

CLI Conversations with an Avi Load Balancer SE’s Linux Operating System

Note:

While it is possible to access a SE's CLI directly, it must only be used for basic troubleshooting. All configuration management must instead be done from and by the Controller.

SSH'ing to a SE or running the attach serviceengine name-of-service-engine command from the Avi Load Balancer shell places one in the SE's Linux CLI. There is no equivalent to the Controller's shell prompt; there are no show commands in the SE CLI. Use the SE's CLI to look into SE-specific logs in various directories, such as /opt/avi/log.

Navigation and Help

After entering into the Avi Load Balancer shell, press the TAB key twice to see a list of available commands.

  • While typing a command, pressing the TAB key auto-completes the command. Double TAB returns a list of available options for the command in the left column. Most options include a brief help description, which is shown in the right column.

    export configuration
    export configuration serviceengine
    export serviceengine ova file from controller virtualservice
    export virtual service
  • Commands or parameters might require multiple words or options. If there is only a single word or option, pressing TAB auto-completes the next word in the command.

    export configuration [TAB]
    export configuration file [TAB]
    WORD (required)
    export configuration file mybackup
    Completed writing the export configuration to mybackup

Other navigational commands:

  • The up-arrow key cycles through and enables the reuse of previously run commands.

  • The history command presents commands in a list format.

  • Pipe filters results, as in

    • | grep address

    • | more

      These are useful in watch commands too.

Sub-mode Navigation

Many Avi Load Balancer CLI commands contain sub-modes, which are nested sub-sections of the current command.

To enter the sub-mode, enter the relevant command. Within the context of a sub-mode, changes are not committed until explicitly saved. Type save to exit the sub-mode while committing changes.

To exit the sub-mode without saving changes, type cancel. When in a sub-mode or a nested sub-mode, the command prompt will change to reflect the current sub-mode.

debug virtualservice Test-VS
debug_ip
cancel
cancel

It is possible to enter a command which enters a sub-mode while also adding applicable flags. This will simultaneously navigate into the sub-mode and run the command. Subsequent commands within the sub-mode do not use the initial sub-mode command.

debug_ip addrs 10.1.1.1
addrs 10.1.1.2
save

The where Command

When operating within a sub-mode, multiple changes can be made to parameters. To see the current status of the configured parameters, use the where command.

debug_ip addrs 10.1.1.1
addrs 10.1.1.2
addrs 10.1.1.3
where
Tenant: admin
+----------+----------+
| Field    | Value    |
+----------+----------+
| addrs[1] | 10.1.1.1 |
| addrs[2] | 10.1.1.2 |
| addrs[3] | 10.1.1.3 |
+----------+----------+

Revealing the REST API Calls Behind CLI Commands

Any Avi Load Balancer CLI command may include the --api-detail flag, which echoes the API call (or calls) the command is performing. The command runs as it would without this flag. This can be useful when building API-driven automation scripts.

show serviceengine --api-detail
REST API Request
API: /api/serviceengine?owned_by_controller=True&join_subresources=runtime

API-echoed output may be enabled for every command run during a single CLI session by typing the terminal display_api_details command, as shown below:

terminal display_api_details
show serviceengine
REST API Request
Method: GET

API: /api/serviceengine?owned_by_controller=True&join_subresources=runtime

+---------------------------+---------------+------------------+---------------+------------+
| Name                      | SE Group      | Mgmt IP          | Cloud         | Oper State |
+---------------------------+---------------+------------------+---------------+------------+
| se3                       | glsbSEG       | 192.168.38.56    | Default-Cloud | OPER_UP    |
| se1                       | Default-Group | 192.168.38.52    | Default-Cloud | OPER_UP    |
| se2                       | Default-Group | 192.168.38.53    | Default-Cloud | OPER_UP    |
+---------------------------+---------------+------------------+---------------+------------+