Closed simonryf closed 3 days ago
Also SIP-COMMON-MIB fails for the same reason, however there SYNTAX is BITS which is definitely by the spec (https://www.rfc-editor.org/rfc/rfc2578.txt -> 7.9. Mapping of the DEFVAL clause)
SIP-COMMON-MIB:
sipCommonCfgServiceNotifEnable OBJECT-TYPE
SYNTAX BITS {
sipCommonServiceColdStart(0),
sipCommonServiceWarmStart(1),
sipCommonServiceStatusChanged(2)
}
MAX-ACCESS read-write
STATUS current
DESCRIPTION
"This object specifies which SIP service related notifications
are enabled. Each bit represents a specific notification. If
a bit has a value 1, the associated notification is enabled and
will be generated by the SIP entity at the appropriate time.
Support for these notifications is OPTIONAL: either none or all
notification values are supported. If an implementation does
not support this object, it should return a 'noSuchObject'
exception to an SNMP GET operation. If notifications are
supported, this object's default value SHOULD reflect
sipCommonServiceColdStart and sipCommonServiceWarmStart enabled
and sipCommonServiceStatusChanged disabled.
This object value SHOULD persist across reboots."
DEFVAL { { sipCommonServiceColdStart,
sipCommonServiceWarmStart } }
::= { sipCommonCfgEntry 7 }
reproduce:
mkdir snmp-test && cd snmp-test
pyenv local 3.12.4
pyenv virtualenv snmp-test
pyenv local snmp-test
pip install pysmi-lextudio
mkdir -p ./mibs && mkdir -p ./mib_cache
# get mibs from lextudio
mibs=(
"SIP-COMMON-MIB"
"SNMPv2-SMI"
"SNMPv2-TC"
"SNMPv2-CONF"
"SNMP-FRAMEWORK-MIB"
"SIP-TC-MIB"
"NETWORK-SERVICES-MIB"
"INET-ADDRESS-MIB"
)
url_prefix="https://raw.githubusercontent.com/lextudio/mibs.pysnmp.com/master/asn1/"
output_dir="./mibs"
for mib in "${mibs[@]}"; do
wget "${url_prefix}${mib}" -O "${output_dir}/${mib}.mib"
done
# compile mibs
mibdump --mib-source ./mibs --destination-directory ./mib_cache SIP-COMMON-MIB
The parser does understand the DEFVAL definition properly (so JSON output is correct), but the template is incorrect so it cannot output proper Python.
Should have been fixed in PySMI release 1.5.0.
Expected behavior
mibdump compiles successfully (e.g. DOCS-IF3-MIB)
Actual behavior
Failed MIBs: DOCS-IF3-MIB (Jinja template rendering error: 'collections.OrderedDict object' has no attribute 'default' at MIB DOCS-IF3-MIB)
Detailed steps
This is a follow up from https://github.com/etingof/pysmi/issues/72
Using only MIBs from https://github.com/lextudio/mibs.pysnmp.com/tree/master/asn1 I could successfully compile DOCS-IF3-MIB. However taking the latest DOCS-IF3-MIB from http://mibs.cablelabs.com/MIBs/DOCSIS/DOCS-IF3-MIB-2024-07-05.txt
I noticed a difference in DOCS-IF3-MIB, see specifically line 3242
DEFVAL { { bonding } }
:changing this line back (as it was in the version from mibs.pysnmp.com) to:
it compiles successfully again. Hope this helps to track the issue down. Of course I'm not 100% confident that Enumerated DEFVAL with TEXTUAL-CONVENTION is actually something which is by the spec.
Python package information
pysmi-lextudio = "1.4.3"
Operating system information
macOS
Python information
3.12.4
(Optional) Contents of your test script
Relevant log output