Software
ANTA catalog for software tests
Test functions related to the EOS software
VerifyEOSExtensions
Bases: AntaTest
Verifies all EOS extensions installed on the device are enabled for boot persistence.
Source code in anta/tests/software.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 | class VerifyEOSExtensions(AntaTest):
"""
Verifies all EOS extensions installed on the device are enabled for boot persistence.
"""
name = "VerifyEOSExtensions"
description = "Verifies all EOS extensions installed on the device are enabled for boot persistence."
categories = ["software"]
commands = [AntaCommand(command="show extensions"), AntaCommand(command="show boot-extensions")]
@AntaTest.anta_test
def test(self) -> None:
"""Run VerifyEOSExtensions validation"""
boot_extensions = []
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"]:
extension = extension.strip("\n")
if extension != "":
boot_extensions.append(extension)
installed_extensions.sort()
boot_extensions.sort()
if installed_extensions == boot_extensions:
self.result.is_success()
else:
self.result.is_failure(f"Missing EOS extensions: installed {installed_extensions} / configured: {boot_extensions}")
|
test
Run VerifyEOSExtensions validation
Source code in anta/tests/software.py
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105 | @AntaTest.anta_test
def test(self) -> None:
"""Run VerifyEOSExtensions validation"""
boot_extensions = []
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"]:
extension = extension.strip("\n")
if extension != "":
boot_extensions.append(extension)
installed_extensions.sort()
boot_extensions.sort()
if installed_extensions == boot_extensions:
self.result.is_success()
else:
self.result.is_failure(f"Missing EOS extensions: installed {installed_extensions} / configured: {boot_extensions}")
|
VerifyEOSVersion
Bases: AntaTest
Verifies the device is running one of the allowed EOS version.
Source code in anta/tests/software.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 | class VerifyEOSVersion(AntaTest):
"""
Verifies the device is running one of the allowed EOS version.
"""
name = "VerifyEOSVersion"
description = "Verifies the device is running one of the allowed EOS version."
categories = ["software"]
commands = [AntaCommand(command="show version")]
@AntaTest.anta_test
def test(self, versions: Optional[List[str]] = None) -> None:
"""
Run VerifyEOSVersion validation
Args:
versions: List of allowed EOS versions.
"""
if not versions:
self.result.is_skipped("VerifyEOSVersion was not run as no versions were given")
return
command_output = self.instance_commands[0].json_output
if command_output["version"] in versions:
self.result.is_success()
else:
self.result.is_failure(f'device is running version {command_output["version"]} not in expected versions: {versions}')
|
test
test(versions: Optional[List[str]] = None) -> None
Run VerifyEOSVersion validation
Parameters:
Name |
Type |
Description |
Default |
versions |
Optional[List[str]]
|
List of allowed EOS versions.
|
None
|
Source code in anta/tests/software.py
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 | @AntaTest.anta_test
def test(self, versions: Optional[List[str]] = None) -> None:
"""
Run VerifyEOSVersion validation
Args:
versions: List of allowed EOS versions.
"""
if not versions:
self.result.is_skipped("VerifyEOSVersion was not run as no versions were given")
return
command_output = self.instance_commands[0].json_output
if command_output["version"] in versions:
self.result.is_success()
else:
self.result.is_failure(f'device is running version {command_output["version"]} not in expected versions: {versions}')
|
VerifyTerminAttrVersion
Bases: AntaTest
Verifies the device is running one of the allowed TerminAttr version.
Source code in anta/tests/software.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 | class VerifyTerminAttrVersion(AntaTest):
"""
Verifies the device is running one of the allowed TerminAttr version.
"""
name = "VerifyTerminAttrVersion"
description = "Verifies the device is running one of the allowed TerminAttr version."
categories = ["software"]
commands = [AntaCommand(command="show version detail")]
@AntaTest.anta_test
def test(self, versions: Optional[List[str]] = None) -> None:
"""
Run VerifyTerminAttrVersion validation
Args:
versions: List of allowed TerminAttr versions.
"""
if not versions:
self.result.is_skipped("VerifyTerminAttrVersion was not run as no versions were given")
return
command_output = self.instance_commands[0].json_output
command_output_data = command_output["details"]["packages"]["TerminAttr-core"]["version"]
if command_output_data in versions:
self.result.is_success()
else:
self.result.is_failure(f"device is running TerminAttr version {command_output_data} and is not in the allowed list: {versions}")
|
test
test(versions: Optional[List[str]] = None) -> None
Run VerifyTerminAttrVersion validation
Parameters:
Name |
Type |
Description |
Default |
versions |
Optional[List[str]]
|
List of allowed TerminAttr versions.
|
None
|
Source code in anta/tests/software.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 | @AntaTest.anta_test
def test(self, versions: Optional[List[str]] = None) -> None:
"""
Run VerifyTerminAttrVersion validation
Args:
versions: List of allowed TerminAttr versions.
"""
if not versions:
self.result.is_skipped("VerifyTerminAttrVersion was not run as no versions were given")
return
command_output = self.instance_commands[0].json_output
command_output_data = command_output["details"]["packages"]["TerminAttr-core"]["version"]
if command_output_data in versions:
self.result.is_success()
else:
self.result.is_failure(f"device is running TerminAttr version {command_output_data} and is not in the allowed list: {versions}")
|
Last update:
July 19, 2023