-
Notifications
You must be signed in to change notification settings - Fork 4
Number of additions and improvements #1
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks! |
|
Thanks for the initial review! Usually the write authorizations are different than the read authorizations. I think understand your point... Since the authorizations is a list, I could append the write authorization to the list. My concern with this approach is that without actually writing to an oid you don't really know whether the authorization is for reading or writing. So with it broken out into a separate parameter the caller can explicitly make the call which authorization is for read vs writing. Also, the changes should be compatible, however it looks like I failed to do that. I'll add a default (None) for the write authorization parameter so that it is compatible. |
|
You're saying you have authorizations that can write but cannot read? In that case I'd use two snmpclient objects instead of two lists of authorizations. |
|
Though looking at that code a bit further. The whole authorization selection in my original code is a bit bonkers. One should just give it a valid authorization instead of making snmpclient try more than one until one works. That's a backwards compatibility breakage I can accept 😄 |
|
Correct. Most SNMP devices use two different logins for the operation, usually private for writing, and public for reading. |
|
I'm happy to re-write the authorizations to just take a dictionary with a single entry for reading, and another entry for writing. Reading entry is required, writing entry is optional. Does that sound good? |
|
I've not seen that before. In my environment, the private one can always be used for both reading and writing. Let me ponder a bit about what I want to do here. |
|
Interesting. All the APC products ship with a default of public/private community strings with the distinction of which one is read-only vs read/write. Since some oid are read/write, I would argue that reads should happen with the read only account, and writes with the other, applying the principal of least privilege needed for an operation. In any case, let me know how you want to change it; I'm happy to make the change and flexible with the signature of |
|
I have a different interpretation of that principle. I wouldn't separate per function call, but per script/tool. If a script doesn't need r/w access, it gets the r/o user. If it needs write access, it gets the r/w user and uses it for both reading and writing. So I'm probably going to rip out both my old crappy auth selection (which was there for a reason that has gone away) and the separate read and write auths, and just require users to provide a single authorization. Apart from that I have the following comments:
|
|
One more comment: what's your minimum python version requirement? I'll port the library to python 3 while I'm at it and want to kill support for python 2.6 and older if possible. |
I'm fine to rip out the old auth mechanism and go with usage being that one object is used for reading and one for writing, each with different authorizations. How do you want to proceed? Do you want me to make the changes? Or will you merge and make the changes? |
|
I'm going to do some preparatory commits (I'm not really happy with the current state of the project) and cherry-pick the parts of your commits I want to keep. Then I'll push that out on a branch for discussion. Stay tuned! |
|
Ok, let me know if you need to do jump in. |
|
Regarding the big if clause, yep you're right! That's a lot cleaner. |
|
Any update on this merge or the other rework? |
Updated a number of things: