Skip to content

Update pyasn1 pysnmp; Fix tests#201

Open
moto-timo wants to merge 7 commits intopdudaemon:mainfrom
moto-timo:timo/pyasn1-pysnmp-debian-bug-1117416
Open

Update pyasn1 pysnmp; Fix tests#201
moto-timo wants to merge 7 commits intopdudaemon:mainfrom
moto-timo:timo/pyasn1-pysnmp-debian-bug-1117416

Conversation

@moto-timo
Copy link

@moto-timo moto-timo commented Feb 15, 2026

I don't have an SNMP PDU to test on, so we need to make sure to test the new snmp async code. But I did add a test suite that passes.

Update pysnmp from >=4.4.12, <6 to >=7.1.22 and pyasn1 from <0.6.1
to >=0.6.2 to support the latest upstream releases.

This fixes compatibility with current Debian packages.

Closes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1117416
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Port the SNMP driver to the pysnmp 7.1 v3arch asyncio API:
- Import from pysnmp.hlapi.v3arch.asyncio instead of pysnmp.hlapi
- setCmd -> set_cmd (PEP 8 naming convention)
- UdpTransportTarget() -> await UdpTransportTarget.create() (async DNS)
- next(setCmd(...)) -> await set_cmd(...) (coroutine instead of generator)
- addAsn1MibSource -> add_asn1_mib_source (PEP 8 naming convention)
- Update MIB source URL from defunct mibs.snmplabs.com to mibs.pysnmp.com
- Add SnmpEngine.close_dispatcher() cleanup in a finally block
- Run async code via asyncio.run() from the sync port_interaction method

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Fix: LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy
     "ENV key value" format

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Replace the deprecated pkg_resources.iter_entry_points() with
importlib.metadata.entry_points(), which is available in the
standard library since Python 3.9.

This fixes ModuleNotFoundError on systems where setuptools is not
installed.

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Add 20 tests covering:
- accepts() class method for driver selection
- __init__() with SNMPv1 and SNMPv3 settings
- port_interaction() command validation and async dispatch
- _port_interaction_async() for both SNMPv1 and SNMPv3 paths
- Error handling: missing username/community, unknown version,
  error indication, error status, and engine cleanup on failure
- inside_number controlpoint substitution with and without
  static_ending
- SNMPv3 auth/priv protocol configuration

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
@moto-timo
Copy link
Author

I have a proof of concept for a test suite:
https://github.com/moto-timo/pdudaemon/tree/timo/test_snmp

@moto-timo moto-timo force-pushed the timo/pyasn1-pysnmp-debian-bug-1117416 branch from 4e1e76a to b5d0471 Compare February 15, 2026 17:27
Fixes: PytestUnknownMarkWarning: Unknown pytest.mark.asyncio - is this a typo?

Signed-off-by: Tim Orling <tim.orling@konsulko.com>
Python 3.8 and 3.9 are EOL [1]
The bump in python3-pysnmp minimum requirement is python 3.10 [2]

[1] https://devguide.python.org/versions/#status-of-python-versions
[2] https://pypi.org/project/pysnmp/7.1.22/
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
@moto-timo moto-timo force-pushed the timo/pyasn1-pysnmp-debian-bug-1117416 branch from b5d0471 to 9240c6e Compare February 15, 2026 17:32
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.

Migrate from pkg_resources to importlib Migration to pysnmp-lextudio SNMP MIBs rely on snmplabs which is no more

1 participant