Registry / testing / anta
library1.8.0pypypiunverified

The Arista Network Test Automation (ANTA) Framework is a Python library designed for automating network device testing, specifically targeting Arista EOS devices. It provides a structured way to define, execute, and report on various network tests, supporting both CLI and programmatic workflows. As of this entry, the current version is 1.8.0, with active development and regular feature and maintenance releases.

pip install anta anta-lib-tests
INSTALL
IMPORT
SIG · ANTA
A
anta
testingpythonv1.8.0
Install
Import
Disk
Pass rate
0/ 10
Env Coverage0 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v? · pip install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

AntaInventory
from anta.inventory import AntaInventory
AntaTest
from anta.models import AntaTest
from anta.anta_models import AntaTest
The core models were moved from `anta_models` to `models` in ANTA v1.0.0.
ResultManager
from anta.result_manager import ResultManager
VerifyReachability
from anta.tests.connectivity import VerifyReachability
Requires the `anta-lib-tests` package to be installed alongside `anta`.
main (CLI runner)
from anta.runner import main
import anta.runner
The `main` function from `anta.runner` is designed for CLI execution and parsing `argparse` arguments. Direct programmatic execution usually involves calling test methods manually on device objects.

This quickstart demonstrates how to programmatically define an ANTA inventory, specify tests, execute them against a device (mocked or real), and process the results. It assumes you have `anta` and `anta-lib-tests` installed. Credentials are loaded from environment variables `ANTA_USERNAME` and `ANTA_PASSWORD`, defaulting to 'admin' and 'arista' respectively. Replace '127.0.0.1' and test host IPs with your actual environment details.

import os from anta.inventory import AntaInventory from anta.models import AntaTest from anta.tests.connectivity import VerifyReachability # Requires anta-lib-tests from anta.result_manager import ResultManager # 1. Define your inventory programmatically or load from a file # This example uses a simple in-memory inventory for a single device. # Replace '127.0.0.1' with your actual device's IP/hostname. inventory_data = { "lab": { "hosts": { "veos-01": { "host": "127.0.0.1", "port": 8443, "username": os.environ.get('ANTA_USERNAME', 'admin'), "password": os.environ.get('ANTA_PASSWORD', 'arista'), "protocol": "https_vfy" } } } } inventory = AntaInventory(inventory_data=inventory_data) # 2. Define your tests using AntaTest objects # This uses a built-in test from anta-lib-tests. Adjust 'hosts' for your network. # Note: '1.1.1.1' and '2.2.2.2' are example unreachable hosts for a quick fail result. # If you have real devices, replace with actual reachable/unreachable IPs. tests_to_run = [ AntaTest(test=VerifyReachability, args={"hosts": ["1.1.1.1", "2.2.2.2"]}) ] # 3. Instantiate a ResultManager to collect test outcomes result_manager = ResultManager() # 4. Iterate over inventory devices and execute tests print("--- Starting ANTA tests ---") for device_name, device in inventory.get_devices().items(): print(f"\nRunning tests on device: {device_name} ({device.host})") try: device.connect() # Establish connection to the device for anta_test in tests_to_run: # Execute each test and record its result print(f" Executing test: {anta_test.test.__name__}...") anta_test.test(device=device, result_manager=result_manager) # Pass device and result_manager device.close() # Close connection after tests except Exception as e: # Handle connection errors or general exceptions during test execution print(f" ERROR during tests on {device_name}: {e}") # Add a skipped/failed result for the first test if connection failed if tests_to_run: result_manager.add_failure(device=device, test=tests_to_run[0].test, result="SKIPPED", messages=[f"Could not connect or run tests: {e}"]) else: print(f" No tests defined for {device_name}, but connection failed: {e}") # 5. Print the aggregated test results print("\n--- ANTA Test Results Summary ---") for result in result_manager.get_results(): print(f"Device: {result.name}, Test: {result.test}, Result: {result.result}") if result.messages: for message in result.messages: print(f" - {message}")
anta --version
Debug
Known issues
breakingANTA v1.0.0 introduced significant API changes and refactoring. Key modules like `anta.anta_models` were renamed to `anta.models`, and the overall test execution flow was redesigned.
fix
Review the official ANTA v1.0.0 migration guide and update import paths, inventory formats, and test definitions. Specifically, `AntaTest` and `AntaDevice` are now imported from `anta.models`.
affects: <1.0.0
gotchaBuilt-in ANTA tests (e.g., `VerifyReachability`) are no longer part of the core `anta` package. They have been moved to a separate package, `anta-lib-tests`.
fix
Ensure you install both `anta` and `anta-lib-tests`: `pip install anta anta-lib-tests`. If you omit `anta-lib-tests`, you will encounter `ModuleNotFoundError` when trying to import common tests.
affects: >=1.0.0
gotchaANTA's programmatic runner (`anta.runner.main`) is primarily designed for internal CLI use with `argparse`. Direct programmatic execution requires a more manual loop over inventory devices and tests.
fix
For programmatic execution, directly instantiate `AntaInventory`, `ResultManager`, and `AntaTest` objects. Then, iterate through your inventory, connect to devices, execute `anta_test.test(device=device, result_manager=result_manager)`, and collect results from the `ResultManager`.
affects: >=1.0.0
gotchaThe inventory format, especially for device connection parameters, has evolved. Older YAML inventory files might require updates, particularly for protocol specification (`https_vfy` for verified HTTPS).
fix
Consult the latest ANTA documentation for the correct inventory YAML structure. Ensure connection parameters like `protocol` (`https_vfy` vs `https`) are correctly specified.
affects: >=1.0.0
Upgrade
Version history
1.8.0latest on PyPI · released Mar 11, 2026
Audit
Dependencies
anta-lib-testsrequiredProvides the official suite of built-in ANTA tests. Many quickstart examples and common use-cases rely on these tests.
Agent activity
50 hits · last 30 days
node
46
Amazon
1
OpenAI (training)
1
Resources
anta — pip install anta · libregistry