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

Loading compiled LLDP-MIB fails with error "'lldpLocManAddrEntry' is not defined" #91

Closed
AlexLardschneider opened this issue Jul 30, 2024 · 4 comments
Labels
area:pysmi PySMI package bug Something isn't working workaround available While this is a bug, feasible workarounds exist so users can continue their work.

Comments

@AlexLardschneider
Copy link

AlexLardschneider commented Jul 30, 2024

Expected behavior

Trying to load the compiled version of LLDP-MIB (found here) and compiled using

mibdump --destination-directory=compiled --rebuild --quiet ./mibs/common/*

fails with the following error:

Traceback (most recent call last):
  File "/Users/Alex/Developer/Test/venv/lib/python3.11/site-packages/pysnmp/smi/builder.py", line 376, in loadModule
    exec(codeObj, g)
  File "compiled/LLDP-MIB.py", line 485, in <module>
    lldpLocManAddrEntry.registerAugmentions(
    ^^^^^^^^^^^^^^^^^^^
NameError: name 'lldpLocManAddrEntry' is not defined. Did you mean: 'lldpConfigManAddrEntry'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
: INFO     : aiomq.py         : RabbitMQ: Starting publisher.
    self.run()
  File "/usr/local/Cellar/python@3.11/3.11.9/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 982, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/Alex/Developer/Test/app.py", line 87, in init_snmp
    mib_builder.init()
  File "/Users/Alex/Developer/Test/util/mib_builder.py", line 121, in init
    mibBuilder.loadModules(*MIBS_GENERIC)
  File "/Users/Alex/Developer/Test/venv/lib/python3.11/site-packages/pysnmp/smi/builder.py", line 417, in loadModules
    self.loadModule(modName, **userCtx)
  File "/Users/Alex/Developer/Test/venv/lib/python3.11/site-packages/pysnmp/smi/builder.py", line 380, in loadModule
    raise error.MibLoadError(
pysnmp.smi.error.MibLoadError: MIB module 'compiled/LLDP-MIBcompiled/LLDP-MIB.py' load error: ['Traceback (most recent call last):\n', '  File "/Users/Alex/Developer/Test/venv/lib/python3.11/site-packages/pysnmp/smi/builder.py", line 376, in loadModule\n    exec(codeObj, g)\n', '  File "compiled/LLDP-MIB.py", line 485, in <module>\n    lldpLocManAddrEntry.registerAugmentions(\n    ^^^^^^^^^^^^^^^^^^^\n', "NameError: name 'lldpLocManAddrEntry' is not defined\n"] caused by <class 'NameError'>: name 'lldpLocManAddrEntry' is not defined

It looks like the compiled version of LLDP-MIB is trying to call the function registerAugmentions on object lldpLocManAddrEntry (like 485), but lldpLocManAddrEntry is first defined on line 819.

Actual behavior

PySNMP should load the compiled MIB file without errors.

Detailed steps

See above.

Python package information

pysmi-lextudio==1.4.3
pysnmp-lextudio==6.2.1
pyasn1==0.6.0

Operating system information

macOS

Python information

3.11

(Optional) Contents of your test script

No response

Relevant log output

No response

@AlexLardschneider AlexLardschneider added bug Something isn't working triage New issues that need to be sorted out. labels Jul 30, 2024
@steven-douilliet
Copy link

See also #90 which talks about LLDP-MIB.

@lextm lextm added area:pysmi PySMI package and removed triage New issues that need to be sorted out. labels Jul 30, 2024
@lextm
Copy link

lextm commented Jul 30, 2024

This all comes down to how PySMI compiles RMON2-MIB and LLDP-MIB.

While the bugfix won't come sooner as we have other priorities at hand, the workaround is simple enough,

  1. Open up LLDP-MIB.py in a text editor.
  2. Find the lines that refer to lldpLocManAddrEntry (two sections in total), cut and paste them right behind lldpLocManAddrEntry's definition line.

BTW, please migrate from pysmi-lextudio/pysnmp-lextudio to pysmi/pysnmp. The former packages with postfix are no longer in maintenance.

@lextm lextm added up for grabs Pull requests are welcome priority:low Low priority items. labels Jul 30, 2024
@lextm lextm added the workaround available While this is a bug, feasible workarounds exist so users can continue their work. label Aug 2, 2024
@lextm
Copy link

lextm commented Aug 16, 2024

Close this now as won't work on it in near future.

@lextm
Copy link

lextm commented Sep 2, 2024

Should have been fixed in PySMI release 1.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:pysmi PySMI package bug Something isn't working workaround available While this is a bug, feasible workarounds exist so users can continue their work.
Projects
None yet
Development

No branches or pull requests

3 participants