Skip to content

Conversation

@lunkwill42
Copy link
Member

@lunkwill42 lunkwill42 commented Dec 5, 2025

Scope and purpose

Fixes #2811. Dependent on #3664.

This is still a work in progress, since I'm not yet able to confirm this functionality with real devices due to potential SNMPv3 authorization issues with test equipment.

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • Wrote the commit message so that the first line continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • Based this pull request on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • If it's not obvious from a linked issue, described how to interact with NAV in order for a reviewer to observe the effects of this change first-hand (commands, URLs, UI interactions)
  • If this results in changes in the UI: Added screenshots of the before and after
  • If this adds a new Python source code file: Added the boilerplate header to that file

@lunkwill42 lunkwill42 self-assigned this Dec 5, 2025
@lunkwill42 lunkwill42 added cisco snmpv3 nonews No news fragment is necessary for this PR (e.g. refactoring, cleanups, workflow/development changes) labels Dec 5, 2025
Base automatically changed from refactor/multibridgemib-inlinecallbacks to master December 5, 2025 13:28
@lunkwill42 lunkwill42 force-pushed the feature/snmpv3-multibridgemib-contexts branch from e870583 to 0feea79 Compare December 5, 2025 13:28
@lunkwill42 lunkwill42 changed the title Feature/snmpv3 multibridgemib contexts Use SNMPv3 contexts for collecting logical BRIDGE-MIB instances (primarily Cisco) Dec 5, 2025
Henceforth, a logical MIB instance identifier may also include an
optional SNMPv3 context name, and an optional context engine ID, if
such things were discovered. Since a community value makes no sense for
SNMPv3 communication, the community field should also be optional.
Some code still expected a BRIDGE-MIB instance descriptor to be a
two-tuple value, but should really produce LogicalMibInstance named
tuples.
We need to fetch context name and context engine ID values from logical
MIB instances to know how to configure our SNMPv3 requests to fetch
these logical instances.
In order to support SNMPv3 contexts, this adds `context_name` and
`context_engine_id` as optional attributes on SNMPParameters objects,
and ensures the correct Net-SNMP command line arguments are generated
for them.
Making alternate agent proxy instances need to consider which SNMP
version is represented, as changing the community makes no sense on
SNMPv3 sessions, while changing context name (and optionally adding a
context engine id) does.

It's also easier and more portable to manipulate parameters selectively
by modifying the `snmp_parameters` of the existing session: That way,
all other parameters of the session are carried through to the alternate
agent proxies.
Only care about debug logging that we got results from alternate
agent proxies, as timeouts would be silently ignored.
@lunkwill42 lunkwill42 force-pushed the feature/snmpv3-multibridgemib-contexts branch from 0feea79 to 6c555bb Compare December 5, 2025 13:34
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Test results

   14 files     14 suites   13m 17s ⏱️
2 702 tests 2 700 ✅ 0 💤 2 ❌
9 593 runs  9 587 ✅ 0 💤 6 ❌

For more details on these failures, see this check.

Results for commit 6c555bb.

@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.73%. Comparing base (1a9ba8e) to head (6c555bb).
⚠️ Report is 25 commits behind head on master.

Files with missing lines Patch % Lines
python/nav/mibs/mibretriever.py 24.00% 19 Missing ⚠️
python/nav/ipdevpoll/snmp/common.py 66.66% 2 Missing ⚠️
python/nav/ipdevpoll/utils.py 75.00% 1 Missing ⚠️
python/nav/mibs/cisco_vtp_mib.py 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3668      +/-   ##
==========================================
- Coverage   62.94%   62.73%   -0.22%     
==========================================
  Files         611      612       +1     
  Lines       45145    45172      +27     
  Branches       43       43              
==========================================
- Hits        28417    28339      -78     
- Misses      16718    16823     +105     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cisco nonews No news fragment is necessary for this PR (e.g. refactoring, cleanups, workflow/development changes) snmpv3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement SNMPv3 contexts as alternative to community indexing for retrieval of logical BRIDGE-MIB instances on Cisco switches

2 participants