Skip to content
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 Logging Configuration #849

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vitthalmagadum
Copy link
Collaborator

Description

Verifies whether the SNMP logging is enabled and SNMP manager(host) details in a specified VRF.

Expected Results
----------------
* Success: The test will pass if the SNMP logging is enabled and manager(host) details is in the specified VRF.
* Failure: The test will fail if the SNMP logging is disabled or the SNMP manager details are not correct.

Fixes #821

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have run pre-commit for code linting and typing (pre-commit run)
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (tox -e testenv)

Copy link

codspeed-hq bot commented Oct 3, 2024

CodSpeed Performance Report

Merging #849 will not alter performance

Comparing vitthalmagadum:issue_821 (6449e97) with main (92cbcd3)

Summary

✅ 8 untouched benchmarks

failures += f"SNMP host '{hostname }' is not configured.\n"
continue
if actual_vrf != vrf:
failures += f"SNMP host '{hostname }' is not correctly configured in specified vrf '{vrf}'.\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should give the failure message like For SNMP host '{hostname }' expected vrf is blah but found blah11 instead.

class SNMPHost(BaseModel):
"""Model for a SNMP Host."""

hostname: IPv4Address
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there is only option of ipv4 address then better to use host instead of hostname. If we can use and name then update input restriction

"hosts": {
"192.168.1.100": {"port": 162, "vrf": ""},
"192.168.1.101": {"port": 162, "vrf": "MGMT"},
"snmp-server-01": {"port": 162, "vrf": "MGMT"},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you share the json output from device for hostname

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaf1-dc1#show snmp | json
{
    "chassis": {
        "chassisId": "C2BB56D511CAB40E40B2DCD1E9D3A9C9"
    },
    "contact": {
        "contact": "\"Network Admin\""
    },
    "location": {
        "location": "\"Data Center A\""
    },
    "counters": {
        "serviceEnabled": true,
        "inPkts": 0,
        "inVersionErrs": 0,
        "inBadCommunityNames": 0,
        "inBadCommunityUses": 0,
        "inParseErrs": 0,
        "inRequestVars": 0,
        "inSetVars": 0,
        "inGetPdus": 0,
        "inGetNextPdus": 0,
        "inSetPdus": 0,
        "outPkts": 5,
        "outTooBigErrs": 0,
        "outNoSuchNameErrs": 0,
        "outBadValueErrs": 0,
        "outGeneralErrs": 0,
        "outGetResponsePdus": 0,
        "outTrapPdus": 5,
        "outTrapDrops": 0,
        "groupLength": 3,
        "numberOfGroups": 9,
        "numberOfViews": 0
    },
    "logging": {
        "loggingEnabled": true,
        "hosts": {
            "192.168.1.100": {
                "port": 162,
                "vrf": ""
            },
            "leaf1-dc1": {
                "port": 162,
                "vrf": ""
            },
            "spine": {
                "port": 162,
                "vrf": ""
            },
            "spine1-dc1.fun.aristanetworks.com": {
                "port": 162,
                "vrf": ""
            }
        }
    },
    "vrfs": {
        "snmpVrfs": [
            "default"
        ]
    },
    "srcIntf": {
        "sourceInterfaces": {
            "default": "Management0",
            "MGMT": "Ethernet1"
        }
    },
    "misc": {
        "transmitMsgMaxSize": 65536
    },
    "enabled": true,
}

Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved. A maintainer will review the pull request shortly.

Copy link

sonarcloud bot commented Oct 14, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the test case to verify SNMP Logging Configuration.
2 participants