diff options
author | elie <elie> | 2015-09-27 10:26:25 +0000 |
---|---|---|
committer | elie <elie> | 2015-09-27 10:26:25 +0000 |
commit | 627d9ff4a3715477e56fe397f099ad0db0d5c1b9 (patch) | |
tree | 60cdd6f446e892194122abad0dfa4c6413eb4374 /examples/hlapi/asyncore/agent/ntforg | |
parent | bdfbce73382678e0288d8bc8d3093c827b05e1d1 (diff) | |
download | pysnmp-627d9ff4a3715477e56fe397f099ad0db0d5c1b9.tar.gz |
* Asyncore and asyncio-based APIs reworked to become functions.
* Asyncio and Twisted API moved entirely into high-level domain to
be aligned with other high-level APIs. This WILL BREAK backward
compatibility for those apps that use Twisted API.
Diffstat (limited to 'examples/hlapi/asyncore/agent/ntforg')
11 files changed, 18 insertions, 26 deletions
diff --git a/examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py b/examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py index e2cacbe..c0ae96b 100644 --- a/examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py +++ b/examples/hlapi/asyncore/agent/ntforg/async-multiple-informs-at-once.py @@ -42,10 +42,8 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication, snmpEngine = SnmpEngine() -ntfOrg = AsyncNotificationOriginator() - for authData, transportTarget, contextData in targets: - sendPduHandle = ntfOrg.sendNotification( + sendPduHandle = sendNotification( snmpEngine, authData, transportTarget, @@ -54,7 +52,7 @@ for authData, transportTarget, contextData in targets: NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ), - cbInfo=(cbFun, None) + cbFun=cbFun ) snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py b/examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py index 3d4d4b6..729f2e5 100644 --- a/examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py +++ b/examples/hlapi/asyncore/agent/ntforg/async-multiple-traps-at-once.py @@ -31,10 +31,8 @@ targets = ( snmpEngine = SnmpEngine() -ntfOrg = AsyncNotificationOriginator() - for authData, transportTarget, contextData in targets: - ntfOrg.sendNotification( + sendNotification( snmpEngine, authData, transportTarget, @@ -43,7 +41,7 @@ for authData, transportTarget, contextData in targets: NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') ).addVarBinds( - ( ObjectName('1.3.6.1.2.1.1.1.0'), + ( ObjectIdentifier('1.3.6.1.2.1.1.1.0'), OctetString('my name') ) ) ) diff --git a/examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py b/examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py index 9df9daf..ce9db15 100644 --- a/examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py +++ b/examples/hlapi/asyncore/agent/ntforg/async-running-multiple-snmp-engines-at-once.py @@ -68,12 +68,10 @@ snmpEngineA.registerTransportDispatcher(transportDispatcher, 'A') snmpEngineB = SnmpEngine() snmpEngineB.registerTransportDispatcher(transportDispatcher, 'B') -ntfOrg = AsyncNotificationOriginator() - for authData, transportTarget, contextData in targets: snmpEngine = transportTarget.getTransportInfo()[1][1] % 3 and \ snmpEngineA or snmpEngineB - sendPduHandle = ntfOrg.sendNotification( + sendPduHandle = sendNotification( snmpEngine, authData, transportTarget, @@ -82,7 +80,7 @@ for authData, transportTarget, contextData in targets: NotificationType( ObjectIdentity('SNMPv2-MIB', 'coldStart') ).addVarBinds( ( '1.3.6.1.2.1.1.1.0', 'my name' ) ), - cbInfo=(cbFun, snmpEngine) + cbFun=cbFun, cbCtx=snmpEngine ) transportDispatcher.runDispatcher() diff --git a/examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py b/examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py index 1a65a61..2ccdafe 100644 --- a/examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py +++ b/examples/hlapi/asyncore/agent/ntforg/custom-contextengineid.py @@ -24,15 +24,13 @@ Functionally similar to: | 1.3.6.1.6.3.1.1.5.2 """# -from pysnmp.hlapi.asyncore import * +from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(), UsmUserData('usr-md5-none', 'authkey1'), UdpTransportTarget(('localhost', 162)), - ContextData( - rfc1902.OctetString(hexValue='8000000004030201') - ), + ContextData(OctetString(hexValue='8000000004030201')), 'inform', NotificationType(ObjectIdentity('1.3.6.1.6.3.1.1.5.2'))) ) diff --git a/examples/hlapi/asyncore/agent/ntforg/custom-contextname.py b/examples/hlapi/asyncore/agent/ntforg/custom-contextname.py index c322d55..a087c7e 100644 --- a/examples/hlapi/asyncore/agent/ntforg/custom-contextname.py +++ b/examples/hlapi/asyncore/agent/ntforg/custom-contextname.py @@ -24,7 +24,7 @@ Functionally similar to: | 1.3.6.1.6.3.1.1.5.2 """# -from pysnmp.hlapi.asyncore import * +from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(), diff --git a/examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py b/examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py index 51bf05a..768ad26 100644 --- a/examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py +++ b/examples/hlapi/asyncore/agent/ntforg/custom-v1-trap.py @@ -28,7 +28,7 @@ Functionally similar to: | '1.3.6.1.2.1.1.1.0' s 'my system' """# -from pysnmp.hlapi.asyncore import * +from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(), @@ -42,7 +42,7 @@ errorIndication, errorStatus, errorIndex, varBinds = next( ('1.3.6.1.2.1.1.3.0', 12345), ('1.3.6.1.6.3.18.1.3.0', '127.0.0.1'), ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), - ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system')) + ('1.3.6.1.2.1.1.1.0', OctetString('my system')) ) ) ) diff --git a/examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py b/examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py index 75542ba..7d4a9d0 100644 --- a/examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py +++ b/examples/hlapi/asyncore/agent/ntforg/default-v1-trap.py @@ -26,7 +26,7 @@ Functionally similar to: | '1.3.6.1.2.1.1.1.0' s 'my system' """# -from pysnmp.hlapi.asyncore import * +from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(), @@ -38,7 +38,7 @@ errorIndication, errorStatus, errorIndex, varBinds = next( ObjectIdentity('1.3.6.1.6.3.1.1.5.2') ).addVarBinds( ('1.3.6.1.6.3.1.1.4.3.0', '1.3.6.1.4.1.20408.4.1.1.2'), - ('1.3.6.1.2.1.1.1.0', rfc1902.OctetString('my system')) + ('1.3.6.1.2.1.1.1.0', OctetString('my system')) ) ) ) diff --git a/examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py b/examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py index 096eb34..17cf899 100644 --- a/examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py +++ b/examples/hlapi/asyncore/agent/ntforg/send-notification-with-additional-varbinds.py @@ -20,7 +20,7 @@ Functionally similar to: | 1.3.6.1.2.1.1.1.0 s 'my system' """# -from pysnmp.hlapi.asyncore import * +from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(), diff --git a/examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py b/examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py index 296aebc..e5121b2 100644 --- a/examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py +++ b/examples/hlapi/asyncore/agent/ntforg/v2c-trap-via-notification-type.py @@ -16,10 +16,10 @@ Functionally similar to: | $ snmptrap -v2c -c public demo.snmplabs.com \ | 12345 -| 1.3.6.1.4.1.20408.4.1.1.2 \ +| 1.3.6.1.4.1.20408.4.1.1.2 """# -from pysnmp.hlapi.asyncore import * +from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(), diff --git a/examples/hlapi/asyncore/agent/ntforg/v3-inform.py b/examples/hlapi/asyncore/agent/ntforg/v3-inform.py index ebf2fdf..39f5127 100644 --- a/examples/hlapi/asyncore/agent/ntforg/v3-inform.py +++ b/examples/hlapi/asyncore/agent/ntforg/v3-inform.py @@ -20,7 +20,7 @@ Functionally similar to: | '1.3.6.1.2.1.1.1.0' s 'my system' """# -from pysnmp.hlapi.asyncore import * +from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(), diff --git a/examples/hlapi/asyncore/agent/ntforg/v3-trap.py b/examples/hlapi/asyncore/agent/ntforg/v3-trap.py index 27d081d..ba62b39 100644 --- a/examples/hlapi/asyncore/agent/ntforg/v3-trap.py +++ b/examples/hlapi/asyncore/agent/ntforg/v3-trap.py @@ -26,7 +26,7 @@ Functionally similar to: | '1.3.6.1.2.1.1.1.0' s 'my system' """# -from pysnmp.hlapi.asyncore import * +from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( sendNotification(SnmpEngine(OctetString(hexValue='8000000001020304')), |