summaryrefslogtreecommitdiff
path: root/examples/v3arch/twisted/agent/ntforg/inform-v2c.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/v3arch/twisted/agent/ntforg/inform-v2c.py')
-rw-r--r--examples/v3arch/twisted/agent/ntforg/inform-v2c.py26
1 files changed, 15 insertions, 11 deletions
diff --git a/examples/v3arch/twisted/agent/ntforg/inform-v2c.py b/examples/v3arch/twisted/agent/ntforg/inform-v2c.py
index 960fcc4..2bd91d2 100644
--- a/examples/v3arch/twisted/agent/ntforg/inform-v2c.py
+++ b/examples/v3arch/twisted/agent/ntforg/inform-v2c.py
@@ -64,15 +64,12 @@ config.addNotificationTarget(
config.addContext(snmpEngine, '')
config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
-# Create default SNMP context where contextEngineId == SnmpEngineId
-snmpContext = context.SnmpContext(snmpEngine)
-
# Create Notification Originator App instance.
-ntfOrg = ntforg.NotificationOriginator(snmpContext)
+ntfOrg = ntforg.NotificationOriginator()
# Error/confirmation receiver
-def cbFun(cbCtx):
- (errorIndication, errorStatus, errorIndex, varBinds) = cbCtx
+def cbFun(response, *args):
+ snmpEngine, errorIndication, errorStatus, errorIndex, varBinds = response
print('Notification status - %s' % (
errorIndication and errorIndication or 'delivered'
)
@@ -80,16 +77,23 @@ def cbFun(cbCtx):
# Optionally stop Twisted reactor
reactor.stop()
+# Create default SNMP context where contextEngineId == SnmpEngineId
+snmpContext = context.SnmpContext(snmpEngine)
+
# Prepare request to be sent yielding Twisted deferred object
-df = ntfOrg.sendNotification(
+df = ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
'my-notification',
- # Trap OID (SNMPv2-MIB::coldStart)
+ # SNMP Context
+ snmpContext,
+ # contextName
+ '',
+ # notification name (SNMPv2-MIB::coldStart)
(1,3,6,1,6,3,1,1,5,1),
- # ( (oid, value), ... )
- ( ((1,3,6,1,2,1,1,1,0), rfc1902.OctetString('Example Notificator')),
- ((1,3,6,1,2,1,1,5,0), rfc1902.OctetString('Notificator Example')) )
+ # additional var-binds: [ (oid, value), ... ]
+ [ ((1,3,6,1,2,1,1,1,0), rfc1902.OctetString('Example Notificator')),
+ ((1,3,6,1,2,1,1,5,0), rfc1902.OctetString('Notificator Example')) ]
)
# Register error/response receiver function at deferred