summaryrefslogtreecommitdiff
path: root/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py')
-rw-r--r--examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py b/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py
index 088b72b..2dfbc55 100644
--- a/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py
+++ b/examples/v3arch/oneliner/agent/ntforg/inform-async-multiple-snmp-engines.py
@@ -26,19 +26,19 @@
#
from pysnmp.entity.rfc3413.oneliner import ntforg
from pysnmp.entity import engine
-from pysnmp.entity.rfc3413 import context
from pysnmp.carrier.asynsock.dispatch import AsynsockDispatcher
-from pysnmp.proto import rfc1902
# List of targets in the following format:
# ( ( authData, transportTarget ), ... )
targets = (
# 1-st target (SNMPv2c over IPv4/UDP)
( ntforg.CommunityData('public'),
- ntforg.UdpTransportTarget(('localhost', 1162)) ),
+ ntforg.UdpTransportTarget(('localhost', 1162)),
+ ntforg.ContextData() ),
# 2-nd target (SNMPv3 over IPv4/UDP)
( ntforg.UsmUserData('usr-md5-des', 'authkey1', 'privkey1'),
- ntforg.UdpTransportTarget(('localhost', 162)) )
+ ntforg.UdpTransportTarget(('localhost', 162)),
+ ntforg.ContextData() ),
)
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -69,19 +69,18 @@ snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B')
ntfOrg = ntforg.AsyncNotificationOriginator()
-for authData, transportTarget in targets:
+for authData, transportTarget, contextData in targets:
snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \
snmpEngineA or snmpEngineB
sendPduHandle = ntfOrg.sendNotification(
snmpEngine,
authData,
transportTarget,
- context.SnmpContext(snmpEngine),
- ntforg.null,
- 'inform',
- ntforg.MibVariable('SNMPv2-MIB', 'coldStart'),
- ( ( rfc1902.ObjectName('1.3.6.1.2.1.1.1.0'),
- rfc1902.OctetString('my name') ), ),
+ contextData,
+ 'inform', # NotifyType
+ ntforg.NotificationType(
+ ntforg.ObjectIdentity('SNMPv2-MIB', 'coldStart')
+ ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ),
cbInfo=(cbFun, snmpEngine)
)