diff options
author | Ilya Etingof <etingof@gmail.com> | 2018-10-13 20:21:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-13 20:21:31 +0200 |
commit | 534a5bb8108013c59706c4fb6d195aa332af5e13 (patch) | |
tree | 26683f3689386d7ca11216c952861e1184430eee /examples/v3arch/asyncore/agent/cmdrsp | |
parent | 12138b182c82981c5268a18b15178ed564be874f (diff) | |
download | pysnmp-git-534a5bb8108013c59706c4fb6d195aa332af5e13.tar.gz |
Convert to async MIB instrumentation API (#209)
MIB instrumentation API changed to allow for asynchronous
managed objects access. Although built-in SNMPv2-SMI objects
are still synchronous, the MIB instrumentation API is async
what allows users to replace default MIB instrumentation
with their own, potentially asynchronous.
CommandResponder refactored to facilitate asynchronous
MIB instrumentation routines. The `readVars`, `readNextVars`
and `writeVars` MIB controller methods return immediately and
deliver their results via a call back.
SMI/MIB managed objects API overhauled for simplicity and
flexibility breaking backward compatibility.
Diffstat (limited to 'examples/v3arch/asyncore/agent/cmdrsp')
-rw-r--r-- | examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py b/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py index 94bdb7de..7e74df3d 100644 --- a/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py +++ b/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py @@ -54,7 +54,9 @@ snmpContext = context.SnmpContext(snmpEngine) # always echos request var-binds in response. class EchoMibInstrumController(instrum.AbstractMibInstrumController): def readVars(self, *varBinds, **context): - return [(ov[0], v2c.OctetString('You queried OID %s' % ov[0])) for ov in varBinds] + cbFun = context.get('cbFun') + if cbFun: + cbFun([(ov[0], v2c.OctetString('You queried OID %s' % ov[0])) for ov in varBinds], **context) # Create a custom Management Instrumentation Controller and register at |