summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/anta_runner.py67
-rw-r--r--examples/tests.yaml59
2 files changed, 126 insertions, 0 deletions
diff --git a/examples/anta_runner.py b/examples/anta_runner.py
new file mode 100644
index 0000000..722cb87
--- /dev/null
+++ b/examples/anta_runner.py
@@ -0,0 +1,67 @@
+# Copyright (c) 2023-2024 Arista Networks, Inc.
+# Use of this source code is governed by the Apache License 2.0
+# that can be found in the LICENSE file.
+"""Example script for ANTA.
+
+usage:
+
+python anta_runner.py
+"""
+
+from __future__ import annotations
+
+import asyncio
+import logging
+import sys
+from pathlib import Path
+
+from anta.catalog import AntaCatalog
+from anta.cli.nrfu.utils import anta_progress_bar
+from anta.inventory import AntaInventory
+from anta.logger import Log, setup_logging
+from anta.models import AntaTest
+from anta.result_manager import ResultManager
+from anta.runner import main as anta_runner
+
+# setup logging
+setup_logging(Log.INFO, Path("/tmp/anta.log"))
+LOGGER = logging.getLogger()
+SCRIPT_LOG_PREFIX = "[bold magenta][ANTA RUNNER SCRIPT][/] " # For convenience purpose - there are nicer way to do this.
+
+
+# NOTE: The inventory and catalog files are not delivered with this script
+USERNAME = "admin"
+PASSWORD = "admin"
+CATALOG_PATH = Path("/tmp/anta_catalog.yml")
+INVENTORY_PATH = Path("/tmp/anta_inventory.yml")
+
+# Load catalog file
+try:
+ catalog = AntaCatalog.parse(CATALOG_PATH)
+except Exception:
+ LOGGER.exception("%s Catalog failed to load!", SCRIPT_LOG_PREFIX)
+ sys.exit(1)
+LOGGER.info("%s Catalog loaded!", SCRIPT_LOG_PREFIX)
+
+# Load inventory
+try:
+ inventory = AntaInventory.parse(INVENTORY_PATH, username=USERNAME, password=PASSWORD)
+except Exception:
+ LOGGER.exception("%s Inventory failed to load!", SCRIPT_LOG_PREFIX)
+ sys.exit(1)
+LOGGER.info("%s Inventory loaded!", SCRIPT_LOG_PREFIX)
+
+# Create result manager object
+manager = ResultManager()
+
+# Launch ANTA
+LOGGER.info("%s Starting ANTA runner...", SCRIPT_LOG_PREFIX)
+with anta_progress_bar() as AntaTest.progress:
+ # Set dry_run to True to avoid connecting to the devices
+ asyncio.run(anta_runner(manager, inventory, catalog, dry_run=False))
+
+LOGGER.info("%s ANTA run completed!", SCRIPT_LOG_PREFIX)
+
+# Manipulate the test result object
+for test_result in manager.results:
+ LOGGER.info("%s %s:%s:%s", SCRIPT_LOG_PREFIX, test_result.name, test_result.test, test_result.result)
diff --git a/examples/tests.yaml b/examples/tests.yaml
index e4445aa..cb3d19b 100644
--- a/examples/tests.yaml
+++ b/examples/tests.yaml
@@ -50,6 +50,18 @@ anta.tests.aaa:
- commands
- dot1x
+anta.tests.avt:
+ - VerifyAVTPathHealth:
+ - VerifyAVTSpecificPath:
+ avt_paths:
+ - avt_name: CONTROL-PLANE-PROFILE
+ vrf: default
+ destination: 10.101.255.2
+ next_hop: 10.101.255.1
+ path_type: direct
+ - VerifyAVTRole:
+ role: edge
+
anta.tests.bfd:
- VerifyBFDSpecificPeers:
bfd_peers:
@@ -167,6 +179,18 @@ anta.tests.interfaces:
- 10.10.10.10/31
- VerifyIpVirtualRouterMac:
mac_address: 00:1c:73:00:dc:01
+ - VerifyInterfacesSpeed:
+ interfaces:
+ - name: Ethernet2
+ auto: False
+ speed: 10
+ - name: Eth3
+ auto: True
+ speed: 100
+ lanes: 1
+ - name: Eth2
+ auto: False
+ speed: 2.5
anta.tests.lanz:
- VerifyLANZ:
@@ -210,6 +234,15 @@ anta.tests.multicast:
- VerifyIGMPSnoopingGlobal:
enabled: True
+anta.tests.path_selection:
+ - VerifyPathsHealth:
+ - VerifySpecificPath:
+ paths:
+ - peer: 10.255.0.1
+ path_group: internet
+ source_address: 100.64.3.2
+ destination_address: 100.64.1.2
+
anta.tests.profiles:
- VerifyUnifiedForwardingTableMode:
mode: 3
@@ -515,3 +548,29 @@ anta.tests.routing:
- VerifyOSPFNeighborCount:
number: 3
- VerifyOSPFMaxLSA:
+ isis:
+ - VerifyISISNeighborState:
+ - VerifyISISNeighborCount:
+ interfaces:
+ - name: Ethernet1
+ level: 1
+ count: 2
+ - name: Ethernet2
+ level: 2
+ count: 1
+ - name: Ethernet3
+ count: 2
+ # level is set to 2 by default
+ - VerifyISISInterfaceMode:
+ interfaces:
+ - name: Loopback0
+ mode: passive
+ # vrf is set to default by default
+ - name: Ethernet2
+ mode: passive
+ level: 2
+ # vrf is set to default by default
+ - name: Ethernet1
+ mode: point-to-point
+ vrf: default
+ # level is set to 2 by default \ No newline at end of file