From 27a16999ea8c8122d2f172273e666ba2031573bc Mon Sep 17 00:00:00 2001 From: Guillaume Mulocher Date: Thu, 31 Oct 2024 13:00:51 +0100 Subject: [PATCH] feat: Make name and description optional for AntaTests (#841) --- anta/models.py | 31 ++++++---- anta/reporter/csv_reporter.py | 3 +- anta/tests/aaa.py | 14 ----- anta/tests/avt.py | 12 +--- anta/tests/bfd.py | 7 --- anta/tests/configuration.py | 5 -- anta/tests/connectivity.py | 3 - anta/tests/field_notices.py | 2 - anta/tests/flow_tracking.py | 10 +--- anta/tests/greent.py | 4 +- anta/tests/hardware.py | 11 ---- anta/tests/interfaces.py | 29 --------- anta/tests/lanz.py | 1 - anta/tests/logging.py | 16 ----- anta/tests/mlag.py | 10 ---- anta/tests/multicast.py | 4 -- anta/tests/path_selection.py | 10 +--- anta/tests/profiles.py | 2 - anta/tests/ptp.py | 5 -- anta/tests/routing/bgp.py | 25 +------- anta/tests/routing/generic.py | 8 +-- anta/tests/routing/isis.py | 33 +++------- anta/tests/routing/ospf.py | 5 -- anta/tests/security.py | 35 +---------- anta/tests/services.py | 6 -- anta/tests/snmp.py | 11 ---- anta/tests/software.py | 4 -- anta/tests/stp.py | 11 ---- anta/tests/stun.py | 12 +--- anta/tests/system.py | 17 +----- anta/tests/vlan.py | 1 - anta/tests/vxlan.py | 11 +--- anta/tools.py | 3 +- asynceapi/aio_portcheck.py | 3 +- asynceapi/config_session.py | 27 +++------ asynceapi/device.py | 15 ++--- asynceapi/errors.py | 3 +- docs/advanced_usages/custom-tests.md | 12 ++-- pyproject.toml | 3 +- tests/units/test_custom_types.py | 3 +- tests/units/test_models.py | 90 ++++++++-------------------- 41 files changed, 97 insertions(+), 420 deletions(-) diff --git a/anta/models.py b/anta/models.py index b103a9965..4cebd997a 100644 --- a/anta/models.py +++ b/anta/models.py @@ -284,8 +284,7 @@ class AntaTest(ABC): The following is an example of an AntaTest subclass implementation: ```python class VerifyReachability(AntaTest): - name = "VerifyReachability" - description = "Test the network reachability to one or many destination IP(s)." + '''Test the network reachability to one or many destination IP(s).''' categories = ["connectivity"] commands = [AntaTemplate(template="ping vrf {vrf} {dst} source {src} repeat 2")] @@ -326,12 +325,17 @@ def test(self) -> None: Python logger for this test instance. """ - # Mandatory class attributes - # TODO: find a way to tell mypy these are mandatory for child classes - maybe Protocol + # Optional class attributes name: ClassVar[str] description: ClassVar[str] + + # Mandatory class attributes + # TODO: find a way to tell mypy these are mandatory for child classes + # follow this https://discuss.python.org/t/provide-a-canonical-way-to-declare-an-abstract-class-variable/69416 + # for now only enforced at runtime with __init_subclass__ categories: ClassVar[list[str]] commands: ClassVar[list[AntaTemplate | AntaCommand]] + # Class attributes to handle the progress bar of ANTA CLI progress: Progress | None = None nrfu_task: TaskID | None = None @@ -505,12 +509,19 @@ def save_commands_data(self, eos_data: list[dict[str, Any] | str]) -> None: self.instance_commands[index].output = data def __init_subclass__(cls) -> None: - """Verify that the mandatory class attributes are defined.""" - mandatory_attributes = ["name", "description", "categories", "commands"] - for attr in mandatory_attributes: - if not hasattr(cls, attr): - msg = f"Class {cls.__module__}.{cls.__name__} is missing required class attribute {attr}" - raise NotImplementedError(msg) + """Verify that the mandatory class attributes are defined and set name and description if not set.""" + mandatory_attributes = ["categories", "commands"] + if missing_attrs := [attr for attr in mandatory_attributes if not hasattr(cls, attr)]: + msg = f"Class {cls.__module__}.{cls.__name__} is missing required class attribute(s): {', '.join(missing_attrs)}" + raise AttributeError(msg) + + cls.name = getattr(cls, "name", cls.__name__) + if not hasattr(cls, "description"): + if not cls.__doc__ or cls.__doc__.strip() == "": + # No doctsring or empty doctsring - raise + msg = f"Cannot set the description for class {cls.name}, either set it in the class definition or add a docstring to the class." + raise AttributeError(msg) + cls.description = cls.__doc__.split(sep="\n", maxsplit=1)[0] @property def module(self) -> str: diff --git a/anta/reporter/csv_reporter.py b/anta/reporter/csv_reporter.py index 33c50a8f4..4554e6f60 100644 --- a/anta/reporter/csv_reporter.py +++ b/anta/reporter/csv_reporter.py @@ -58,8 +58,7 @@ def split_list_to_txt_list(cls, usr_list: list[str], delimiter: str = " - ") -> @classmethod def convert_to_list(cls, result: TestResult) -> list[str]: - """ - Convert a TestResult into a list of string for creating file content. + """Convert a TestResult into a list of string for creating file content. Parameters ---------- diff --git a/anta/tests/aaa.py b/anta/tests/aaa.py index d6d0689e4..6328e06e6 100644 --- a/anta/tests/aaa.py +++ b/anta/tests/aaa.py @@ -35,8 +35,6 @@ class VerifyTacacsSourceIntf(AntaTest): ``` """ - name = "VerifyTacacsSourceIntf" - description = "Verifies TACACS source-interface for a specified VRF." categories: ClassVar[list[str]] = ["aaa"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show tacacs", revision=1)] @@ -81,8 +79,6 @@ class VerifyTacacsServers(AntaTest): ``` """ - name = "VerifyTacacsServers" - description = "Verifies TACACS servers are configured for a specified VRF." categories: ClassVar[list[str]] = ["aaa"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show tacacs", revision=1)] @@ -134,8 +130,6 @@ class VerifyTacacsServerGroups(AntaTest): ``` """ - name = "VerifyTacacsServerGroups" - description = "Verifies if the provided TACACS server group(s) are configured." categories: ClassVar[list[str]] = ["aaa"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show tacacs", revision=1)] @@ -184,8 +178,6 @@ class VerifyAuthenMethods(AntaTest): ``` """ - name = "VerifyAuthenMethods" - description = "Verifies the AAA authentication method lists for different authentication types (login, enable, dot1x)." categories: ClassVar[list[str]] = ["aaa"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show aaa methods authentication", revision=1)] @@ -245,8 +237,6 @@ class VerifyAuthzMethods(AntaTest): ``` """ - name = "VerifyAuthzMethods" - description = "Verifies the AAA authorization method lists for different authorization types (commands, exec)." categories: ClassVar[list[str]] = ["aaa"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show aaa methods authorization", revision=1)] @@ -301,8 +291,6 @@ class VerifyAcctDefaultMethods(AntaTest): ``` """ - name = "VerifyAcctDefaultMethods" - description = "Verifies the AAA accounting default method lists for different accounting types (system, exec, commands, dot1x)." categories: ClassVar[list[str]] = ["aaa"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show aaa methods accounting", revision=1)] @@ -364,8 +352,6 @@ class VerifyAcctConsoleMethods(AntaTest): ``` """ - name = "VerifyAcctConsoleMethods" - description = "Verifies the AAA accounting console method lists for different accounting types (system, exec, commands, dot1x)." categories: ClassVar[list[str]] = ["aaa"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show aaa methods accounting", revision=1)] diff --git a/anta/tests/avt.py b/anta/tests/avt.py index d72296aa0..66b30babe 100644 --- a/anta/tests/avt.py +++ b/anta/tests/avt.py @@ -18,8 +18,7 @@ class VerifyAVTPathHealth(AntaTest): - """ - Verifies the status of all Adaptive Virtual Topology (AVT) paths for all VRFs. + """Verifies the status of all Adaptive Virtual Topology (AVT) paths for all VRFs. Expected Results ---------------- @@ -34,7 +33,6 @@ class VerifyAVTPathHealth(AntaTest): ``` """ - name = "VerifyAVTPathHealth" description = "Verifies the status of all AVT paths for all VRFs." categories: ClassVar[list[str]] = ["avt"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show adaptive-virtual-topology path")] @@ -73,8 +71,7 @@ def test(self) -> None: class VerifyAVTSpecificPath(AntaTest): - """ - Verifies the status and type of an Adaptive Virtual Topology (AVT) path for a specified VRF. + """Verifies the status and type of an Adaptive Virtual Topology (AVT) path for a specified VRF. Expected Results ---------------- @@ -97,7 +94,6 @@ class VerifyAVTSpecificPath(AntaTest): ``` """ - name = "VerifyAVTSpecificPath" description = "Verifies the status and type of an AVT path for a specified VRF." categories: ClassVar[list[str]] = ["avt"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ @@ -191,8 +187,7 @@ def test(self) -> None: class VerifyAVTRole(AntaTest): - """ - Verifies the Adaptive Virtual Topology (AVT) role of a device. + """Verifies the Adaptive Virtual Topology (AVT) role of a device. Expected Results ---------------- @@ -208,7 +203,6 @@ class VerifyAVTRole(AntaTest): ``` """ - name = "VerifyAVTRole" description = "Verifies the AVT role of a device." categories: ClassVar[list[str]] = ["avt"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show adaptive-virtual-topology path")] diff --git a/anta/tests/bfd.py b/anta/tests/bfd.py index f42d80de7..b48cf27c0 100644 --- a/anta/tests/bfd.py +++ b/anta/tests/bfd.py @@ -42,7 +42,6 @@ class VerifyBFDSpecificPeers(AntaTest): ``` """ - name = "VerifyBFDSpecificPeers" description = "Verifies the IPv4 BFD peer's sessions and remote disc in the specified VRF." categories: ClassVar[list[str]] = ["bfd"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bfd peers", revision=1)] @@ -123,8 +122,6 @@ class VerifyBFDPeersIntervals(AntaTest): ``` """ - name = "VerifyBFDPeersIntervals" - description = "Verifies the timers of the IPv4 BFD peers in the specified VRF." categories: ClassVar[list[str]] = ["bfd"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bfd peers detail", revision=1)] @@ -218,8 +215,6 @@ class VerifyBFDPeersHealth(AntaTest): ``` """ - name = "VerifyBFDPeersHealth" - description = "Verifies the health of all IPv4 BFD peers." categories: ClassVar[list[str]] = ["bfd"] # revision 1 as later revision introduces additional nesting for type commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ @@ -308,8 +303,6 @@ class VerifyBFDPeersRegProtocols(AntaTest): ``` """ - name = "VerifyBFDPeersRegProtocols" - description = "Verifies that IPv4 BFD peer(s) have the specified protocol(s) registered." categories: ClassVar[list[str]] = ["bfd"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bfd peers detail", revision=1)] diff --git a/anta/tests/configuration.py b/anta/tests/configuration.py index 186deaf2d..376e08ba4 100644 --- a/anta/tests/configuration.py +++ b/anta/tests/configuration.py @@ -33,8 +33,6 @@ class VerifyZeroTouch(AntaTest): ``` """ - name = "VerifyZeroTouch" - description = "Verifies ZeroTouch is disabled" categories: ClassVar[list[str]] = ["configuration"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show zerotouch", revision=1)] @@ -64,8 +62,6 @@ class VerifyRunningConfigDiffs(AntaTest): ``` """ - name = "VerifyRunningConfigDiffs" - description = "Verifies there is no difference between the running-config and the startup-config" categories: ClassVar[list[str]] = ["configuration"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show running-config diffs", ofmt="text")] @@ -104,7 +100,6 @@ class VerifyRunningConfigLines(AntaTest): ``` """ - name = "VerifyRunningConfigLines" description = "Search the Running-Config for the given RegEx patterns." categories: ClassVar[list[str]] = ["configuration"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show running-config", ofmt="text")] diff --git a/anta/tests/connectivity.py b/anta/tests/connectivity.py index c0c6f731b..4174c1a9a 100644 --- a/anta/tests/connectivity.py +++ b/anta/tests/connectivity.py @@ -43,8 +43,6 @@ class VerifyReachability(AntaTest): ``` """ - name = "VerifyReachability" - description = "Test the network reachability to one or many destination IP(s)." categories: ClassVar[list[str]] = ["connectivity"] # Removing the between '{size}' and '{df_bit}' to compensate the df-bit set default value # i.e if df-bit kept disable then it will add redundant space in between the command @@ -129,7 +127,6 @@ class VerifyLLDPNeighbors(AntaTest): ``` """ - name = "VerifyLLDPNeighbors" description = "Verifies that the provided LLDP neighbors are connected properly." categories: ClassVar[list[str]] = ["connectivity"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show lldp neighbors detail", revision=1)] diff --git a/anta/tests/field_notices.py b/anta/tests/field_notices.py index 6f98a2c9a..4594c380f 100644 --- a/anta/tests/field_notices.py +++ b/anta/tests/field_notices.py @@ -34,7 +34,6 @@ class VerifyFieldNotice44Resolution(AntaTest): ``` """ - name = "VerifyFieldNotice44Resolution" description = "Verifies that the device is using the correct Aboot version per FN0044." categories: ClassVar[list[str]] = ["field notices"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show version detail", revision=1)] @@ -143,7 +142,6 @@ class VerifyFieldNotice72Resolution(AntaTest): ``` """ - name = "VerifyFieldNotice72Resolution" description = "Verifies if the device is exposed to FN0072, and if the issue has been mitigated." categories: ClassVar[list[str]] = ["field notices"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show version detail", revision=1)] diff --git a/anta/tests/flow_tracking.py b/anta/tests/flow_tracking.py index 676bdb4f0..c50a36799 100644 --- a/anta/tests/flow_tracking.py +++ b/anta/tests/flow_tracking.py @@ -17,8 +17,7 @@ def validate_record_export(record_export: dict[str, str], tracker_info: dict[str, str]) -> str: - """ - Validate the record export configuration against the tracker info. + """Validate the record export configuration against the tracker info. Parameters ---------- @@ -41,8 +40,7 @@ def validate_record_export(record_export: dict[str, str], tracker_info: dict[str def validate_exporters(exporters: list[dict[str, str]], tracker_info: dict[str, str]) -> str: - """ - Validate the exporter configurations against the tracker info. + """Validate the exporter configurations against the tracker info. Parameters ---------- @@ -74,8 +72,7 @@ def validate_exporters(exporters: list[dict[str, str]], tracker_info: dict[str, class VerifyHardwareFlowTrackerStatus(AntaTest): - """ - Verifies if hardware flow tracking is running and an input tracker is active. + """Verifies if hardware flow tracking is running and an input tracker is active. This test optionally verifies the tracker interval/timeout and exporter configuration. @@ -102,7 +99,6 @@ class VerifyHardwareFlowTrackerStatus(AntaTest): ``` """ - name = "VerifyHardwareFlowTrackerStatus" description = ( "Verifies if hardware flow tracking is running and an input tracker is active. Optionally verifies the tracker interval/timeout and exporter configuration." ) diff --git a/anta/tests/greent.py b/anta/tests/greent.py index b7632422b..97ac46df2 100644 --- a/anta/tests/greent.py +++ b/anta/tests/greent.py @@ -29,7 +29,6 @@ class VerifyGreenTCounters(AntaTest): ``` """ - name = "VerifyGreenTCounters" description = "Verifies if the GreenT counters are incremented." categories: ClassVar[list[str]] = ["greent"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show monitor telemetry postcard counters", revision=1)] @@ -61,8 +60,7 @@ class VerifyGreenT(AntaTest): ``` """ - name = "VerifyGreenT" - description = "Verifies if a GreenT policy is created." + description = "Verifies if a GreenT policy other than the default is created." categories: ClassVar[list[str]] = ["greent"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show monitor telemetry postcard policy profile", revision=1)] diff --git a/anta/tests/hardware.py b/anta/tests/hardware.py index 569c180d7..1c562b000 100644 --- a/anta/tests/hardware.py +++ b/anta/tests/hardware.py @@ -36,8 +36,6 @@ class VerifyTransceiversManufacturers(AntaTest): ``` """ - name = "VerifyTransceiversManufacturers" - description = "Verifies if all transceivers come from approved manufacturers." categories: ClassVar[list[str]] = ["hardware"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show inventory", revision=2)] @@ -77,8 +75,6 @@ class VerifyTemperature(AntaTest): ``` """ - name = "VerifyTemperature" - description = "Verifies the device temperature." categories: ClassVar[list[str]] = ["hardware"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show system environment temperature", revision=1)] @@ -110,8 +106,6 @@ class VerifyTransceiversTemperature(AntaTest): ``` """ - name = "VerifyTransceiversTemperature" - description = "Verifies the transceivers temperature." categories: ClassVar[list[str]] = ["hardware"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show system environment temperature transceiver", revision=1)] @@ -151,8 +145,6 @@ class VerifyEnvironmentSystemCooling(AntaTest): ``` """ - name = "VerifyEnvironmentSystemCooling" - description = "Verifies the system cooling status." categories: ClassVar[list[str]] = ["hardware"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show system environment cooling", revision=1)] @@ -232,8 +224,6 @@ class VerifyEnvironmentPower(AntaTest): ``` """ - name = "VerifyEnvironmentPower" - description = "Verifies the power supplies status." categories: ClassVar[list[str]] = ["hardware"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show system environment power", revision=1)] @@ -274,7 +264,6 @@ class VerifyAdverseDrops(AntaTest): ``` """ - name = "VerifyAdverseDrops" description = "Verifies there are no adverse drops on DCS-7280 and DCS-7500 family switches." categories: ClassVar[list[str]] = ["hardware"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show hardware counter drop", revision=1)] diff --git a/anta/tests/interfaces.py b/anta/tests/interfaces.py index 32b85d493..5dab16729 100644 --- a/anta/tests/interfaces.py +++ b/anta/tests/interfaces.py @@ -44,8 +44,6 @@ class VerifyInterfaceUtilization(AntaTest): ``` """ - name = "VerifyInterfaceUtilization" - description = "Verifies that the utilization of interfaces is below a certain threshold." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaCommand(command="show interfaces counters rates", revision=1), @@ -105,8 +103,6 @@ class VerifyInterfaceErrors(AntaTest): ``` """ - name = "VerifyInterfaceErrors" - description = "Verifies there are no interface error counters." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces counters errors", revision=1)] @@ -140,8 +136,6 @@ class VerifyInterfaceDiscards(AntaTest): ``` """ - name = "VerifyInterfaceDiscards" - description = "Verifies there are no interface discard counters." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces counters discards", revision=1)] @@ -174,8 +168,6 @@ class VerifyInterfaceErrDisabled(AntaTest): ``` """ - name = "VerifyInterfaceErrDisabled" - description = "Verifies there are no interfaces in the errdisabled state." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces status", revision=1)] @@ -219,8 +211,6 @@ class VerifyInterfacesStatus(AntaTest): ``` """ - name = "VerifyInterfacesStatus" - description = "Verifies the status of the provided interfaces." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces description", revision=1)] @@ -291,8 +281,6 @@ class VerifyStormControlDrops(AntaTest): ``` """ - name = "VerifyStormControlDrops" - description = "Verifies there are no interface storm-control drop counters." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show storm-control", revision=1)] @@ -329,8 +317,6 @@ class VerifyPortChannels(AntaTest): ``` """ - name = "VerifyPortChannels" - description = "Verifies there are no inactive ports in all port channels." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show port-channel", revision=1)] @@ -364,8 +350,6 @@ class VerifyIllegalLACP(AntaTest): ``` """ - name = "VerifyIllegalLACP" - description = "Verifies there are no illegal LACP packets in all port channels." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show lacp counters all-ports", revision=1)] @@ -401,7 +385,6 @@ class VerifyLoopbackCount(AntaTest): ``` """ - name = "VerifyLoopbackCount" description = "Verifies the number of loopback interfaces and their status." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip interface brief", revision=1)] @@ -450,8 +433,6 @@ class VerifySVI(AntaTest): ``` """ - name = "VerifySVI" - description = "Verifies the status of all SVIs." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip interface brief", revision=1)] @@ -495,7 +476,6 @@ class VerifyL3MTU(AntaTest): ``` """ - name = "VerifyL3MTU" description = "Verifies the global L3 MTU of all L3 interfaces." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces", revision=1)] @@ -553,7 +533,6 @@ class VerifyIPProxyARP(AntaTest): ``` """ - name = "VerifyIPProxyARP" description = "Verifies if Proxy ARP is enabled." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show ip interface {intf}", revision=2)] @@ -607,7 +586,6 @@ class VerifyL2MTU(AntaTest): ``` """ - name = "VerifyL2MTU" description = "Verifies the global L2 MTU of all L2 interfaces." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces", revision=1)] @@ -669,7 +647,6 @@ class VerifyInterfaceIPv4(AntaTest): ``` """ - name = "VerifyInterfaceIPv4" description = "Verifies the interface IPv4 addresses." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show ip interface {interface}", revision=2)] @@ -765,8 +742,6 @@ class VerifyIpVirtualRouterMac(AntaTest): ``` """ - name = "VerifyIpVirtualRouterMac" - description = "Verifies the IP virtual router MAC address." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip virtual-router", revision=2)] @@ -818,8 +793,6 @@ class VerifyInterfacesSpeed(AntaTest): ``` """ - name = "VerifyInterfacesSpeed" - description = "Verifies the speed, lanes, auto-negotiation status, and mode as full duplex for interfaces." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces")] @@ -909,8 +882,6 @@ class VerifyLACPInterfacesStatus(AntaTest): ``` """ - name = "VerifyLACPInterfacesStatus" - description = "Verifies the Link Aggregation Control Protocol(LACP) status of the provided interfaces." categories: ClassVar[list[str]] = ["interfaces"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show lacp interface {interface}", revision=1)] diff --git a/anta/tests/lanz.py b/anta/tests/lanz.py index dcdab69db..0995af7c9 100644 --- a/anta/tests/lanz.py +++ b/anta/tests/lanz.py @@ -30,7 +30,6 @@ class VerifyLANZ(AntaTest): ``` """ - name = "VerifyLANZ" description = "Verifies if LANZ is enabled." categories: ClassVar[list[str]] = ["lanz"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show queue-monitor length status", revision=1)] diff --git a/anta/tests/logging.py b/anta/tests/logging.py index 2972b4ec8..74ae875c7 100644 --- a/anta/tests/logging.py +++ b/anta/tests/logging.py @@ -59,8 +59,6 @@ class VerifyLoggingPersistent(AntaTest): ``` """ - name = "VerifyLoggingPersistent" - description = "Verifies if logging persistent is enabled and logs are saved in flash." categories: ClassVar[list[str]] = ["logging"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaCommand(command="show logging", ofmt="text"), @@ -100,8 +98,6 @@ class VerifyLoggingSourceIntf(AntaTest): ``` """ - name = "VerifyLoggingSourceIntf" - description = "Verifies logging source-interface for a specified VRF." categories: ClassVar[list[str]] = ["logging"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show logging", ofmt="text")] @@ -144,8 +140,6 @@ class VerifyLoggingHosts(AntaTest): ``` """ - name = "VerifyLoggingHosts" - description = "Verifies logging hosts (syslog servers) for a specified VRF." categories: ClassVar[list[str]] = ["logging"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show logging", ofmt="text")] @@ -189,8 +183,6 @@ class VerifyLoggingLogsGeneration(AntaTest): ``` """ - name = "VerifyLoggingLogsGeneration" - description = "Verifies if logs are generated." categories: ClassVar[list[str]] = ["logging"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaCommand(command="send log level informational message ANTA VerifyLoggingLogsGeneration validation", ofmt="text"), @@ -226,8 +218,6 @@ class VerifyLoggingHostname(AntaTest): ``` """ - name = "VerifyLoggingHostname" - description = "Verifies if logs are generated with the device FQDN." categories: ClassVar[list[str]] = ["logging"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaCommand(command="show hostname", revision=1), @@ -270,8 +260,6 @@ class VerifyLoggingTimestamp(AntaTest): ``` """ - name = "VerifyLoggingTimestamp" - description = "Verifies if logs are generated with the appropriate timestamp." categories: ClassVar[list[str]] = ["logging"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaCommand(command="send log level informational message ANTA VerifyLoggingTimestamp validation", ofmt="text"), @@ -312,8 +300,6 @@ class VerifyLoggingAccounting(AntaTest): ``` """ - name = "VerifyLoggingAccounting" - description = "Verifies if AAA accounting logs are generated." categories: ClassVar[list[str]] = ["logging"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show aaa accounting logs | tail", ofmt="text")] @@ -344,8 +330,6 @@ class VerifyLoggingErrors(AntaTest): ``` """ - name = "VerifyLoggingErrors" - description = "Verifies there are no syslog messages with a severity of ERRORS or higher." categories: ClassVar[list[str]] = ["logging"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show logging threshold errors", ofmt="text")] diff --git a/anta/tests/mlag.py b/anta/tests/mlag.py index c894b98b6..e353420c9 100644 --- a/anta/tests/mlag.py +++ b/anta/tests/mlag.py @@ -36,8 +36,6 @@ class VerifyMlagStatus(AntaTest): ``` """ - name = "VerifyMlagStatus" - description = "Verifies the health status of the MLAG configuration." categories: ClassVar[list[str]] = ["mlag"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show mlag", revision=2)] @@ -78,8 +76,6 @@ class VerifyMlagInterfaces(AntaTest): ``` """ - name = "VerifyMlagInterfaces" - description = "Verifies there are no inactive or active-partial MLAG ports." categories: ClassVar[list[str]] = ["mlag"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show mlag", revision=2)] @@ -114,8 +110,6 @@ class VerifyMlagConfigSanity(AntaTest): ``` """ - name = "VerifyMlagConfigSanity" - description = "Verifies there are no MLAG config-sanity inconsistencies." categories: ClassVar[list[str]] = ["mlag"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show mlag config-sanity", revision=1)] @@ -153,8 +147,6 @@ class VerifyMlagReloadDelay(AntaTest): ``` """ - name = "VerifyMlagReloadDelay" - description = "Verifies the MLAG reload-delay parameters." categories: ClassVar[list[str]] = ["mlag"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show mlag", revision=2)] @@ -203,7 +195,6 @@ class VerifyMlagDualPrimary(AntaTest): ``` """ - name = "VerifyMlagDualPrimary" description = "Verifies the MLAG dual-primary detection parameters." categories: ClassVar[list[str]] = ["mlag"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show mlag detail", revision=2)] @@ -262,7 +253,6 @@ class VerifyMlagPrimaryPriority(AntaTest): ``` """ - name = "VerifyMlagPrimaryPriority" description = "Verifies the configuration of the MLAG primary priority." categories: ClassVar[list[str]] = ["mlag"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show mlag detail", revision=2)] diff --git a/anta/tests/multicast.py b/anta/tests/multicast.py index 554bd5759..f6e84babc 100644 --- a/anta/tests/multicast.py +++ b/anta/tests/multicast.py @@ -35,8 +35,6 @@ class VerifyIGMPSnoopingVlans(AntaTest): ``` """ - name = "VerifyIGMPSnoopingVlans" - description = "Verifies the IGMP snooping status for the provided VLANs." categories: ClassVar[list[str]] = ["multicast"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip igmp snooping", revision=1)] @@ -78,8 +76,6 @@ class VerifyIGMPSnoopingGlobal(AntaTest): ``` """ - name = "VerifyIGMPSnoopingGlobal" - description = "Verifies the IGMP snooping global configuration." categories: ClassVar[list[str]] = ["multicast"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip igmp snooping", revision=1)] diff --git a/anta/tests/path_selection.py b/anta/tests/path_selection.py index 416cb8c4a..15b06aef2 100644 --- a/anta/tests/path_selection.py +++ b/anta/tests/path_selection.py @@ -18,8 +18,7 @@ class VerifyPathsHealth(AntaTest): - """ - Verifies the path and telemetry state of all paths under router path-selection. + """Verifies the path and telemetry state of all paths under router path-selection. The expected states are 'IPsec established', 'Resolved' for path and 'active' for telemetry. @@ -38,8 +37,6 @@ class VerifyPathsHealth(AntaTest): ``` """ - name = "VerifyPathsHealth" - description = "Verifies the path and telemetry state of all paths under router path-selection." categories: ClassVar[list[str]] = ["path-selection"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show path-selection paths", revision=1)] @@ -73,8 +70,7 @@ def test(self) -> None: class VerifySpecificPath(AntaTest): - """ - Verifies the path and telemetry state of a specific path for an IPv4 peer under router path-selection. + """Verifies the path and telemetry state of a specific path for an IPv4 peer under router path-selection. The expected states are 'IPsec established', 'Resolved' for path and 'active' for telemetry. @@ -98,8 +94,6 @@ class VerifySpecificPath(AntaTest): ``` """ - name = "VerifySpecificPath" - description = "Verifies the path and telemetry state of a specific path under router path-selection." categories: ClassVar[list[str]] = ["path-selection"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaTemplate(template="show path-selection paths peer {peer} path-group {group} source {source} destination {destination}", revision=1) diff --git a/anta/tests/profiles.py b/anta/tests/profiles.py index 859c8866c..93edacd59 100644 --- a/anta/tests/profiles.py +++ b/anta/tests/profiles.py @@ -33,7 +33,6 @@ class VerifyUnifiedForwardingTableMode(AntaTest): ``` """ - name = "VerifyUnifiedForwardingTableMode" description = "Verifies the device is using the expected UFT mode." categories: ClassVar[list[str]] = ["profiles"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show platform trident forwarding-table partition", revision=1)] @@ -72,7 +71,6 @@ class VerifyTcamProfile(AntaTest): ``` """ - name = "VerifyTcamProfile" description = "Verifies the device TCAM profile." categories: ClassVar[list[str]] = ["profiles"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show hardware tcam profile", revision=1)] diff --git a/anta/tests/ptp.py b/anta/tests/ptp.py index cbb8ee357..687f17517 100644 --- a/anta/tests/ptp.py +++ b/anta/tests/ptp.py @@ -33,7 +33,6 @@ class VerifyPtpModeStatus(AntaTest): ``` """ - name = "VerifyPtpModeStatus" description = "Verifies that the device is configured as a PTP Boundary Clock." categories: ClassVar[list[str]] = ["ptp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ptp", revision=2)] @@ -80,7 +79,6 @@ class Input(AntaTest.Input): gmid: str """Identifier of the Grandmaster to which the device should be locked.""" - name = "VerifyPtpGMStatus" description = "Verifies that the device is locked to a valid PTP Grandmaster." categories: ClassVar[list[str]] = ["ptp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ptp", revision=2)] @@ -120,7 +118,6 @@ class VerifyPtpLockStatus(AntaTest): ``` """ - name = "VerifyPtpLockStatus" description = "Verifies that the device was locked to the upstream PTP GM in the last minute." categories: ClassVar[list[str]] = ["ptp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ptp", revision=2)] @@ -161,7 +158,6 @@ class VerifyPtpOffset(AntaTest): ``` """ - name = "VerifyPtpOffset" description = "Verifies that the PTP timing offset is within +/- 1000ns from the master clock." categories: ClassVar[list[str]] = ["ptp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ptp monitor", revision=1)] @@ -206,7 +202,6 @@ class VerifyPtpPortModeStatus(AntaTest): ``` """ - name = "VerifyPtpPortModeStatus" description = "Verifies the PTP interfaces state." categories: ClassVar[list[str]] = ["ptp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ptp", revision=2)] diff --git a/anta/tests/routing/bgp.py b/anta/tests/routing/bgp.py index a37328608..e573f3f71 100644 --- a/anta/tests/routing/bgp.py +++ b/anta/tests/routing/bgp.py @@ -209,7 +209,6 @@ class VerifyBGPPeerCount(AntaTest): ``` """ - name = "VerifyBGPPeerCount" description = "Verifies the count of BGP peers." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ @@ -351,8 +350,6 @@ class VerifyBGPPeersHealth(AntaTest): ``` """ - name = "VerifyBGPPeersHealth" - description = "Verifies the health of BGP peers" categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaTemplate(template="show bgp {afi} {safi} summary vrf {vrf}", revision=3), @@ -494,8 +491,6 @@ class VerifyBGPSpecificPeers(AntaTest): ``` """ - name = "VerifyBGPSpecificPeers" - description = "Verifies the health of specific BGP peer(s)." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaTemplate(template="show bgp {afi} {safi} summary vrf {vrf}", revision=3), @@ -610,7 +605,7 @@ def test(self) -> None: class VerifyBGPExchangedRoutes(AntaTest): - """Verifies if the BGP peers have correctly advertised and received routes. + """Verifies the advertised and received routes of BGP peers. The route type should be 'valid' and 'active' for a specified VRF. @@ -642,8 +637,6 @@ class VerifyBGPExchangedRoutes(AntaTest): ``` """ - name = "VerifyBGPExchangedRoutes" - description = "Verifies the advertised and received routes of BGP peers." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaTemplate(template="show bgp neighbors {peer} advertised-routes vrf {vrf}", revision=3), @@ -734,7 +727,6 @@ class VerifyBGPPeerMPCaps(AntaTest): ``` """ - name = "VerifyBGPPeerMPCaps" description = "Verifies the multiprotocol capabilities of a BGP peer." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bgp neighbors vrf all", revision=3)] @@ -829,7 +821,6 @@ class VerifyBGPPeerASNCap(AntaTest): ``` """ - name = "VerifyBGPPeerASNCap" description = "Verifies the four octet asn capabilities of a BGP peer." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bgp neighbors vrf all", revision=3)] @@ -907,7 +898,6 @@ class VerifyBGPPeerRouteRefreshCap(AntaTest): ``` """ - name = "VerifyBGPPeerRouteRefreshCap" description = "Verifies the route refresh capabilities of a BGP peer." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bgp neighbors vrf all", revision=3)] @@ -987,7 +977,6 @@ class VerifyBGPPeerMD5Auth(AntaTest): ``` """ - name = "VerifyBGPPeerMD5Auth" description = "Verifies the MD5 authentication and state of a BGP peer." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bgp neighbors vrf all", revision=3)] @@ -1062,8 +1051,6 @@ class VerifyEVPNType2Route(AntaTest): ``` """ - name = "VerifyEVPNType2Route" - description = "Verifies the EVPN Type-2 routes for a given IPv4 or MAC address and VNI." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show bgp evpn route-type mac-ip {address} vni {vni}", revision=2)] @@ -1139,7 +1126,6 @@ class VerifyBGPAdvCommunities(AntaTest): ``` """ - name = "VerifyBGPAdvCommunities" description = "Verifies the advertised communities of a BGP peer." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bgp neighbors vrf all", revision=3)] @@ -1216,7 +1202,6 @@ class VerifyBGPTimers(AntaTest): ``` """ - name = "VerifyBGPTimers" description = "Verifies the timers of a BGP peer." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show bgp neighbors vrf all", revision=3)] @@ -1295,8 +1280,6 @@ class VerifyBGPPeerDropStats(AntaTest): ``` """ - name = "VerifyBGPPeerDropStats" - description = "Verifies the NLRI drop statistics of a BGP IPv4 peer(s)." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show bgp neighbors {peer} vrf {vrf}", revision=3)] @@ -1384,8 +1367,6 @@ class VerifyBGPPeerUpdateErrors(AntaTest): ``` """ - name = "VerifyBGPPeerUpdateErrors" - description = "Verifies the update error counters of a BGP IPv4 peer." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show bgp neighbors {peer} vrf {vrf}", revision=3)] @@ -1469,8 +1450,6 @@ class VerifyBgpRouteMaps(AntaTest): ``` """ - name = "VerifyBgpRouteMaps" - description = "Verifies BGP inbound and outbound route-maps of BGP IPv4 peer(s)." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show bgp neighbors {peer} vrf {vrf}", revision=3)] @@ -1567,8 +1546,6 @@ class VerifyBGPPeerRouteLimit(AntaTest): ``` """ - name = "VerifyBGPPeerRouteLimit" - description = "Verifies maximum routes and maximum routes warning limit for the provided BGP IPv4 peer(s)." categories: ClassVar[list[str]] = ["bgp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show bgp neighbors {peer} vrf {vrf}", revision=3)] diff --git a/anta/tests/routing/generic.py b/anta/tests/routing/generic.py index d1322a50d..fb9e3175d 100644 --- a/anta/tests/routing/generic.py +++ b/anta/tests/routing/generic.py @@ -26,7 +26,7 @@ class VerifyRoutingProtocolModel(AntaTest): - """Verifies the configured routing protocol model is the one we expect. + """Verifies the configured routing protocol model. Expected Results ---------------- @@ -43,8 +43,6 @@ class VerifyRoutingProtocolModel(AntaTest): ``` """ - name = "VerifyRoutingProtocolModel" - description = "Verifies the configured routing protocol model." categories: ClassVar[list[str]] = ["routing"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip route summary", revision=3)] @@ -85,8 +83,6 @@ class VerifyRoutingTableSize(AntaTest): ``` """ - name = "VerifyRoutingTableSize" - description = "Verifies the size of the IP routing table of the default VRF." categories: ClassVar[list[str]] = ["routing"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip route summary", revision=3)] @@ -138,8 +134,6 @@ class VerifyRoutingTableEntry(AntaTest): ``` """ - name = "VerifyRoutingTableEntry" - description = "Verifies that the provided routes are present in the routing table of a specified VRF." categories: ClassVar[list[str]] = ["routing"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaTemplate(template="show ip route vrf {vrf} {route}", revision=4), diff --git a/anta/tests/routing/isis.py b/anta/tests/routing/isis.py index 684578ce1..f57c08275 100644 --- a/anta/tests/routing/isis.py +++ b/anta/tests/routing/isis.py @@ -158,8 +158,6 @@ class VerifyISISNeighborState(AntaTest): ``` """ - name = "VerifyISISNeighborState" - description = "Verifies all IS-IS neighbors are in UP state." categories: ClassVar[list[str]] = ["isis"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis neighbors", revision=1)] @@ -204,8 +202,6 @@ class VerifyISISNeighborCount(AntaTest): ``` """ - name = "VerifyISISNeighborCount" - description = "Verifies count of IS-IS interface per level" categories: ClassVar[list[str]] = ["isis"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis interface brief", revision=1)] @@ -277,7 +273,6 @@ class VerifyISISInterfaceMode(AntaTest): ``` """ - name = "VerifyISISInterfaceMode" description = "Verifies interface mode for IS-IS" categories: ClassVar[list[str]] = ["isis"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis interface brief", revision=1)] @@ -333,9 +328,7 @@ def test(self) -> None: class VerifyISISSegmentRoutingAdjacencySegments(AntaTest): - """Verifies ISIS Segment Routing Adjacency Segments. - - Verify that all expected Adjacency segments are correctly visible for each interface. + """Verify that all expected Adjacency segments are correctly visible for each interface. Expected Results ---------------- @@ -360,8 +353,6 @@ class VerifyISISSegmentRoutingAdjacencySegments(AntaTest): ``` """ - name = "VerifyISISSegmentRoutingAdjacencySegments" - description = "Verify expected Adjacency segments are correctly visible for each interface." categories: ClassVar[list[str]] = ["isis", "segment-routing"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis segment-routing adjacency-segments", ofmt="json")] @@ -446,8 +437,7 @@ def test(self) -> None: class VerifyISISSegmentRoutingDataplane(AntaTest): - """ - Verify dataplane of a list of ISIS-SR instances. + """Verify dataplane of a list of ISIS-SR instances. Expected Results ---------------- @@ -468,8 +458,6 @@ class VerifyISISSegmentRoutingDataplane(AntaTest): ``` """ - name = "VerifyISISSegmentRoutingDataplane" - description = "Verify dataplane of a list of ISIS-SR instances" categories: ClassVar[list[str]] = ["isis", "segment-routing"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis segment-routing", ofmt="json")] @@ -530,8 +518,7 @@ def test(self) -> None: class VerifyISISSegmentRoutingTunnels(AntaTest): - """ - Verify ISIS-SR tunnels computed by device. + """Verify ISIS-SR tunnels computed by device. Expected Results ---------------- @@ -561,8 +548,6 @@ class VerifyISISSegmentRoutingTunnels(AntaTest): ``` """ - name = "VerifyISISSegmentRoutingTunnels" - description = "Verify ISIS-SR tunnels computed by device" categories: ClassVar[list[str]] = ["isis", "segment-routing"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show isis segment-routing tunnel", ofmt="json")] @@ -638,8 +623,7 @@ def test(self) -> None: self.result.is_failure("\n".join(failure_message)) def _check_tunnel_type(self, via_input: VerifyISISSegmentRoutingTunnels.Input.Entry.Vias, eos_entry: dict[str, Any]) -> bool: - """ - Check if the tunnel type specified in `via_input` matches any of the tunnel types in `eos_entry`. + """Check if the tunnel type specified in `via_input` matches any of the tunnel types in `eos_entry`. Parameters ---------- @@ -666,8 +650,7 @@ def _check_tunnel_type(self, via_input: VerifyISISSegmentRoutingTunnels.Input.En return True def _check_tunnel_nexthop(self, via_input: VerifyISISSegmentRoutingTunnels.Input.Entry.Vias, eos_entry: dict[str, Any]) -> bool: - """ - Check if the tunnel nexthop matches the given input. + """Check if the tunnel nexthop matches the given input. Parameters ---------- @@ -694,8 +677,7 @@ def _check_tunnel_nexthop(self, via_input: VerifyISISSegmentRoutingTunnels.Input return True def _check_tunnel_interface(self, via_input: VerifyISISSegmentRoutingTunnels.Input.Entry.Vias, eos_entry: dict[str, Any]) -> bool: - """ - Check if the tunnel interface exists in the given EOS entry. + """Check if the tunnel interface exists in the given EOS entry. Parameters ---------- @@ -722,8 +704,7 @@ def _check_tunnel_interface(self, via_input: VerifyISISSegmentRoutingTunnels.Inp return True def _check_tunnel_id(self, via_input: VerifyISISSegmentRoutingTunnels.Input.Entry.Vias, eos_entry: dict[str, Any]) -> bool: - """ - Check if the tunnel ID matches any of the tunnel IDs in the EOS entry's vias. + """Check if the tunnel ID matches any of the tunnel IDs in the EOS entry's vias. Parameters ---------- diff --git a/anta/tests/routing/ospf.py b/anta/tests/routing/ospf.py index 3ffd81d53..d5d12e29e 100644 --- a/anta/tests/routing/ospf.py +++ b/anta/tests/routing/ospf.py @@ -109,8 +109,6 @@ class VerifyOSPFNeighborState(AntaTest): ``` """ - name = "VerifyOSPFNeighborState" - description = "Verifies all OSPF neighbors are in FULL state." categories: ClassVar[list[str]] = ["ospf"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip ospf neighbor", revision=1)] @@ -146,8 +144,6 @@ class VerifyOSPFNeighborCount(AntaTest): ``` """ - name = "VerifyOSPFNeighborCount" - description = "Verifies the number of OSPF neighbors in FULL state is the one we expect." categories: ClassVar[list[str]] = ["ospf"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip ospf neighbor", revision=1)] @@ -190,7 +186,6 @@ class VerifyOSPFMaxLSA(AntaTest): ``` """ - name = "VerifyOSPFMaxLSA" description = "Verifies all OSPF instances did not cross the maximum LSA threshold." categories: ClassVar[list[str]] = ["ospf"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip ospf", revision=1)] diff --git a/anta/tests/security.py b/anta/tests/security.py index 71c9f12ee..13a48e577 100644 --- a/anta/tests/security.py +++ b/anta/tests/security.py @@ -42,8 +42,6 @@ class VerifySSHStatus(AntaTest): ``` """ - name = "VerifySSHStatus" - description = "Verifies if the SSHD agent is disabled in the default VRF." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management ssh", ofmt="text")] @@ -83,7 +81,6 @@ class VerifySSHIPv4Acl(AntaTest): ``` """ - name = "VerifySSHIPv4Acl" description = "Verifies if the SSHD agent has IPv4 ACL(s) configured." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management ssh ip access-list summary", revision=1)] @@ -132,7 +129,6 @@ class VerifySSHIPv6Acl(AntaTest): ``` """ - name = "VerifySSHIPv6Acl" description = "Verifies if the SSHD agent has IPv6 ACL(s) configured." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management ssh ipv6 access-list summary", revision=1)] @@ -179,8 +175,6 @@ class VerifyTelnetStatus(AntaTest): ``` """ - name = "VerifyTelnetStatus" - description = "Verifies if Telnet is disabled in the default VRF." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management telnet", revision=1)] @@ -210,8 +204,6 @@ class VerifyAPIHttpStatus(AntaTest): ``` """ - name = "VerifyAPIHttpStatus" - description = "Verifies if eAPI HTTP server is disabled globally." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management api http-commands", revision=1)] @@ -242,7 +234,6 @@ class VerifyAPIHttpsSSL(AntaTest): ``` """ - name = "VerifyAPIHttpsSSL" description = "Verifies if the eAPI has a valid SSL profile." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management api http-commands", revision=1)] @@ -285,8 +276,6 @@ class VerifyAPIIPv4Acl(AntaTest): ``` """ - name = "VerifyAPIIPv4Acl" - description = "Verifies if eAPI has the right number IPv4 ACL(s) configured for a specified VRF." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management api http-commands ip access-list summary", revision=1)] @@ -335,8 +324,6 @@ class VerifyAPIIPv6Acl(AntaTest): ``` """ - name = "VerifyAPIIPv6Acl" - description = "Verifies if eAPI has the right number IPv6 ACL(s) configured for a specified VRF." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management api http-commands ipv6 access-list summary", revision=1)] @@ -395,8 +382,6 @@ class VerifyAPISSLCertificate(AntaTest): ``` """ - name = "VerifyAPISSLCertificate" - description = "Verifies the eAPI SSL certificate expiry, common subject name, encryption algorithm and key size." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaCommand(command="show management security ssl certificate", revision=1), @@ -505,8 +490,6 @@ class VerifyBannerLogin(AntaTest): ``` """ - name = "VerifyBannerLogin" - description = "Verifies the login banner of a device." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show banner login", revision=1)] @@ -549,8 +532,6 @@ class VerifyBannerMotd(AntaTest): ``` """ - name = "VerifyBannerMotd" - description = "Verifies the motd banner of a device." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show banner motd", revision=1)] @@ -604,8 +585,6 @@ class VerifyIPv4ACL(AntaTest): ``` """ - name = "VerifyIPv4ACL" - description = "Verifies the configuration of IPv4 ACLs." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show ip access-lists {acl}", revision=1)] @@ -669,8 +648,7 @@ def test(self) -> None: class VerifyIPSecConnHealth(AntaTest): - """ - Verifies all IPv4 security connections. + """Verifies all IPv4 security connections. Expected Results ---------------- @@ -685,8 +663,6 @@ class VerifyIPSecConnHealth(AntaTest): ``` """ - name = "VerifyIPSecConnHealth" - description = "Verifies all IPv4 security connections." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip security connection vrf all")] @@ -716,8 +692,7 @@ def test(self) -> None: class VerifySpecificIPSecConn(AntaTest): - """ - Verifies the state of IPv4 security connections for a specified peer. + """Verifies the state of IPv4 security connections for a specified peer. It optionally allows for the verification of a specific path for a peer by providing source and destination addresses. If these addresses are not provided, it will verify all paths for the specified peer. @@ -744,7 +719,6 @@ class VerifySpecificIPSecConn(AntaTest): ``` """ - name = "VerifySpecificIPSecConn" description = "Verifies IPv4 security connections for a peer." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show ip security connection vrf {vrf} path peer {peer}")] @@ -831,8 +805,7 @@ def test(self) -> None: class VerifyHardwareEntropy(AntaTest): - """ - Verifies hardware entropy generation is enabled on device. + """Verifies hardware entropy generation is enabled on device. Expected Results ---------------- @@ -847,8 +820,6 @@ class VerifyHardwareEntropy(AntaTest): ``` """ - name = "VerifyHardwareEntropy" - description = "Verifies hardware entropy generation is enabled on device." categories: ClassVar[list[str]] = ["security"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show management security")] diff --git a/anta/tests/services.py b/anta/tests/services.py index 618426350..4b1e45d0c 100644 --- a/anta/tests/services.py +++ b/anta/tests/services.py @@ -34,8 +34,6 @@ class VerifyHostname(AntaTest): ``` """ - name = "VerifyHostname" - description = "Verifies the hostname of a device." categories: ClassVar[list[str]] = ["services"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show hostname", revision=1)] @@ -77,7 +75,6 @@ class VerifyDNSLookup(AntaTest): ``` """ - name = "VerifyDNSLookup" description = "Verifies the DNS name to IP address resolution." categories: ClassVar[list[str]] = ["services"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="bash timeout 10 nslookup {domain}", revision=1)] @@ -129,7 +126,6 @@ class VerifyDNSServers(AntaTest): ``` """ - name = "VerifyDNSServers" description = "Verifies if the DNS servers are correctly configured." categories: ClassVar[list[str]] = ["services"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ip name-server", revision=1)] @@ -194,8 +190,6 @@ class VerifyErrdisableRecovery(AntaTest): ``` """ - name = "VerifyErrdisableRecovery" - description = "Verifies the errdisable recovery reason, status, and interval." categories: ClassVar[list[str]] = ["services"] # NOTE: Only `text` output format is supported for this command commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show errdisable recovery", ofmt="text")] diff --git a/anta/tests/snmp.py b/anta/tests/snmp.py index 217e32059..b8bd73d2e 100644 --- a/anta/tests/snmp.py +++ b/anta/tests/snmp.py @@ -34,7 +34,6 @@ class VerifySnmpStatus(AntaTest): ``` """ - name = "VerifySnmpStatus" description = "Verifies if the SNMP agent is enabled." categories: ClassVar[list[str]] = ["snmp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show snmp", revision=1)] @@ -73,7 +72,6 @@ class VerifySnmpIPv4Acl(AntaTest): ``` """ - name = "VerifySnmpIPv4Acl" description = "Verifies if the SNMP agent has IPv4 ACL(s) configured." categories: ClassVar[list[str]] = ["snmp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show snmp ipv4 access-list summary", revision=1)] @@ -122,7 +120,6 @@ class VerifySnmpIPv6Acl(AntaTest): ``` """ - name = "VerifySnmpIPv6Acl" description = "Verifies if the SNMP agent has IPv6 ACL(s) configured." categories: ClassVar[list[str]] = ["snmp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show snmp ipv6 access-list summary", revision=1)] @@ -170,8 +167,6 @@ class VerifySnmpLocation(AntaTest): ``` """ - name = "VerifySnmpLocation" - description = "Verifies the SNMP location of a device." categories: ClassVar[list[str]] = ["snmp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show snmp", revision=1)] @@ -213,8 +208,6 @@ class VerifySnmpContact(AntaTest): ``` """ - name = "VerifySnmpContact" - description = "Verifies the SNMP contact of a device." categories: ClassVar[list[str]] = ["snmp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show snmp", revision=1)] @@ -261,8 +254,6 @@ class VerifySnmpPDUCounters(AntaTest): ``` """ - name = "VerifySnmpPDUCounters" - description = "Verifies the SNMP PDU counters." categories: ClassVar[list[str]] = ["snmp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show snmp", revision=1)] @@ -317,8 +308,6 @@ class VerifySnmpErrorCounters(AntaTest): - inBadCommunityNames """ - name = "VerifySnmpErrorCounters" - description = "Verifies the SNMP error counters." categories: ClassVar[list[str]] = ["snmp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show snmp", revision=1)] diff --git a/anta/tests/software.py b/anta/tests/software.py index 4028dd963..9a41881ab 100644 --- a/anta/tests/software.py +++ b/anta/tests/software.py @@ -34,7 +34,6 @@ class VerifyEOSVersion(AntaTest): ``` """ - name = "VerifyEOSVersion" description = "Verifies the EOS version of the device." categories: ClassVar[list[str]] = ["software"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show version", revision=1)] @@ -74,7 +73,6 @@ class VerifyTerminAttrVersion(AntaTest): ``` """ - name = "VerifyTerminAttrVersion" description = "Verifies the TerminAttr version of the device." categories: ClassVar[list[str]] = ["software"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show version detail", revision=1)] @@ -112,8 +110,6 @@ class VerifyEOSExtensions(AntaTest): ``` """ - name = "VerifyEOSExtensions" - description = "Verifies that all EOS extensions installed on the device are enabled for boot persistence." categories: ClassVar[list[str]] = ["software"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaCommand(command="show extensions", revision=2), diff --git a/anta/tests/stp.py b/anta/tests/stp.py index 3208f0c40..93a0d2e39 100644 --- a/anta/tests/stp.py +++ b/anta/tests/stp.py @@ -36,8 +36,6 @@ class VerifySTPMode(AntaTest): ``` """ - name = "VerifySTPMode" - description = "Verifies the configured STP mode for a provided list of VLAN(s)." categories: ClassVar[list[str]] = ["stp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show spanning-tree vlan {vlan}", revision=1)] @@ -93,8 +91,6 @@ class VerifySTPBlockedPorts(AntaTest): ``` """ - name = "VerifySTPBlockedPorts" - description = "Verifies there is no STP blocked ports." categories: ClassVar[list[str]] = ["stp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show spanning-tree blockedports", revision=1)] @@ -126,8 +122,6 @@ class VerifySTPCounters(AntaTest): ``` """ - name = "VerifySTPCounters" - description = "Verifies there is no errors in STP BPDU packets." categories: ClassVar[list[str]] = ["stp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show spanning-tree counters", revision=1)] @@ -163,7 +157,6 @@ class VerifySTPForwardingPorts(AntaTest): ``` """ - name = "VerifySTPForwardingPorts" description = "Verifies that all interfaces are forwarding for a provided list of VLAN(s)." categories: ClassVar[list[str]] = ["stp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show spanning-tree topology vlan {vlan} status", revision=1)] @@ -222,8 +215,6 @@ class VerifySTPRootPriority(AntaTest): ``` """ - name = "VerifySTPRootPriority" - description = "Verifies the STP root priority for a provided list of VLAN or MST instance ID(s)." categories: ClassVar[list[str]] = ["stp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show spanning-tree root detail", revision=1)] @@ -279,8 +270,6 @@ class VerifyStpTopologyChanges(AntaTest): ``` """ - name = "VerifyStpTopologyChanges" - description = "Verifies the number of changes across all interfaces in the Spanning Tree Protocol (STP) topology is below a threshold." categories: ClassVar[list[str]] = ["stp"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show spanning-tree topology status detail", revision=1)] diff --git a/anta/tests/stun.py b/anta/tests/stun.py index f06b5a0ab..8b4f4fb2f 100644 --- a/anta/tests/stun.py +++ b/anta/tests/stun.py @@ -18,10 +18,7 @@ class VerifyStunClient(AntaTest): - """ - Verifies the configuration of the STUN client, specifically the IPv4 source address and port. - - Optionally, it can also verify the public address and port. + """Verifies STUN client settings, including local IP/port and optionally public IP/port. Expected Results ---------------- @@ -45,8 +42,6 @@ class VerifyStunClient(AntaTest): ``` """ - name = "VerifyStunClient" - description = "Verifies the STUN client is configured with the specified IPv4 source address and port. Validate the public IP and port if provided." categories: ClassVar[list[str]] = ["stun"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show stun client translations {source_address} {source_port}")] @@ -118,8 +113,7 @@ def test(self) -> None: class VerifyStunServer(AntaTest): - """ - Verifies the STUN server status is enabled and running. + """Verifies the STUN server status is enabled and running. Expected Results ---------------- @@ -134,8 +128,6 @@ class VerifyStunServer(AntaTest): ``` """ - name = "VerifyStunServer" - description = "Verifies the STUN server status is enabled and running." categories: ClassVar[list[str]] = ["stun"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show stun server status", revision=1)] diff --git a/anta/tests/system.py b/anta/tests/system.py index d620d533b..775eecbc5 100644 --- a/anta/tests/system.py +++ b/anta/tests/system.py @@ -42,7 +42,6 @@ class VerifyUptime(AntaTest): ``` """ - name = "VerifyUptime" description = "Verifies the device uptime." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show uptime", revision=1)] @@ -80,8 +79,6 @@ class VerifyReloadCause(AntaTest): ``` """ - name = "VerifyReloadCause" - description = "Verifies the last reload cause of the device." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show reload cause", revision=1)] @@ -124,7 +121,6 @@ class VerifyCoredump(AntaTest): ``` """ - name = "VerifyCoredump" description = "Verifies there are no core dump files." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show system coredump", revision=1)] @@ -143,7 +139,7 @@ def test(self) -> None: class VerifyAgentLogs(AntaTest): - """Verifies that no agent crash reports are present on the device. + """Verifies there are no agent crash reports. Expected Results ---------------- @@ -158,8 +154,6 @@ class VerifyAgentLogs(AntaTest): ``` """ - name = "VerifyAgentLogs" - description = "Verifies there are no agent crash reports." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show agent logs crash", ofmt="text")] @@ -191,8 +185,6 @@ class VerifyCPUUtilization(AntaTest): ``` """ - name = "VerifyCPUUtilization" - description = "Verifies whether the CPU utilization is below 75%." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show processes top once", revision=1)] @@ -223,8 +215,6 @@ class VerifyMemoryUtilization(AntaTest): ``` """ - name = "VerifyMemoryUtilization" - description = "Verifies whether the memory utilization is below 75%." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show version", revision=1)] @@ -255,8 +245,6 @@ class VerifyFileSystemUtilization(AntaTest): ``` """ - name = "VerifyFileSystemUtilization" - description = "Verifies that no partition is utilizing more than 75% of its disk space." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="bash timeout 10 df -h", ofmt="text")] @@ -286,7 +274,6 @@ class VerifyNTP(AntaTest): ``` """ - name = "VerifyNTP" description = "Verifies if NTP is synchronised." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ntp status", ofmt="text")] @@ -328,8 +315,6 @@ class VerifyNTPAssociations(AntaTest): ``` """ - name = "VerifyNTPAssociations" - description = "Verifies the Network Time Protocol (NTP) associations." categories: ClassVar[list[str]] = ["system"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show ntp associations")] diff --git a/anta/tests/vlan.py b/anta/tests/vlan.py index fdf91d896..b7b1bd4cb 100644 --- a/anta/tests/vlan.py +++ b/anta/tests/vlan.py @@ -38,7 +38,6 @@ class VerifyVlanInternalPolicy(AntaTest): ``` """ - name = "VerifyVlanInternalPolicy" description = "Verifies the VLAN internal allocation policy and the range of VLANs." categories: ClassVar[list[str]] = ["vlan"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show vlan internal allocation policy", revision=1)] diff --git a/anta/tests/vxlan.py b/anta/tests/vxlan.py index fe5381670..3236ef3bd 100644 --- a/anta/tests/vxlan.py +++ b/anta/tests/vxlan.py @@ -41,7 +41,6 @@ class VerifyVxlan1Interface(AntaTest): ``` """ - name = "VerifyVxlan1Interface" description = "Verifies the Vxlan1 interface status." categories: ClassVar[list[str]] = ["vxlan"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces description", revision=1)] @@ -65,7 +64,7 @@ def test(self) -> None: class VerifyVxlanConfigSanity(AntaTest): - """Verifies that no issues are detected with the VXLAN configuration. + """Verifies there are no VXLAN config-sanity inconsistencies. Expected Results ---------------- @@ -81,8 +80,6 @@ class VerifyVxlanConfigSanity(AntaTest): ``` """ - name = "VerifyVxlanConfigSanity" - description = "Verifies there are no VXLAN config-sanity inconsistencies." categories: ClassVar[list[str]] = ["vxlan"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show vxlan config-sanity", revision=1)] @@ -124,8 +121,6 @@ class VerifyVxlanVniBinding(AntaTest): ``` """ - name = "VerifyVxlanVniBinding" - description = "Verifies the VNI-VLAN bindings of the Vxlan1 interface." categories: ClassVar[list[str]] = ["vxlan"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show vxlan vni", revision=1)] @@ -187,8 +182,6 @@ class VerifyVxlanVtep(AntaTest): ``` """ - name = "VerifyVxlanVtep" - description = "Verifies the VTEP peers of the Vxlan1 interface" categories: ClassVar[list[str]] = ["vxlan"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show vxlan vtep", revision=1)] @@ -238,8 +231,6 @@ class VerifyVxlan1ConnSettings(AntaTest): ``` """ - name = "VerifyVxlan1ConnSettings" - description = "Verifies the interface vxlan1 source interface and UDP port." categories: ClassVar[list[str]] = ["vxlan"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show interfaces", revision=1)] diff --git a/anta/tools.py b/anta/tools.py index 4f73db9cb..b00ccf7f9 100644 --- a/anta/tools.py +++ b/anta/tools.py @@ -94,8 +94,7 @@ def get_dict_superset( *, required: bool = False, ) -> Any: - """ - Get the first dictionary from a list of dictionaries that is a superset of the input dict. + """Get the first dictionary from a list of dictionaries that is a superset of the input dict. Returns the supplied default value or None if there is no match and "required" is False. diff --git a/asynceapi/aio_portcheck.py b/asynceapi/aio_portcheck.py index 0cab94cb3..deac0431a 100644 --- a/asynceapi/aio_portcheck.py +++ b/asynceapi/aio_portcheck.py @@ -34,8 +34,7 @@ async def port_check_url(url: URL, timeout: int = 5) -> bool: - """ - Open the port designated by the URL given the timeout in seconds. + """Open the port designated by the URL given the timeout in seconds. Parameters ---------- diff --git a/asynceapi/config_session.py b/asynceapi/config_session.py index df26d7def..7f83da41f 100644 --- a/asynceapi/config_session.py +++ b/asynceapi/config_session.py @@ -29,8 +29,7 @@ class SessionConfig: - """ - Send configuration to a device using the EOS session mechanism. + """Send configuration to a device using the EOS session mechanism. This is the preferred way of managing configuration changes. @@ -44,8 +43,7 @@ class SessionConfig: CLI_CFG_FACTORY_RESET = "rollback clean-config" def __init__(self, device: Device, name: str) -> None: - """ - Create a new instance of SessionConfig. + """Create a new instance of SessionConfig. The session config instance bound to the given device instance, and using the session `name`. @@ -81,8 +79,7 @@ def device(self) -> Device: # ------------------------------------------------------------------------- async def status_all(self) -> dict[str, Any]: - """ - Get the status of all the session config on the device. + """Get the status of all the session config on the device. Run the following command on the device: # show configuration sessions detail @@ -122,8 +119,7 @@ async def status_all(self) -> dict[str, Any]: return await self._cli("show configuration sessions detail") # type: ignore[return-value] # json outformat returns dict[str, Any] async def status(self) -> dict[str, Any] | None: - """ - Get the status of a session config on the device. + """Get the status of a session config on the device. Run the following command on the device: # show configuration sessions detail @@ -179,8 +175,7 @@ async def status(self) -> dict[str, Any] | None: return res["sessions"].get(self.name) async def push(self, content: list[str] | str, *, replace: bool = False) -> None: - """ - Send the configuration content to the device. + """Send the configuration content to the device. If `replace` is true, then the command "rollback clean-config" is issued before sending the configuration content. @@ -218,8 +213,7 @@ async def push(self, content: list[str] | str, *, replace: bool = False) -> None await self._cli(commands=commands) async def commit(self, timer: str | None = None) -> None: - """ - Commit the session config. + """Commit the session config. Run the following command on the device: # configure session @@ -241,8 +235,7 @@ async def commit(self, timer: str | None = None) -> None: await self._cli(command) async def abort(self) -> None: - """ - Abort the configuration session. + """Abort the configuration session. Run the following command on the device: # configure session abort @@ -250,8 +243,7 @@ async def abort(self) -> None: await self._cli(f"{self._cli_config_session} abort") async def diff(self) -> str: - """ - Return the "diff" of the session config relative to the running config. + """Return the "diff" of the session config relative to the running config. Run the following command on the device: # show session-config named diffs @@ -268,8 +260,7 @@ async def diff(self) -> str: return await self._cli(f"show session-config named {self.name} diffs", ofmt="text") # type: ignore[return-value] # text outformat returns str async def load_file(self, filename: str, *, replace: bool = False) -> None: - """ - Load the configuration from into the session configuration. + """Load the configuration from into the session configuration. If the replace parameter is True then the file contents will replace the existing session config (load-replace). diff --git a/asynceapi/device.py b/asynceapi/device.py index 933ae649c..7793ce519 100644 --- a/asynceapi/device.py +++ b/asynceapi/device.py @@ -43,8 +43,7 @@ class Device(httpx.AsyncClient): - """ - Represent the async JSON-RPC client that communicates with an Arista EOS device. + """Represent the async JSON-RPC client that communicates with an Arista EOS device. This class inherits directly from the httpx.AsyncClient, so any initialization options can be passed directly. @@ -63,8 +62,7 @@ def __init__( port: str | int | None = None, **kwargs: Any, # noqa: ANN401 ) -> None: - """ - Initialize the Device class. + """Initialize the Device class. As a subclass to httpx.AsyncClient, the caller can provide any of those initializers. Specific parameters for Device class are all optional and described below. @@ -111,8 +109,7 @@ def __init__( self.headers["Content-Type"] = "application/json-rpc" async def check_connection(self) -> bool: - """ - Check the target device to ensure that the eAPI port is open and accepting connections. + """Check the target device to ensure that the eAPI port is open and accepting connections. It is recommended that a Caller checks the connection before involving cli commands, but this step is not required. @@ -136,8 +133,7 @@ async def cli( # noqa: PLR0913 expand_aliases: bool = False, req_id: int | str | None = None, ) -> list[dict[str, Any] | str] | dict[str, Any] | str | None: - """ - Execute one or more CLI commands. + """Execute one or more CLI commands. Parameters ---------- @@ -264,8 +260,7 @@ def _jsonrpc_command( # noqa: PLR0913 return cmd async def jsonrpc_exec(self, jsonrpc: dict[str, Any]) -> list[dict[str, Any] | str]: - """ - Execute the JSON-RPC dictionary object. + """Execute the JSON-RPC dictionary object. Parameters ---------- diff --git a/asynceapi/errors.py b/asynceapi/errors.py index e6794b7ef..5fce9db08 100644 --- a/asynceapi/errors.py +++ b/asynceapi/errors.py @@ -12,8 +12,7 @@ class EapiCommandError(RuntimeError): - """ - Exception class for EAPI command errors. + """Exception class for EAPI command errors. Attributes ---------- diff --git a/docs/advanced_usages/custom-tests.md b/docs/advanced_usages/custom-tests.md index d79fe50e3..8b217998c 100644 --- a/docs/advanced_usages/custom-tests.md +++ b/docs/advanced_usages/custom-tests.md @@ -36,8 +36,6 @@ class VerifyTemperature(AntaTest): ``` """ - name = "VerifyTemperature" - description = "Verifies the device temperature." categories: ClassVar[list[str]] = ["hardware"] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show system environment temperature", revision=1)] @@ -61,8 +59,8 @@ Full AntaTest API documentation is available in the [API documentation section]( ### Class Attributes -- `name` (`str`): Name of the test. Used during reporting. -- `description` (`str`): A human readable description of your test. +- `name` (`str`, `optional`): Name of the test. Used during reporting. By default set to the Class name. +- `description` (`str`, `optional`): A human readable description of your test. By default set to the first line of the docstring. - `categories` (`list[str]`): A list of categories in which the test belongs. - `commands` (`[list[AntaCommand | AntaTemplate]]`): A list of command to collect from devices. This list **must** be a list of [AntaCommand](../api/models.md#anta.models.AntaCommand) or [AntaTemplate](../api/models.md#anta.models.AntaTemplate) instances. Rendering [AntaTemplate](../api/models.md#anta.models.AntaTemplate) instances will be discussed later. @@ -171,11 +169,11 @@ from anta.models import AntaTest, AntaCommand, AntaTemplate class (AntaTest): """ - + """ - name = "YourTestName" # should be your class name - description = "" + # name = # uncomment to override default behavior of name=Class Name + # description = # uncomment to override default behavior of description=first line of docstring categories = ["", ""] commands = [ AntaCommand( diff --git a/pyproject.toml b/pyproject.toml index bad984d69..7a2dd8c73 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -337,10 +337,9 @@ select = ["ALL", # By enabling a convention for docstrings, ruff automatically ignore some rules that need to be # added back if we want them. # https://docs.astral.sh/ruff/faq/#does-ruff-support-numpy-or-google-style-docstrings - # TODO: Augment the numpy convention rules to make sure we add all the params - # Uncomment below D417 "D415", "D417", + "D212", ] ignore = [ "COM812", # Ignoring conflicting rules that may cause conflicts when used with the formatter diff --git a/tests/units/test_custom_types.py b/tests/units/test_custom_types.py index 697017105..95c52344a 100644 --- a/tests/units/test_custom_types.py +++ b/tests/units/test_custom_types.py @@ -192,8 +192,7 @@ def test_regexp_eos_blacklist_cmds(test_string: str, expected: bool) -> None: """Test REGEXP_EOS_BLACKLIST_CMDS.""" def matches_any_regex(string: str, regex_list: list[str]) -> bool: - """ - Check if a string matches at least one regular expression in a list. + """Check if a string matches at least one regular expression in a list. :param string: The string to check. :param regex_list: A list of regular expressions. diff --git a/tests/units/test_models.py b/tests/units/test_models.py index d604b4835..8b7c50f10 100644 --- a/tests/units/test_models.py +++ b/tests/units/test_models.py @@ -26,8 +26,6 @@ class FakeTest(AntaTest): """ANTA test that always succeed.""" - name = "FakeTest" - description = "ANTA test that always succeed" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @@ -40,8 +38,6 @@ def test(self) -> None: class FakeTestWithFailedCommand(AntaTest): """ANTA test with a command that failed.""" - name = "FakeTestWithFailedCommand" - description = "ANTA test with a command that failed" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show version", errors=["failed command"])] @@ -54,8 +50,6 @@ def test(self) -> None: class FakeTestWithUnsupportedCommand(AntaTest): """ANTA test with an unsupported command.""" - name = "FakeTestWithUnsupportedCommand" - description = "ANTA test with an unsupported command" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [ AntaCommand( @@ -73,8 +67,6 @@ def test(self) -> None: class FakeTestWithInput(AntaTest): """ANTA test with inputs that always succeed.""" - name = "FakeTestWithInput" - description = "ANTA test with inputs that always succeed" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @@ -92,8 +84,6 @@ def test(self) -> None: class FakeTestWithTemplate(AntaTest): """ANTA test with template that always succeed.""" - name = "FakeTestWithTemplate" - description = "ANTA test with template that always succeed" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show interface {interface}")] @@ -115,8 +105,6 @@ def test(self) -> None: class FakeTestWithTemplateNoRender(AntaTest): """ANTA test with template that miss the render() method.""" - name = "FakeTestWithTemplateNoRender" - description = "ANTA test with template that miss the render() method" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show interface {interface}")] @@ -134,8 +122,6 @@ def test(self) -> None: class FakeTestWithTemplateBadRender1(AntaTest): """ANTA test with template that raises a AntaTemplateRenderError exception.""" - name = "FakeTestWithTemplateBadRender" - description = "ANTA test with template that raises a AntaTemplateRenderError exception" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show interface {interface}")] @@ -157,8 +143,6 @@ def test(self) -> None: class FakeTestWithTemplateBadRender2(AntaTest): """ANTA test with template that raises an arbitrary exception in render().""" - name = "FakeTestWithTemplateBadRender2" - description = "ANTA test with template that raises an arbitrary exception in render()" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show interface {interface}")] @@ -180,8 +164,6 @@ def test(self) -> None: class FakeTestWithTemplateBadRender3(AntaTest): """ANTA test with template that gives extra template parameters in render().""" - name = "FakeTestWithTemplateBadRender3" - description = "ANTA test with template that gives extra template parameters in render()" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show interface {interface}")] @@ -203,8 +185,6 @@ def test(self) -> None: class FakeTestWithTemplateBadTest(AntaTest): """ANTA test with template that tries to access an undefined template parameter in test().""" - name = "FakeTestWithTemplateBadTest" - description = "ANTA test with template that tries to access an undefined template parameter in test()" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaTemplate(template="show interface {interface}")] @@ -227,8 +207,6 @@ def test(self) -> None: class SkipOnPlatformTest(AntaTest): """ANTA test that is skipped.""" - name = "SkipOnPlatformTest" - description = "ANTA test that is skipped on a specific platform" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @@ -242,8 +220,6 @@ def test(self) -> None: class UnSkipOnPlatformTest(AntaTest): """ANTA test that is skipped.""" - name = "UnSkipOnPlatformTest" - description = "ANTA test that is skipped on a specific platform" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @@ -257,8 +233,6 @@ def test(self) -> None: class SkipOnPlatformTestWithInput(AntaTest): """ANTA test skipped on platforms but with Input.""" - name = "SkipOnPlatformTestWithInput" - description = "ANTA test skipped on platforms but with Input" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @@ -277,8 +251,6 @@ def test(self) -> None: class DeprecatedTestWithoutNewTest(AntaTest): """ANTA test that is deprecated without new test.""" - name = "DeprecatedTestWitouthNewTest" - description = "ANTA test that is deprecated without new test" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @@ -292,8 +264,6 @@ def test(self) -> None: class DeprecatedTestWithNewTest(AntaTest): """ANTA test that is deprecated with new test.""" - name = "DeprecatedTestWithNewTest" - description = "ANTA deprecated test with New Test" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @@ -307,8 +277,6 @@ def test(self) -> None: class FakeTestWithMissingTest(AntaTest): """ANTA test with missing test() method implementation.""" - name = "FakeTestWithMissingTest" - description = "ANTA test with missing test() method implementation" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @@ -526,65 +494,61 @@ class TestAntaTest: def test__init_subclass__(self) -> None: """Test __init_subclass__.""" - with pytest.raises(NotImplementedError) as exec_info: + with pytest.raises(AttributeError) as exec_info: - class _WrongTestNoName(AntaTest): - """ANTA test that is missing a name.""" + class _WrongTestNoCategories(AntaTest): + """ANTA test that is missing categories.""" - description = "ANTA test that is missing a name" - categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @AntaTest.anta_test def test(self) -> None: self.result.is_success() - assert exec_info.value.args[0] == "Class tests.units.test_models._WrongTestNoName is missing required class attribute name" + assert exec_info.value.args[0] == "Class tests.units.test_models._WrongTestNoCategories is missing required class attribute(s): categories" - with pytest.raises(NotImplementedError) as exec_info: + with pytest.raises(AttributeError) as exec_info: - class _WrongTestNoDescription(AntaTest): - """ANTA test that is missing a description.""" + class _WrongTestNoCommands(AntaTest): + """ANTA test that is missing commands.""" - name = "WrongTestNoDescription" categories: ClassVar[list[str]] = [] - commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] @AntaTest.anta_test def test(self) -> None: self.result.is_success() - assert exec_info.value.args[0] == "Class tests.units.test_models._WrongTestNoDescription is missing required class attribute description" + assert exec_info.value.args[0] == "Class tests.units.test_models._WrongTestNoCommands is missing required class attribute(s): commands" - with pytest.raises(NotImplementedError) as exec_info: + with pytest.raises( + AttributeError, + match="Cannot set the description for class _WrongTestNoDescription, either set it in the class definition or add a docstring to the class.", + ): - class _WrongTestNoCategories(AntaTest): - """ANTA test that is missing categories.""" + class _WrongTestNoDescription(AntaTest): + # ANTA test that is missing a description and does not have a doctstring. - name = "WrongTestNoCategories" - description = "ANTA test that is missing categories" commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] + categories: ClassVar[list[str]] = [] @AntaTest.anta_test def test(self) -> None: self.result.is_success() - assert exec_info.value.args[0] == "Class tests.units.test_models._WrongTestNoCategories is missing required class attribute categories" - - with pytest.raises(NotImplementedError) as exec_info: + class _TestOverwriteNameAndDescription(AntaTest): + """ANTA test where both the test name and description are overwritten in the class definition.""" - class _WrongTestNoCommands(AntaTest): - """ANTA test that is missing commands.""" - - name = "WrongTestNoCommands" - description = "ANTA test that is missing commands" - categories: ClassVar[list[str]] = [] + name: ClassVar[str] = "CustomName" + description: ClassVar[str] = "Custom description" + commands: ClassVar[list[AntaCommand | AntaTemplate]] = [] + categories: ClassVar[list[str]] = [] - @AntaTest.anta_test - def test(self) -> None: - self.result.is_success() + @AntaTest.anta_test + def test(self) -> None: + self.result.is_success() - assert exec_info.value.args[0] == "Class tests.units.test_models._WrongTestNoCommands is missing required class attribute commands" + assert _TestOverwriteNameAndDescription.name == "CustomName" + assert _TestOverwriteNameAndDescription.description == "Custom description" def test_abc(self) -> None: """Test that an error is raised if AntaTest is not implemented.""" @@ -626,8 +590,6 @@ def test_blacklist(self, device: AntaDevice, command: str) -> None: class FakeTestWithBlacklist(AntaTest): """Fake Test for blacklist.""" - name = "FakeTestWithBlacklist" - description = "ANTA test that has blacklisted command" categories: ClassVar[list[str]] = [] commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command=command)]