Skip to content

Implement an SNMP back-end selection option in zino.toml #396

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

Merged
merged 10 commits into from
Mar 12, 2025

Conversation

lunkwill42
Copy link
Member

@lunkwill42 lunkwill42 commented Feb 19, 2025

Scope and purpose

Part of fix for #383. Dependent on #394 and #395.

This adds an option snmp.backend to the configuration file zino.toml (defaulting to the new netsnmp-cffi back-end).

Since netsnmp-cffi is a new back-end, still in development, this allows users to optionally go back to the original PySNMP-based back-end in case they experience stability issues with the new solution.

This pull request

  • adds an option configuration option to zino.toml
  • changes how SNMP back-ends are selected/loaded

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to Zino can be found in the
README.

  • Added a changelog fragment for towncrier
  • Added/amended tests for new/changed code
  • Added/changed documentation
  • Linted/formatted the code with black, ruff and isort, easiest by using pre-commit
  • The first line of the commit message 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/
  • If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done

@lunkwill42 lunkwill42 self-assigned this Feb 19, 2025
Copy link

github-actions bot commented Feb 19, 2025

🦙 MegaLinter status: ✅ SUCCESS

Descriptor Linter Files Fixed Errors Elapsed time
✅ PYTHON black 73 0 1.42s
✅ PYTHON isort 73 0 0.56s
✅ PYTHON ruff 73 0 0.03s

See detailed report in MegaLinter reports
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security

Copy link

github-actions bot commented Feb 19, 2025

Test results

    3 files      3 suites   1m 15s ⏱️
  660 tests   660 ✅ 0 💤 0 ❌
1 932 runs  1 930 ✅ 2 💤 0 ❌

Results for commit 77c07f6.

♻️ This comment has been updated with latest results.

Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 98.76543% with 1 line in your changes missing coverage. Please review.

Project coverage is 98.59%. Comparing base (980ac89) to head (77c07f6).
Report is 16 commits behind head on master.

Files with missing lines Patch % Lines
src/zino/trapd/__init__.py 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #396      +/-   ##
==========================================
+ Coverage   98.46%   98.59%   +0.14%     
==========================================
  Files          83       83              
  Lines        9971    10021      +50     
==========================================
+ Hits         9817     9880      +63     
+ Misses        154      141      -13     

☔ 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.

@lunkwill42 lunkwill42 changed the title Implements an SNMP back-end selection option in zino.toml Implement an SNMP back-end selection option in zino.toml Feb 20, 2025
@johannaengland johannaengland force-pushed the feature/add-snmp-backend-selection-option branch from 9df3750 to acf514d Compare February 27, 2025 09:10
Copy link
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

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

It would be good to document somewhere that it is not enough to change the snmp.backend setting in the config for a running Zino, but that it needs to be restarted for it to come into effect

@lunkwill42
Copy link
Member Author

It would be good to document somewhere that it is not enough to change the snmp.backend setting in the config for a running Zino, but that it needs to be restarted for it to come into effect

Doesn't every change to zino.toml require a restart to take effect, @johannaengland ?

@johannaengland
Copy link
Contributor

It would be good to document somewhere that it is not enough to change the snmp.backend setting in the config for a running Zino, but that it needs to be restarted for it to come into effect

Doesn't every change to zino.toml require a restart to take effect, @johannaengland ?

Yes, it does, I mixed up polldevs.cf and zino.toml 😅

@lunkwill42 lunkwill42 force-pushed the feature/use-netsnmp-cffi-for-traps branch from a97452c to decef88 Compare March 10, 2025 13:54
@lunkwill42 lunkwill42 force-pushed the feature/add-snmp-backend-selection-option branch from acf514d to 82ed56a Compare March 10, 2025 14:05
@lunkwill42 lunkwill42 force-pushed the feature/use-netsnmp-cffi-for-traps branch from decef88 to 1ed57cf Compare March 10, 2025 14:09
@lunkwill42 lunkwill42 force-pushed the feature/add-snmp-backend-selection-option branch from 82ed56a to 0745cbb Compare March 10, 2025 14:10
@lunkwill42 lunkwill42 force-pushed the feature/add-snmp-backend-selection-option branch from 0745cbb to 5895c86 Compare March 10, 2025 15:38
@lunkwill42
Copy link
Member Author

Keeping this in draft mode until I'm satisfied with test coverage

@lunkwill42 lunkwill42 force-pushed the feature/use-netsnmp-cffi-for-traps branch from 0e9cd93 to cceb873 Compare March 11, 2025 07:53
@lunkwill42 lunkwill42 force-pushed the feature/add-snmp-backend-selection-option branch 2 times, most recently from d62026d to f066705 Compare March 11, 2025 14:50
@lunkwill42
Copy link
Member Author

Coverage looks ok now, so taking out of draft

@lunkwill42 lunkwill42 marked this pull request as ready for review March 11, 2025 14:52
Copy link
Contributor

@hmpf hmpf left a comment

Choose a reason for hiding this comment

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

See questions

@lunkwill42 lunkwill42 requested a review from hmpf March 12, 2025 13:12
This adds functionality to `zino.snmp` and `zino.trapd` to select
between the supported back-ends.

This is mostly geared at loading a single default back-end for the
running process, but will allow for importing more than one back-end,
for example for testing scenarios.
Instead of the Zino main program initializing the netsnmpy backend
explicitly, ensure the call goes out to the selected backend instead.
This just ensure the example program can keep running.
A back-end needs to be loaded before much of the Zino code can be
tested, but since multiple back-ends can eventually be imported, the
test suite can still target explicit back-ends if needed.
@lunkwill42 lunkwill42 force-pushed the feature/add-snmp-backend-selection-option branch from 20b06d0 to 4eccdf0 Compare March 12, 2025 13:57
Copy link
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

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

Just a nitpick about test names 😁

Because I changed two lines to make the script work, CodeCov insists
I need coverage of those lines - but getuptime.py had no coverage to
begin with.  Not really very relevant to this particular PR, but it
turns out that getuptime.py actually didn't work as intended, which
these tests discovered - so overall, this is a good thing :)
As commented in code-review.
@lunkwill42 lunkwill42 force-pushed the feature/add-snmp-backend-selection-option branch from 4eccdf0 to 77c07f6 Compare March 12, 2025 14:32
Copy link

Base automatically changed from feature/use-netsnmp-cffi-for-traps to master March 12, 2025 14:37
@lunkwill42 lunkwill42 merged commit c5965ee into master Mar 12, 2025
11 checks passed
@lunkwill42 lunkwill42 deleted the feature/add-snmp-backend-selection-option branch March 12, 2025 14:38
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.

4 participants