Skip to content

Commit

Permalink
Doc: Update cli
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc committed Jul 17, 2023
1 parent 61618e2 commit 7c649e5
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 102 deletions.
Empty file added anta-complete.sh
Empty file.
13 changes: 7 additions & 6 deletions docs/cli/debug.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Debugging ANTA Commands
# ANTA debug commands

The ANTA CLI includes a set of debugging tools, making it easier to build and test ANTA content. This functionality is accessed via the `debug` entrypoint and offers the following options:
The ANTA CLI includes a set of debugging tools, making it easier to build and test ANTA content. This functionality is accessed via the `debug` subcommand and offers the following options:

- Executing a command on a device from your inventory and revealing the result.
- Running a templated command on a device from your inventory and revealing the result.
- Executing a command on a device from your inventory and retrieving the result.
- Running a templated command on a device from your inventory and retrieving the result.

These tools are especially helpful in building your tests, as they give you visual access to the output you receive from the eAPI. They also facilitate the extraction of output content for use in unit tests, as described in our [contribution guide](../contribution.md).
These tools are especially helpful in building the tests, as they give a visual access to the output received from the eAPI. They also facilitate the extraction of output content for use in unit tests, as described in our [contribution guide](../contribution.md).

!!! warning
The `debug` tools require a device from your inventory. Thus, you MUST use a valid [ANTA Inventory](../usage-inventory-catalog.md#create-an-inventory-file).
Expand Down Expand Up @@ -33,7 +33,7 @@ Options:

### Example

This example illustrates how to run the `show interfaces description` command with a `JSON` format:
This example illustrates how to run the `show interfaces description` command with a `JSON` format (default):

```bash
anta debug run-cmd --command "show interfaces description" --device DC1-SPINE1
Expand Down Expand Up @@ -111,4 +111,5 @@ anta --log DEBUG debug run-template --template "ping {dst} source {src}" dst "8.

anta --log DEBUG debug run-template --template "ping {dst} source {src}" dst "8.8.8.8" src Loopback0 dst "1.1.1.1" src Loopback1 --device DC1-SPINE1          
> {'dst': '1.1.1.1', 'src': 'Loopback1'}
# Notice how `src` and `dst` keep only the latest value
```
16 changes: 11 additions & 5 deletions docs/cli/exec.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Executing Commands on Devices

ANTA CLI incorporates a set of entrypoints to facilitate remote command execution on EOS devices.
ANTA CLI provides a set of entrypoints to facilitate remote command execution on EOS devices.

### EXEC Command overview
```bash
Expand Down Expand Up @@ -46,9 +46,10 @@ anta exec clear-counters --tags SPINE
INFO Cleared counters on DC1-SPINE1 (cEOSLab) utils.py:41
INFO Cleared counters on DC2-SPINE2 (cEOSLab)
```

## Collect a set of commands

This command collects all the commands you've specified in a catalog, which can be in either `json` or `text` format.
This command collects all the commands specified in a commands-list file, which can be in either `json` or `text` format.

### Command overview

Expand All @@ -70,7 +71,7 @@ Options:
--help Show this message and exit.
```
Your catalog file should follow this structure:
The commands-list file should follow this structure:
```yaml
---
Expand All @@ -94,6 +95,7 @@ anta exec snapshot --tags SPINE --commands-list ./commands.yaml --output ./
INFO Collected command 'show bfd peers' from device DC1-SPINE1 (cEOSLab) utils.py:76
INFO Collected command 'show bfd peers' from device DC1-SPINE2 (cEOSLab)
```
The results of the executed commands will be stored in the output directory specified during command execution:
```bash
Expand Down Expand Up @@ -168,10 +170,13 @@ When executed, this command fetches tech-support files and downloads them locall
ANTA uses SCP to download files from devices; ensure that all SSH Host Keys are trusted before running the command. Use the `anta --insecure` option if they are not.
The configuration `aaa authorization exec default local` must be enabled on devices for SCP to function. ANTA won't automatically configure this unless `--configure` is specified.
The configuration `aaa authorization exec default local` must be enabled on devices for SCP to function. ANTA will not automatically configure this unless `--configure` is specified.
The `--latest` option allows retrieval of a specific number of the most recent tech-support files.
!!! warning
By default **all** the tech-support files present on the devices are retrieved.
### Example
```bash
Expand Down Expand Up @@ -211,4 +216,5 @@ tech-support/
6 directories, 6 files
```
Each device has its own subdirectory containing the collected tech-support files.
Each device has its own subdirectory containing the collected tech-support files.
101 changes: 24 additions & 77 deletions docs/cli/get-inventory-information.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
# Retrieving Inventory Information

The ANTA CLI offers multiple entry points to access data from your local inventory.
The ANTA CLI offers multiple entrypoints to access data from your local inventory.

## Obtaining all configured tags

As most of ANTA's commands accommodate tag filtering, this particular command is useful for enumerating all tags configured in your inventory. Running the `anta get tags` command will return a list of all tags that have been configured in your inventory.

### Command overview

```bash
anta get tags --help
Usage: anta get tags [OPTIONS]

Get list of configured tags in user inventory.

Options:
--help Show this message and exit.
```

### Example
## Inventory used of examples

Let's consider the following inventory:

Expand Down Expand Up @@ -75,7 +59,25 @@ anta_inventory:
tags: ["BL", "DC2"]
```
To get the list of all configured tags in your CLI, run the following command:
## Obtaining all configured tags
As most of ANTA's commands accommodate tag filtering, this particular command is useful for enumerating all tags configured in the inventory. Running the `anta get tags` command will return a list of all tags that have been configured in the inventory.

### Command overview

```bash
anta get tags --help
Usage: anta get tags [OPTIONS]
Get list of configured tags in user inventory.
Options:
--help Show this message and exit.
```

### Example

To get the list of all configured tags in the inventory, run the following command:

```bash
anta get tags
Expand All @@ -93,11 +95,11 @@ Tags found:
```

!!! note
Even if you haven't explicitly configured the `all` tag in your inventory, it's automatically added. This default tag allows you to execute commands on all devices in your inventory when you don't specify any particular tag.
Even if you haven't explicitly configured the `all` tag in the inventory, it is automatically added. This default tag allows to execute commands on all devices in the inventory when no tag is specified.

## List devices in inventory

This command will list all devices available in your inventory. Using the `--tags` option, you can filter this list to only include devices with specific tags. The `--connected` option allows you to display only the devices where a connection has been established.
This command will list all devices available in the inventory. Using the `--tags` option, you can filter this list to only include devices with specific tags. The `--connected` option allows to display only the devices where a connection has been established.

### Command overview

Expand All @@ -117,65 +119,10 @@ Options:


!!! tip
In its default mode, `anta get inventory` provides only information that doesn't rely on a device connection. If you're interested in obtaining connection-dependent details, like the hardware model, please use the `--connected` option.
In its default mode, `anta get inventory` provides only information that doesn't rely on a device connection. If you are interested in obtaining connection-dependent details, like the hardware model, please use the `--connected` option.

### Example

Let's consider the following inventory:

```yaml
---
anta_inventory:
hosts:
- host: 172.20.20.101
name: DC1-SPINE1
tags: ["SPINE", "DC1"]

- host: 172.20.20.102
name: DC1-SPINE2
tags: ["SPINE", "DC1"]

- host: 172.20.20.111
name: DC1-LEAF1A
tags: ["LEAF", "DC1"]

- host: 172.20.20.112
name: DC1-LEAF1B
tags: ["LEAF", "DC1"]

- host: 172.20.20.121
name: DC1-BL1
tags: ["BL", "DC1"]

- host: 172.20.20.122
name: DC1-BL2
tags: ["BL", "DC1"]

- host: 172.20.20.201
name: DC2-SPINE1
tags: ["SPINE", "DC2"]

- host: 172.20.20.202
name: DC2-SPINE2
tags: ["SPINE", "DC2"]

- host: 172.20.20.211
name: DC2-LEAF1A
tags: ["LEAF", "DC2"]

- host: 172.20.20.212
name: DC2-LEAF1B
tags: ["LEAF", "DC2"]

- host: 172.20.20.221
name: DC2-BL1
tags: ["BL", "DC2"]

- host: 172.20.20.222
name: DC2-BL2
tags: ["BL", "DC2"]
```
To retrieve a comprehensive list of all devices along with their details, execute the following command. It will provide all the data loaded into the ANTA inventory from your [inventory file](../../usage-inventory-catalog/).

```bash
Expand Down
4 changes: 2 additions & 2 deletions docs/cli/inv-from-cvp.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Create an Inventory from CloudVision

In large setups, it might be beneficial to construct your inventory based on CloudVision. The `from-cvp` entrypoint of the `get` command enables you to create an ANTA inventory from CloudVision.
In large setups, it might be beneficial to construct your inventory based on CloudVision. The `from-cvp` entrypoint of the `get` command enables the user to create an ANTA inventory from CloudVision.

### Command overview

Expand Down Expand Up @@ -63,4 +63,4 @@ $ for container in pod01 pod02 spines; do anta get from-cvp -ip <cvp-ip> -u cvpa
INFO Connected to CVP cvp.as73.inetsix.net
INFO Inventory file has been created in /home/tom/Projects/arista/network-test-automation/test-inventory/inventory-spines.yml
```
```
16 changes: 8 additions & 8 deletions docs/cli/nrfu.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ All commands under the `anta nrfu` namespace require a catalog yaml file specifi

## Performing NRFU with text rendering

The `text` command provides a straightforward text report for each test executed on all devices in your inventory.
The `text` subcommand provides a straightforward text report for each test executed on all devices in your inventory.

### Command overview

Expand All @@ -51,7 +51,7 @@ Options:
--help Show this message and exit.
```

The `--tags` option allows you to target specific devices in your inventory, while the `--search` option permits filtering based on a regular expression pattern in both the hostname and the test name.
The `--tags` option allows to target specific devices in your inventory, while the `--search` option permits filtering based on a regular expression pattern in both the hostname and the test name.

The `--skip-error` option can be used to exclude tests that failed due to connectivity issues or unsupported commands.

Expand All @@ -60,7 +60,7 @@ The `--skip-error` option can be used to exclude tests that failed due to connec
```bash
anta nrfu text --tags LEAF --search DC1-LEAF1A
```
[![anta nrfu text results](../imgs/anta-nrfu-text-output.png){ loading=lazy width="800" }](../imgs/anta-nrfu-text-output.png)
[![anta nrfu text results](../imgs/anta-nrfu-text-output.png){ loading=lazy width="1600" }](../imgs/anta-nrfu-text-output.png)

## Performing NRFU with table rendering

Expand Down Expand Up @@ -90,14 +90,14 @@ The `--device` and `--test` options show a summarized view of the test results f
```bash
anta nrfu table --tags LEAF
```
[![anta nrfu table results](../imgs/anta-nrfu-table-output.png){ loading=lazy width="800" }](../imgs/anta-nrfu-table-output.png)
[![anta nrfu table results](../imgs/anta-nrfu-table-output.png){ loading=lazy width="1600" }](../imgs/anta-nrfu-table-output.png)

For larger setups, you can also group the results by host or test to get a summarized view:

```bash
anta nrfu table --tags LEAF --device DC1-LEAF1A
```
[![anta nrfu table per host results](../imgs/anta-nrfu-table-per-host-output.png){ loading=lazy width="800" }](../imgs/anta-nrfu-table-per-host-output.png)
[![anta nrfu table per host results](../imgs/anta-nrfu-table-per-host-output.png){ loading=lazy width="1600" }](../imgs/anta-nrfu-table-per-host-output.png)

## Performing NRFU with JSON rendering

Expand Down Expand Up @@ -127,7 +127,7 @@ The `--output` option allows you to save the JSON report as a file.
```bash
anta nrfu json --tags LEAF
```
[![anta nrfu json results](../imgs/anta-nrfu-json-output.png){ loading=lazy width="800" }](../imgs/anta-nrfu-json-output.png)
[![anta nrfu json results](../imgs/anta-nrfu-json-output.png){ loading=lazy width="1600" }](../imgs/anta-nrfu-json-output.png)

## Performing NRFU with custom reports

Expand Down Expand Up @@ -160,7 +160,7 @@ The `--tags` option can be used to target specific devices in your inventory.
```bash
anta nrfu tpl-report --tags LEAF --template ./custom_template.j2
```
[![anta nrfu json results](../imgs/anta-nrfu-tpl-report-output.png){ loading=lazy width="800" }](../imgs/anta-nrfu-tpl-report-output.png)
[![anta nrfu json results](../imgs/anta-nrfu-tpl-report-output.png){ loading=lazy width="1600" }](../imgs/anta-nrfu-tpl-report-output.png)

The template `./custom_template.j2` is a simple Jinja2 template:

Expand All @@ -186,4 +186,4 @@ cat nrfu-tpl-report.txt
* VerifyMlagInterfaces is [green]SUCCESS[/green] for DC1-LEAF1A
* VerifyMlagConfigSanity is [green]SUCCESS[/green] for DC1-LEAF1A
* VerifyMlagReloadDelay is [green]SUCCESS[/green] for DC1-LEAF1A
```
```
8 changes: 4 additions & 4 deletions docs/cli/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ For all subcommands, ANTA will return the exit code 0, indicating a successful o
For the nrfu command, ANTA uses the following exit codes:
- Exit code 0 - All tests passed successfully.
- Exit code 1 - Tests were run, but at least one test returned a failure.
- Exit code 2 - Tests were run, but at least one test returned an error.
- Exit code 3 - An internal error occurred while executing tests.
- `Exit code 0` - All tests passed successfully.
- `Exit code 1` - Tests were run, but at least one test returned a failure.
- `Exit code 2` - Tests were run, but at least one test returned an error.
- `Exit code 3` - An internal error occurred while executing tests.
To ignore the test status, use `anta --ignore-status nrfu`, and the exit code will always be 0.
Expand Down

0 comments on commit 7c649e5

Please sign in to comment.