-
Notifications
You must be signed in to change notification settings - Fork 28
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
base: main
Are you sure you want to change the base?
Conversation
anta/tests/snmp.py
Outdated
|
||
Expected Results | ||
---------------- | ||
* Success: The test will pass if the SNMP PDU counter(s) are non-zero/greater than zero. |
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.
please correct the success and failure message
|
||
|
||
class VerifySNMPNotificationHost(AntaTest): | ||
"""Verifies the SNMP notification host (SNMP manager) configurations. |
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.
anta/tests/snmp.py
Outdated
"""Model for a SNMP Manager.""" | ||
|
||
hostname: IPv4Address | ||
"""IP address of the SNMP notification host.""" |
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.
"""IP address of the SNMP notification host.""" | |
"""IPv4 address of the SNMP notification host.""" |
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.
anta/tests/snmp.py
Outdated
|
||
# Verify SNMP host details. | ||
if not (host_details := get_item(self.instance_commands[0].json_output["hosts"], "hostname", hostname)): | ||
failures += f"Details not found for SNMP host '{hostname}'.\n" |
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.
failures += f"Details not found for SNMP host '{hostname}'.\n" | |
failures += f"SNMP host '{hostname}' is not configured.\n" |
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.
anta/tests/snmp.py
Outdated
user = host.user | ||
|
||
# Verify SNMP host details. | ||
if not (host_details := get_item(self.instance_commands[0].json_output["hosts"], "hostname", hostname)): |
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.
we can get empty list in case no SNMP host configured so in that case just break with a general message
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.
Added check. Thanks!!
7fa9d7f
to
0c93649
Compare
CodSpeed Performance ReportMerging #838 will not alter performanceComparing Summary
|
anta/tests/snmp.py
Outdated
"""List of SNMP hosts.""" | ||
|
||
class SNMPHost(BaseModel): | ||
"""Model for a SNMP Manager.""" |
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.
"""Model for a SNMP Manager.""" | |
"""Model for a SNMP Host.""" |
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.
anta/tests/snmp.py
Outdated
"""Optional VRF for SNMP Hosts. If not provided, it defaults to `default`.""" | ||
notification_type: Literal["trap", "inform"] | ||
"""Type of SNMP notification (trap or inform).""" | ||
version: Literal["v1", "v2c", "v3"] |
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.
i think the snmp version you can move to custom type as we can use it for many other general snmp testcases
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.
Added to custom types.
anta/tests/snmp.py
Outdated
|
||
# Verify SNMP host details. | ||
if not (snmp_hosts := get_value(self.instance_commands[0].json_output, "hosts")): | ||
self.result.is_failure("SNMP is not configured.") |
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.
self.result.is_failure("SNMP is not configured.") | |
self.result.is_failure("No SNMP host is configured.") |
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. Thanks!!
bfa02e4
to
da8ba27
Compare
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
5a718d9
to
4b31a5d
Compare
Conflicts have been resolved. A maintainer will review the pull request shortly. |
Quality Gate passedIssues Measures |
Description
Verifies the SNMP notification host (SNMP manager) configurations.
Fixes #822
Checklist:
pre-commit run
)tox -e testenv
)