-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue_822: Refactored testcase with latest inputs changes
- Loading branch information
1 parent
c793bcb
commit ce6aa8c
Showing
6 changed files
with
372 additions
and
91 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,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 only for version is v2 or vc2. Can be provided in the `VerifySNMPNotificationHost` test.""" | ||
user: str | None = None | ||
"""Optional SNMP user for authentication, required only for the 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.