-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(anta.tests): Fix VerifyReachability failure messages (#912)
- Loading branch information
1 parent
7858e26
commit 6414404
Showing
7 changed files
with
253 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
"""Package related to all ANTA tests input models.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright (c) 2023-2024 Arista Networks, Inc. | ||
# Use of this source code is governed by the Apache License 2.0 | ||
# that can be found in the LICENSE file. | ||
"""Module containing input models for connectivity tests.""" | ||
|
||
from __future__ import annotations | ||
|
||
from ipaddress import IPv4Address | ||
|
||
from pydantic import BaseModel, ConfigDict | ||
|
||
from anta.custom_types import Interface | ||
|
||
|
||
class Host(BaseModel): | ||
"""Model for a remote host to ping.""" | ||
|
||
model_config = ConfigDict(extra="forbid") | ||
destination: IPv4Address | ||
"""IPv4 address to ping.""" | ||
source: IPv4Address | Interface | ||
"""IPv4 address source IP or egress interface to use.""" | ||
vrf: str = "default" | ||
"""VRF context. Defaults to `default`.""" | ||
repeat: int = 2 | ||
"""Number of ping repetition. Defaults to 2.""" | ||
size: int = 100 | ||
"""Specify datagram size. Defaults to 100.""" | ||
df_bit: bool = False | ||
"""Enable do not fragment bit in IP header. Defaults to False.""" | ||
|
||
def __str__(self) -> str: | ||
"""Return a human-readable string representation of the Host for reporting. | ||
Examples | ||
-------- | ||
Host 10.1.1.1 (src: 10.2.2.2, vrf: mgmt, size: 100B, repeat: 2) | ||
""" | ||
df_status = ", df-bit: enabled" if self.df_bit else "" | ||
return f"Host {self.destination} (src: {self.source}, vrf: {self.vrf}, size: {self.size}B, repeat: {self.repeat}{df_status})" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
164 changes: 164 additions & 0 deletions
164
docs/templates/python/material/anta_test_input_model.html.jinja
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
{% if obj.members %} | ||
{{ log.debug("Rendering children of " + obj.path) }} | ||
|
||
<div class="doc doc-children"> | ||
|
||
{% if root_members %} | ||
{% set members_list = config.members %} | ||
{% else %} | ||
{% set members_list = none %} | ||
{% endif %} | ||
|
||
{% if config.group_by_category %} | ||
|
||
{% with %} | ||
|
||
{% if config.show_category_heading %} | ||
{% set extra_level = 1 %} | ||
{% else %} | ||
{% set extra_level = 0 %} | ||
{% endif %} | ||
|
||
{% with attributes = obj.attributes|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) %} | ||
{% if attributes %} | ||
{% if config.show_category_heading %} | ||
{% filter heading(heading_level, id=html_id ~ "-attributes") %}Attributes{% endfilter %} | ||
{% endif %} | ||
{% with heading_level = heading_level + extra_level %} | ||
{% set root = False %} | ||
{% set heading_level = heading_level + 1 %} | ||
{% set old_obj = obj %} | ||
{% set obj = class %} | ||
{% include "attributes_table.html" with context %} | ||
{% set obj = old_obj %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endwith %} | ||
|
||
{% with classes = obj.classes|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) %} | ||
{% if classes %} | ||
{% if config.show_category_heading %} | ||
{% filter heading(heading_level, id=html_id ~ "-classes") %}Classes{% endfilter %} | ||
{% endif %} | ||
{% with heading_level = heading_level + extra_level %} | ||
{% for class in classes|order_members(config.members_order, members_list) %} | ||
{% if class.name == "Input" %} | ||
{% filter heading(heading_level, id=html_id ~ "-attributes") %}Inputs{% endfilter %} | ||
{% set root = False %} | ||
{% set heading_level = heading_level + 1 %} | ||
{% set old_obj = obj %} | ||
{% set obj = class %} | ||
{% include "attributes_table.html" with context %} | ||
{% set obj = old_obj %} | ||
{% else %} | ||
{% if members_list is not none or class.is_public %} | ||
{% include class|get_template with context %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endwith %} | ||
|
||
{% with functions = obj.functions|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) %} | ||
{% if functions %} | ||
{% if config.show_category_heading %} | ||
{% filter heading(heading_level, id=html_id ~ "-functions") %}Functions{% endfilter %} | ||
{% endif %} | ||
{% with heading_level = heading_level + extra_level %} | ||
{% for function in functions|order_members(config.members_order, members_list) %} | ||
{% if not (obj.kind.value == "class" and function.name == "__init__" and config.merge_init_into_class) %} | ||
{% if members_list is not none or function.is_public %} | ||
{% include function|get_template with context %} | ||
{% endif %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endwith %} | ||
|
||
{% if config.show_submodules %} | ||
{% with modules = obj.modules|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) %} | ||
{% if modules %} | ||
{% if config.show_category_heading %} | ||
{% filter heading(heading_level, id=html_id ~ "-modules") %}Modules{% endfilter %} | ||
{% endif %} | ||
{% with heading_level = heading_level + extra_level %} | ||
{% for module in modules|order_members(config.members_order.alphabetical, members_list) %} | ||
{% if members_list is not none or module.is_public %} | ||
{% include module|get_template with context %} | ||
{% endif %} | ||
{% endfor %} | ||
{% endwith %} | ||
{% endif %} | ||
{% endwith %} | ||
{% endif %} | ||
|
||
{% endwith %} | ||
|
||
{% else %} | ||
|
||
{% for child in obj.all_members | ||
|filter_objects( | ||
filters=config.filters, | ||
members_list=members_list, | ||
inherited_members=config.inherited_members, | ||
keep_no_docstrings=config.show_if_no_docstring, | ||
) | ||
|order_members(config.members_order, members_list) | ||
%} | ||
|
||
{% if not (obj.is_class and child.name == "__init__" and config.merge_init_into_class) %} | ||
|
||
{% if members_list is not none or child.is_public %} | ||
{% if child.is_attribute %} | ||
{% with attribute = child %} | ||
{% include attribute|get_template with context %} | ||
{% endwith %} | ||
|
||
{% elif child.is_class %} | ||
{% with class = child %} | ||
{% include class|get_template with context %} | ||
{% endwith %} | ||
|
||
{% elif child.is_function %} | ||
{% with function = child %} | ||
{% include function|get_template with context %} | ||
{% endwith %} | ||
|
||
{% elif child.is_module and config.show_submodules %} | ||
{% with module = child %} | ||
{% include module|get_template with context %} | ||
{% endwith %} | ||
|
||
{% endif %} | ||
{% endif %} | ||
|
||
{% endif %} | ||
|
||
{% endfor %} | ||
|
||
{% endif %} | ||
|
||
</div> | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters