-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add SNMPv3 support to nav.Snmp.pynetsnmp
implementation
#2703
Add SNMPv3 support to nav.Snmp.pynetsnmp
implementation
#2703
Conversation
I'm kind of reticent to add all these arguments directly to the |
597f90c
to
deae6cc
Compare
Codecov Report
@@ Coverage Diff @@
## snmpv3 #2703 +/- ##
=======================================
Coverage 55.19% 55.19%
=======================================
Files 561 562 +1
Lines 40946 41004 +58
=======================================
+ Hits 22601 22634 +33
- Misses 18345 18370 +25
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Just a slight cleanup before starting on SNMPv3 support
These could be re-used elsewhere, like in the `SNMPv3Form`.
This adds the optional SNMPv3 parameters to `nav.Snmp.pynetsnmp.Snmp`, along with parameter verification based on the selected SNMP version.
This reworks the SNMP command line builder to include SNMPv3 parameters as needed.
deae6cc
to
03eba24
Compare
I agree that a dataclass should be made for the parameter inputs |
self, | ||
host: str, | ||
community: str = "public", | ||
version: Union[str, int] = "1", | ||
port: Union[str, int] = 161, | ||
retries: int = 3, | ||
timeout: int = 1, | ||
# SNMPv3-only options | ||
sec_level: Optional[SecurityLevel] = None, | ||
auth_protocol: Optional[AuthenticationProtocol] = None, | ||
sec_name: Optional[str] = None, | ||
auth_password: Optional[str] = None, | ||
priv_protocol: Optional[PrivacyProtocol] = None, | ||
priv_password: Optional[str] = None, |
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 see what you mean about the ugly __init__
.
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.
Anything else missing than tests?
Snmp.__init__() can now raise exceptions before `self.handle` is ever created, thereby causing errors to be logged from Snmp.__del_ everytime the garbage collector deletes such defunct object. This protects against that silly situation.
Kudos, SonarCloud Quality Gate passed! |
Yes, I just pushed a small update for a silly bug. Tests would be nice, but I have to think a bit about how do to them - the coverage on this file is a measly 54% as of now, so I might want to do them in a separate PR... And a good question is whether we should act on @stveit's suggestion... |
Ah well, dammnit. Pushing to the wrong branch screwed up this PR, marking it as merged. That was not the intent - now I can't reopen it. I'll have to make a new one. |
Add SNMPv3 support to nav.Snmp.pynetsnmp implementation #2703
This adds the necessary arguments, validation and a reworked command line builder for SNMPv3 communication to the synchronous SNMP implementation in
nav.Snmp.pynetsnmp.Snmp
.Closes #2700