Skip to content

ANTA catalog for Software tests

Module related to the EOS software tests.

VerifyEOSExtensions

Verifies that all EOS extensions installed on the device are enabled for boot persistence.

Expected Results
  • Success: The test will pass if all EOS extensions installed on the device are enabled for boot persistence.
  • Failure: The test will fail if some EOS extensions installed on the device are not enabled for boot persistence.
Examples
anta.tests.software:
  - VerifyEOSExtensions:
Source code in anta/tests/software.py
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
class VerifyEOSExtensions(AntaTest):
    """Verifies that all EOS extensions installed on the device are enabled for boot persistence.

    Expected Results
    ----------------
    * Success: The test will pass if all EOS extensions installed on the device are enabled for boot persistence.
    * Failure: The test will fail if some EOS extensions installed on the device are not enabled for boot persistence.

    Examples
    --------
    ```yaml
    anta.tests.software:
      - VerifyEOSExtensions:
    ```
    """

    categories: ClassVar[list[str]] = ["software"]
    commands: ClassVar[list[AntaCommand | AntaTemplate]] = [
        AntaCommand(command="show extensions", revision=2),
        AntaCommand(command="show boot-extensions", revision=1),
    ]

    @AntaTest.anta_test
    def test(self) -> None:
        """Main test function for VerifyEOSExtensions."""
        boot_extensions = []
        self.result.is_success()
        show_extensions_command_output = self.instance_commands[0].json_output
        show_boot_extensions_command_output = self.instance_commands[1].json_output
        installed_extensions = [
            extension for extension, extension_data in show_extensions_command_output["extensions"].items() if extension_data["status"] == "installed"
        ]
        for extension in show_boot_extensions_command_output["extensions"]:
            formatted_extension = extension.strip("\n")
            if formatted_extension != "":
                boot_extensions.append(formatted_extension)
        installed_extensions.sort()
        boot_extensions.sort()
        if installed_extensions != boot_extensions:
            str_installed_extensions = ", ".join(installed_extensions) if installed_extensions else "Not found"
            str_boot_extensions = ", ".join(boot_extensions) if boot_extensions else "Not found"
            self.result.is_failure(f"EOS extensions mismatch - Installed: {str_installed_extensions} Configured: {str_boot_extensions}")

VerifyEOSVersion

Verifies the EOS version of the device.

Expected Results
  • Success: The test will pass if the device is running one of the allowed EOS version.
  • Failure: The test will fail if the device is not running one of the allowed EOS version.
Examples
anta.tests.software:
  - VerifyEOSVersion:
      versions:
        - 4.25.4M
        - 4.26.1F

Inputs

Name Type Description Default
versions list[str]
List of allowed EOS versions.
-
Source code in anta/tests/software.py
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class VerifyEOSVersion(AntaTest):
    """Verifies the EOS version of the device.

    Expected Results
    ----------------
    * Success: The test will pass if the device is running one of the allowed EOS version.
    * Failure: The test will fail if the device is not running one of the allowed EOS version.

    Examples
    --------
    ```yaml
    anta.tests.software:
      - VerifyEOSVersion:
          versions:
            - 4.25.4M
            - 4.26.1F
    ```
    """

    categories: ClassVar[list[str]] = ["software"]
    commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show version", revision=1)]

    class Input(AntaTest.Input):
        """Input model for the VerifyEOSVersion test."""

        versions: list[str]
        """List of allowed EOS versions."""

    @AntaTest.anta_test
    def test(self) -> None:
        """Main test function for VerifyEOSVersion."""
        command_output = self.instance_commands[0].json_output
        self.result.is_success()
        if command_output["version"] not in self.inputs.versions:
            self.result.is_failure(f"EOS version mismatch - Actual: {command_output['version']} not in Expected: {', '.join(self.inputs.versions)}")

VerifyTerminAttrVersion

Verifies the TerminAttr version of the device.

Expected Results
  • Success: The test will pass if the device is running one of the allowed TerminAttr version.
  • Failure: The test will fail if the device is not running one of the allowed TerminAttr version.
Examples
anta.tests.software:
  - VerifyTerminAttrVersion:
      versions:
        - v1.13.6
        - v1.8.0

Inputs

Name Type Description Default
versions list[str]
List of allowed TerminAttr versions.
-
Source code in anta/tests/software.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class VerifyTerminAttrVersion(AntaTest):
    """Verifies the TerminAttr version of the device.

    Expected Results
    ----------------
    * Success: The test will pass if the device is running one of the allowed TerminAttr version.
    * Failure: The test will fail if the device is not running one of the allowed TerminAttr version.

    Examples
    --------
    ```yaml
    anta.tests.software:
      - VerifyTerminAttrVersion:
          versions:
            - v1.13.6
            - v1.8.0
    ```
    """

    categories: ClassVar[list[str]] = ["software"]
    commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show version detail", revision=1)]

    class Input(AntaTest.Input):
        """Input model for the VerifyTerminAttrVersion test."""

        versions: list[str]
        """List of allowed TerminAttr versions."""

    @AntaTest.anta_test
    def test(self) -> None:
        """Main test function for VerifyTerminAttrVersion."""
        command_output = self.instance_commands[0].json_output
        self.result.is_success()
        command_output_data = command_output["details"]["packages"]["TerminAttr-core"]["version"]
        if command_output_data not in self.inputs.versions:
            self.result.is_failure(f"TerminAttr version mismatch - Actual: {command_output_data} not in Expected: {', '.join(self.inputs.versions)}")