Skip to content
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

V7.1.6 Change of PEP8 naming convention has broken many functions (breaking backwards compatability) #132

Closed
WibblyGhost opened this issue Oct 13, 2024 · 4 comments
Labels
area:pysnmp PySNMP package bug Something isn't working

Comments

@WibblyGhost
Copy link

WibblyGhost commented Oct 13, 2024

Expected behavior

I should be able to run any PySNMP functions, but cannot.

Actual behavior

When updating to the latest version 7.1.6 of PySNMP, it seems to have broken all backwards compatability due to the commit that updates all functions to PEP8 compliance (which I agree is important), but testing has not been performed when pushing this release as it breaks all functions in PySNMP, and also breaks our custom MIB's created through PySMI's mibdump.

  File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/pysnmp/smi/view.py", line 284, in get_next_node_name
    self.__mibSymbolsIdx[modName]["oidToLabelIdx"].nextKey(oid) + suffix,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'OidOrderedDict' object has no attribute 'nextKey'. Did you mean: 'next_key'?

And our custom mibs created using the latest pysmi-lexstudio (1.4.3) also don't follow the new PEP8 naming convention change.

# Import base ASN.1 objects even if this MIB does not use it

(Integer,
 OctetString,
 ObjectIdentifier) = mibBuilder.importSymbols(
    "ASN1",
    "Integer",
    "OctetString",
    "ObjectIdentifier")

Or maybe I'm suppsoed to use pysmi (7.1.6) which has the following errors...

Traceback (most recent call last):
  File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/pysmi/borrower/pyfile.py", line 11, in <module>
    SOURCE_SUFFIXES = importlib.machinery.SOURCE_SUFFIXES
                      ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'importlib' has no attribute 'machinery'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/pysmi/borrower/pyfile.py", line 14, in <module>
    raise ImportError()
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/taitnet/Programming/integration-tests/.venv3/bin/mibdump", line 5, in <module>
    from pysmi.scripts.mibdump import start
  File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/pysmi/scripts/mibdump.py", line 16, in <module>
    from pysmi.borrower import AnyFileBorrower, PyFileBorrower
  File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/pysmi/borrower/__init__.py", line 8, in <module>
    from pysmi.borrower.pyfile import PyFileBorrower
  File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/pysmi/borrower/pyfile.py", line 17, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'

Detailed steps

The steps are,
Try run PySNMP
or
Try run custom MIBS with PySNMP

Python package information

7.1.6

Operating system information

Ubuntu

Python information

3.12

(Optional) Contents of your test script

No response

Relevant log output

File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/behave/model.py", line 1329, in run
    match.run(runner.context)
  File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/behave/matchers.py", line 98, in run
    self.func(context, *args, **kwargs)
  File "features/steps/snmp_steps.py", line 19, in create_snmp_rfss_endpoint
    snmp_client = SnmpClient(ip_address=rc_ip, port=CONTEXT_ITEMS.snmp_config["snmp_port"])
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/taitnet/Programming/integration-tests/features/classes/snmp_classes.py", line 99, in __init__
    self._load_mibs()
  File "/home/taitnet/Programming/integration-tests/features/classes/snmp_classes.py", line 94, in _load_mibs
    oid, _label, _suffix = self._mib_view.get_next_node_name(oid)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages/pysnmp/smi/view.py", line 284, in get_next_node_name
    self.__mibSymbolsIdx[modName]["oidToLabelIdx"].nextKey(oid) + suffix,
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'OidOrderedDict' object has no attribute 'nextKey'. Did you mean: 'next_key'?
@WibblyGhost WibblyGhost added bug Something isn't working triage New issues that need to be sorted out. labels Oct 13, 2024
@lextudio-support lextudio-support added the priority:low Low priority items. label Oct 13, 2024
@lextudio-support
Copy link

New issues are marked as low priority by default. Becoming our commercial customers, and then your reports are handled with higher priority after triage.

@lextm
Copy link

lextm commented Oct 14, 2024

Currently we mainly rely on the commercial customers to report compatibility issues, so reports like this indicate that unfortunately gaps exist and will last for a while.

You might try out the 7.1.7 release where we fixed some of these bugs. But we expect more similar issues to be reported.

We plan to address such by shipping more frequent releases throughout the 7.1.x cycle, till we feel it's safe to ship 8.0 with all compatibility layer removed.

@lextm lextm closed this as completed Oct 14, 2024
@lextm lextm added area:pysnmp PySNMP package and removed triage New issues that need to be sorted out. priority:low Low priority items. labels Oct 14, 2024
@lextm lextm pinned this issue Oct 14, 2024
@WibblyGhost
Copy link
Author

@lextm thanks for putting in a fix to the issue.
However pysmi still seems to be broken to some extent. When inputting a mib into mibdump it doesn't seem to output any PyMIBS.

mibdump --destination-format=pysnmp --destination-directory=pymibs tmp/COMMON-MIB.mib
Source MIB repositories: file:///home/___/Programming/integration-tests/tmp, file:///usr/share/snmp/mibs, https://mibs.pysnmp.com/asn1/@mib@
Borrow missing/failed MIBs from: https://mibs.pysnmp.com:443/mibs/notexts/@mib@
Existing/compiled MIB locations: pysnmp.smi.mibs, pysnmp_mibs
Compiled MIBs destination directory: pymibs
MIBs excluded from code generation: INET-ADDRESS-MIB, PYSNMP-USM-MIB, RFC-1212, RFC-1215, RFC1065-SMI, RFC1155-SMI, RFC1158-MIB, RFC1213-MIB, SNMP-FRAMEWORK-MIB, SNMP-TARGET-MIB, SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, SNMPv2-TM, TRANSPORT-ADDRESS-MIB
MIBs to compile: COMMON-MIB
Destination format: pysnmp
Custom destination template: None
Parser grammar cache directory: not used
Also compile all relevant MIBs: yes
Rebuild MIBs regardless of age: no
Dry run mode: no
Create/update MIBs: yes
Byte-compile Python modules: yes (optimization level no)
Ignore compilation errors: no
Generate OID->MIB index: no
Generate texts in MIBs: no
Keep original texts layout: no
Try various file names while searching for MIB module: yes
Created/updated MIBs: 
Pre-compiled MIBs borrowed: 
Up to date MIBs: SNMPv2-CONF, SNMPv2-SMI, SNMPv2-TC, COMMON-MIB
Missing source MIBs: 
Ignored MIBs: 
Failed MIBs:
pip show pysmi
Name: pysmi
Version: 1.5.4
Summary: A pure-Python implementation of SNMP/SMI MIB parsing and conversion library.
Home-page: https://github.com/lextudio/pysmi
Author: Ilya Etingof
Author-email: [email protected]
License: BSD-2-Clause
Location: /home/taitnet/Programming/integration-tests/.venv3/lib/python3.12/site-packages
Requires: Jinja2, ply, requests
Required-by: 

Am I missing something here?

@lextm
Copy link

lextm commented Oct 15, 2024

@WibblyGhost We currently possess a substantial inventory of MIB documents for testing. The latest version, 1.5.4, has shown decent performance with approximately 1,000 failed modules out of over 11,000 files.

Our current focus is on addressing the requirements of the commercial clients and we may extend testing to other requests like yours afterwards.

Any necessary fixes will be incorporated into upcoming releases of pysmi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:pysnmp PySNMP package bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants