-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(anta): Added the test case to Verify SNMP Notification Host #838
Draft
vitthalmagadum
wants to merge
7
commits into
aristanetworks:main
Choose a base branch
from
vitthalmagadum:issue_822
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b8a3419
iisue_822 Added TC for SNMP Notification host
dcdcf9c
issue_822 Handling review comments: updated failure msgs and docstring
c793bcb
issue_822 Updated after resolved conflicts
ce6aa8c
Issue_822: Refactored testcase with latest inputs changes
geetanjalimanegslab 3a4dc19
Issue_822: Updated unitestcase,docstrings and added check for incorr…
geetanjalimanegslab 1692ea8
fixing the sonar issues
vitthalmagadum 6346d0e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,42 @@ | ||
# Copyright (c) 2023-2025 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 SNMP tests.""" | ||
|
||
from __future__ import annotations | ||
|
||
from ipaddress import IPv4Address | ||
from typing import Literal | ||
|
||
from pydantic import BaseModel, ConfigDict | ||
|
||
from anta.custom_types import Hostname, Port, SnmpVersion | ||
|
||
|
||
class SNMPHost(BaseModel): | ||
"""Model for a SNMP Host.""" | ||
|
||
model_config = ConfigDict(extra="forbid") | ||
hostname: IPv4Address | Hostname | ||
"""IPv4 address of the SNMP notification host.""" | ||
vrf: str = "default" | ||
"""Optional VRF for SNMP Hosts. If not provided, it defaults to `default`.""" | ||
notification_type: Literal["trap", "inform"] = "trap" | ||
"""Type of SNMP notification (trap or inform), it defaults to trap.""" | ||
version: SnmpVersion | None = None | ||
"""SNMP protocol version.Required field in the `VerifySNMPNotificationHost` test.""" | ||
udp_port: Port | int = 162 | ||
"""UDP port for SNMP. If not provided then defaults to 162.""" | ||
community_string: str | None = None | ||
"""Optional SNMP community string for authentication,required for SNMP version is v1 or v2c. Can be provided in the `VerifySNMPNotificationHost` test.""" | ||
user: str | None = None | ||
"""Optional SNMP user for authentication, required for SNMP version v3. Can be provided in the `VerifySNMPNotificationHost` test.""" | ||
|
||
def __str__(self) -> str: | ||
"""Return a human-readable string representation of the Host for reporting. | ||
|
||
Examples | ||
-------- | ||
- Host: 192.168.1.100 VRF: default | ||
""" | ||
return f"Host: {self.hostname} VRF: {self.vrf}" |
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
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 |
---|---|---|
|
@@ -717,6 +717,16 @@ anta.tests.services: | |
# Verifies the hostname of a device. | ||
hostname: s1-spine1 | ||
anta.tests.snmp: | ||
- VerifySNMPNotificationHost: | ||
# Verifies the SNMP notification host (SNMP manager) configurations. | ||
notification_hosts: | ||
- hostname: 192.168.1.100 | ||
vrf: default | ||
notification_type: trap | ||
version: v1 | ||
udp_port: 162 | ||
community_string: public | ||
user: public | ||
- VerifySnmpContact: | ||
# Verifies the SNMP contact of a device. | ||
contact: [email protected] | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have more brief description about what configuration we are verifying
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated docstring.