diff options
Diffstat (limited to 'pysnmp')
-rw-r--r-- | pysnmp/hlapi/varbinds.py | 10 | ||||
-rw-r--r-- | pysnmp/smi/rfc1902.py | 16 |
2 files changed, 18 insertions, 8 deletions
diff --git a/pysnmp/hlapi/varbinds.py b/pysnmp/hlapi/varbinds.py index 0eed7e50..6f118c78 100644 --- a/pysnmp/hlapi/varbinds.py +++ b/pysnmp/hlapi/varbinds.py @@ -45,7 +45,8 @@ class CommandGeneratorVarBinds(MibViewControllerManager): else: varBind = ObjectType(ObjectIdentity(varBind[0]), varBind[1]) - resolvedVarBinds.append(varBind.resolveWithMib(mibViewController)) + resolvedVarBinds.append( + varBind.resolveWithMib(mibViewController, ignoreErrors=False)) return resolvedVarBinds @@ -65,13 +66,16 @@ class NotificationOriginatorVarBinds(MibViewControllerManager): mibViewController = self.getMibViewController(userCache) if isinstance(varBinds, NotificationType): - return varBinds.resolveWithMib(mibViewController) + return varBinds.resolveWithMib( + mibViewController, ignoreErrors=False) resolvedVarBinds = [] for varBind in varBinds: if isinstance(varBind, NotificationType): - resolvedVarBinds.extend(varBind.resolveWithMib(mibViewController)) + resolvedVarBinds.extend( + varBind.resolveWithMib( + mibViewController, ignoreErrors=False)) continue if isinstance(varBind, ObjectType): diff --git a/pysnmp/smi/rfc1902.py b/pysnmp/smi/rfc1902.py index c96996b9..5b8f994e 100644 --- a/pysnmp/smi/rfc1902.py +++ b/pysnmp/smi/rfc1902.py @@ -1236,7 +1236,7 @@ class NotificationType(object): def isFullyResolved(self): return self._state & self.ST_CLEAN - def resolveWithMib(self, mibViewController): + def resolveWithMib(self, mibViewController, ignoreErrors=True): """Perform MIB variable ID conversion and notification objects expansion. Parameters @@ -1244,6 +1244,12 @@ class NotificationType(object): mibViewController : :py:class:`~pysnmp.smi.view.MibViewController` class instance representing MIB browsing functionality. + Other Parameters + ---------------- + ignoreErrors: :py:class:`bool` + If `True` (default), ignore MIB object name or value casting + failures if possible. + Returns ------- : :py:class:`~pysnmp.smi.rfc1902.NotificationType` @@ -1280,7 +1286,8 @@ class NotificationType(object): self._varBinds.append( ObjectType(ObjectIdentity(v2c.apiTrapPDU.snmpTrapOID), - self._objectIdentity).resolveWithMib(mibViewController)) + self._objectIdentity).resolveWithMib( + mibViewController, ignoreErrors)) SmiNotificationType, = mibViewController.mibBuilder.importSymbols( 'SNMPv2-SMI', 'NotificationType') @@ -1301,7 +1308,7 @@ class NotificationType(object): objectIdentity, self._objects.get( notificationObject, rfc1905.unSpecified)) - objectType.resolveWithMib(mibViewController) + objectType.resolveWithMib(mibViewController, ignoreErrors) self._varBinds.append(objectType) @@ -1315,8 +1322,7 @@ class NotificationType(object): for varBinds in self._additionalVarBinds: if not isinstance(varBinds, ObjectType): varBinds = ObjectType(ObjectIdentity(varBinds[0]), varBinds[1]) - - varBinds.resolveWithMib(mibViewController) + varBinds.resolveWithMib(mibViewController, ignoreErrors) if varBinds[0] in varBindsLocation: self._varBinds[varBindsLocation[varBinds[0]]] = varBinds |