From dad702f69446abcbcf32584743beb47f4583e0cd Mon Sep 17 00:00:00 2001 From: elie Date: Tue, 17 Jun 2014 05:46:57 +0000 Subject: converted to the latest API that supports more data to be used --- .../agent/ntforg/inform-multiple-protocols.py | 29 ++++++++++++++-------- examples/v3arch/agent/ntforg/inform-v2c.py | 25 ++++++++++++------- examples/v3arch/agent/ntforg/inform-v3.py | 17 +++++++++---- .../agent/ntforg/trap-v1-from-specific-address.py | 20 +++++++++------ examples/v3arch/agent/ntforg/trap-v1.py | 23 +++++++++++------ .../agent/ntforg/trap-v2c-multiple-addresses.py | 22 ++++++++++------ .../agent/ntforg/trap-v2c-multiple-transports.py | 24 +++++++++++------- .../v3arch/agent/ntforg/trap-v2c-with-objects.py | 14 +++++++---- examples/v3arch/agent/ntforg/trap-v2c.py | 29 ++++++++++++++-------- examples/v3arch/agent/ntforg/trap-v3.py | 22 ++++++++++------ examples/v3arch/manager/cmdgen/get-v1.py | 10 ++++---- .../manager/cmdgen/get-v2c-custom-timeout.py | 10 ++++---- .../v3arch/manager/cmdgen/get-v3-custom-context.py | 17 +++++++------ .../cmdgen/get-v3-observe-request-processing.py | 10 ++++---- examples/v3arch/manager/cmdgen/get-v3.py | 10 ++++---- examples/v3arch/manager/cmdgen/getbulk-v2c.py | 11 ++++---- examples/v3arch/manager/cmdgen/getbulk-v3.py | 7 +++--- examples/v3arch/manager/cmdgen/getnext-v1.py | 12 ++++----- .../cmdgen/getnext-v2c-from-specific-address.py | 12 ++++----- .../v3arch/manager/cmdgen/getnext-v3-over-ipv6.py | 12 ++++----- .../manager/cmdgen/getnext-v3-pull-subtree.py | 10 ++++---- examples/v3arch/manager/cmdgen/set-v1.py | 12 ++++----- examples/v3arch/manager/cmdgen/set-v2c.py | 10 ++++---- examples/v3arch/manager/cmdgen/set-v3.py | 10 ++++---- examples/v3arch/twisted/agent/ntforg/inform-v2c.py | 2 ++ examples/v3arch/twisted/agent/ntforg/inform-v3.py | 2 ++ examples/v3arch/twisted/agent/ntforg/trap-v1.py | 2 ++ .../agent/ntforg/trap-v2c-multiple-targets.py | 5 ++-- examples/v3arch/twisted/agent/ntforg/trap-v3.py | 2 ++ examples/v3arch/twisted/manager/cmdgen/get-v1.py | 9 ++++--- .../manager/cmdgen/get-v2c-custom-timeout.py | 9 ++++--- .../manager/cmdgen/get-v3-custom-context.py | 14 +++++------ examples/v3arch/twisted/manager/cmdgen/get-v3.py | 9 ++++--- .../v3arch/twisted/manager/cmdgen/getbulk-v2c.py | 9 ++++--- .../v3arch/twisted/manager/cmdgen/getbulk-v3.py | 11 ++++---- .../v3arch/twisted/manager/cmdgen/getnext-v1.py | 9 ++++--- .../cmdgen/getnext-v2c-from-specific-address.py | 9 ++++--- .../manager/cmdgen/getnext-v3-pull-subtree.py | 9 ++++--- examples/v3arch/twisted/manager/cmdgen/set-v1.py | 11 ++++---- examples/v3arch/twisted/manager/cmdgen/set-v2c.py | 9 ++++--- examples/v3arch/twisted/manager/cmdgen/set-v3.py | 9 ++++--- 41 files changed, 297 insertions(+), 211 deletions(-) (limited to 'examples') diff --git a/examples/v3arch/agent/ntforg/inform-multiple-protocols.py b/examples/v3arch/agent/ntforg/inform-multiple-protocols.py index 2c4e9bd..a3fbb8d 100644 --- a/examples/v3arch/agent/ntforg/inform-multiple-protocols.py +++ b/examples/v3arch/agent/ntforg/inform-multiple-protocols.py @@ -77,32 +77,39 @@ config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + # Create default SNMP context where contextEngineId == SnmpEngineId snmpContext = context.SnmpContext(snmpEngine) -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - -# Error/confirmation receiver -def cbFun(sendRequestHandle, errorIndication, cbCtx): +# Error/confirmation receiver +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( sendRequestHandle, errorIndication and errorIndication or 'delivered' ) ) - + # Build and submit notification message to dispatcher -ntfOrg.sendNotification( +sendRequestHandle = 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), v2c.OctetString('Example Notificator')), ), + # instance Index + None, + # additional var-binds: ( (oid, value), ... ) + [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')) ], cbFun ) -print('Notifications are scheduled to be sent') +print('Notifications %s are scheduled to be sent' % sendRequestHandle) # Run I/O dispatcher which would send pending message and process response snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/inform-v2c.py b/examples/v3arch/agent/ntforg/inform-v2c.py index 0d46c12..08993b0 100644 --- a/examples/v3arch/agent/ntforg/inform-v2c.py +++ b/examples/v3arch/agent/ntforg/inform-v2c.py @@ -56,29 +56,36 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + # Create default SNMP context where contextEngineId == SnmpEngineId snmpContext = context.SnmpContext(snmpEngine) -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - # Error/confirmation receiver -def cbFun(sendRequestHandle, errorIndication, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( sendRequestHandle, errorIndication and errorIndication or 'delivered' ) ) # Build and submit notification message to dispatcher -sendRequestHandle = ntfOrg.sendNotification( +sendRequestHandle = 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), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ), + # instance Index + None, + # additional var-binds: ( (oid, value), ... ) + [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), + ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ], cbFun ) diff --git a/examples/v3arch/agent/ntforg/inform-v3.py b/examples/v3arch/agent/ntforg/inform-v3.py index 8d1ca46..facebe3 100644 --- a/examples/v3arch/agent/ntforg/inform-v3.py +++ b/examples/v3arch/agent/ntforg/inform-v3.py @@ -61,21 +61,28 @@ snmpContext = context.SnmpContext(snmpEngine) ntfOrg = ntforg.NotificationOriginator(snmpContext) # Error/confirmation receiver -def cbFun(sendRequestHandle, errorIndication, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( sendRequestHandle, errorIndication and errorIndication or 'delivered' ) ) # Build and submit notification message to dispatcher -sendRequestHandle = ntfOrg.sendNotification( +sendRequestHandle = 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,5,0), v2c.OctetString('system name')), ), + # instance Index + None, + # additional var-binds: ( (oid, value), ... ) + [ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')) ], cbFun ) diff --git a/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py b/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py index 090e599..2bfa05d 100644 --- a/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py +++ b/examples/v3arch/agent/ntforg/trap-v1-from-specific-address.py @@ -54,19 +54,25 @@ config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** -# Create default SNMP context where contextEngineId == SnmpEngineId +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + + # Create default SNMP context where contextEngineId == SnmpEngineId snmpContext = context.SnmpContext(snmpEngine) -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - # Build and submit notification message to dispatcher -ntfOrg.sendNotification( +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), + # instance Index + None ) print('Notification is scheduled to be sent') diff --git a/examples/v3arch/agent/ntforg/trap-v1.py b/examples/v3arch/agent/ntforg/trap-v1.py index 6fa8e5b..f21bde5 100644 --- a/examples/v3arch/agent/ntforg/trap-v1.py +++ b/examples/v3arch/agent/ntforg/trap-v1.py @@ -61,21 +61,28 @@ config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** -# Create default SNMP context where contextEngineId == SnmpEngineId +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + + # Create default SNMP context where contextEngineId == SnmpEngineId snmpContext = context.SnmpContext(snmpEngine) -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - # Build and submit notification message to dispatcher -ntfOrg.sendNotification( +ntfOrg.sendVarBinds( snmpEngine, # Notification targets 'my-notification', - # TRAP OID: Generic Trap #6 (enterpriseSpecific) and Specific Trap 432 + # SNMP Context + snmpContext, + # contextName + '', + # notification name: Generic Trap #6 (enterpriseSpecific) + # and Specific Trap 432 '1.3.6.1.4.1.20408.4.1.1.2.0.432', + # instance Index + None, # additional var-binds - ( + [ # Uptime value with 12345 (v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'), v2c.TimeTicks(12345)), @@ -88,7 +95,7 @@ ntfOrg.sendNotification( # managed object '1.3.6.1.2.1.1.1.0' = 'my system' (v2c.ObjectIdentifier('1.3.6.1.2.1.1.1.0'), v2c.OctetString('my system')) - ) + ] ) print('Notification is scheduled to be sent') diff --git a/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py b/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py index 51cd7e1..329268f 100644 --- a/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py +++ b/examples/v3arch/agent/ntforg/trap-v2c-multiple-addresses.py @@ -71,22 +71,28 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + # Create default SNMP context where contextEngineId == SnmpEngineId snmpContext = context.SnmpContext(snmpEngine) -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - # Build and submit notification message to dispatcher -ntfOrg.sendNotification( +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), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ) + # instance Index + None, + # additional var-binds: ( (oid, value), ... ) + [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), + ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ] ) print('Notifications are scheduled to be sent') diff --git a/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py b/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py index 6215d5a..ea204f2 100644 --- a/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py +++ b/examples/v3arch/agent/ntforg/trap-v2c-multiple-transports.py @@ -70,22 +70,28 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** -# Create default SNMP context where contextEngineId == SnmpEngineId +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + + # Create default SNMP context where contextEngineId == SnmpEngineId snmpContext = context.SnmpContext(snmpEngine) -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - # Build and submit notification message to dispatcher -ntfOrg.sendNotification( +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), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ) + # instance Index + None, + # additional var-binds: ( (oid, value), ... ) + [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), + ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ] ) print('Notification is scheduled to be sent') diff --git a/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py b/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py index 5a9da88..e4ac2e0 100644 --- a/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py +++ b/examples/v3arch/agent/ntforg/trap-v2c-with-objects.py @@ -102,17 +102,21 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** # Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - +ntfOrg = ntforg.NotificationOriginator() + # Build and submit notification message to dispatcher -ntfOrg.sendNotification( +ntfOrg.sendVarBinds( snmpEngine, # Notification targets 'my-notification', - # Trap type + # SNMP Context + snmpContext, + # contextName + '', + # notification name ('ACCOUNTING-CONTROL-MIB', 'acctngFileFull'), # MIB scalar/table instances of NOTIFICATION-TYPE objects - instanceIndex=(0,) + (0,) ) print('Notification is scheduled to be sent') diff --git a/examples/v3arch/agent/ntforg/trap-v2c.py b/examples/v3arch/agent/ntforg/trap-v2c.py index 612074b..4e3465b 100644 --- a/examples/v3arch/agent/ntforg/trap-v2c.py +++ b/examples/v3arch/agent/ntforg/trap-v2c.py @@ -55,33 +55,40 @@ config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** -# Create default SNMP context where contextEngineId == SnmpEngineId +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + + # Create default SNMP context where contextEngineId == SnmpEngineId snmpContext = context.SnmpContext(snmpEngine) -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - # Error/confirmation receiver -def cbFun(sendRequestHandle, errorIndication, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): print('Notification %s, status - %s' % ( sendRequestHandle, errorIndication and errorIndication or 'delivered' ) ) # Build and submit notification message to dispatcher -ntfOrg.sendNotification( +sendRequestHandle = 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), v2c.OctetString('Example Notificator')), - ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ), + # instance Index + None, + # additional var-binds: ( (oid, value), ... ) + [ ((1,3,6,1,2,1,1,1,0), v2c.OctetString('Example Notificator')), + ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example')) ], cbFun ) -print('Notification is scheduled to be sent') +print('Notification %s is scheduled to be sent' % sendRequestHandle) # Run I/O dispatcher which would send pending message and process response snmpEngine.transportDispatcher.runDispatcher() diff --git a/examples/v3arch/agent/ntforg/trap-v3.py b/examples/v3arch/agent/ntforg/trap-v3.py index d53ac59..bff341a 100644 --- a/examples/v3arch/agent/ntforg/trap-v3.py +++ b/examples/v3arch/agent/ntforg/trap-v3.py @@ -59,21 +59,27 @@ config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1,3,6)) # *** SNMP engine configuration is complete by this line *** -# Create default SNMP context where contextEngineId == SnmpEngineId +# Create Notification Originator App instance. +ntfOrg = ntforg.NotificationOriginator() + + # Create default SNMP context where contextEngineId == SnmpEngineId snmpContext = context.SnmpContext(snmpEngine) -# Create Notification Originator App instance. -ntfOrg = ntforg.NotificationOriginator(snmpContext) - # Build and submit notification message to dispatcher -ntfOrg.sendNotification( +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,5,0), v2c.OctetString('system name')), ) + # instance Index + None, + # additional var-binds: ( (oid, value), ... ) + [ ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')) ] ) print('Notification is scheduled to be sent') diff --git a/examples/v3arch/manager/cmdgen/get-v1.py b/examples/v3arch/manager/cmdgen/get-v1.py index f1fb907..4fbfb8b 100644 --- a/examples/v3arch/manager/cmdgen/get-v1.py +++ b/examples/v3arch/manager/cmdgen/get-v1.py @@ -46,9 +46,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBinds, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, @@ -64,10 +63,11 @@ def cbFun(sendRequestHandle, print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) # Prepare and send a request message -cmdgen.GetCommandGenerator().sendReq( +cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,1,0), None), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,1,0), None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/get-v2c-custom-timeout.py b/examples/v3arch/manager/cmdgen/get-v2c-custom-timeout.py index 15f4abf..5ea17a4 100644 --- a/examples/v3arch/manager/cmdgen/get-v2c-custom-timeout.py +++ b/examples/v3arch/manager/cmdgen/get-v2c-custom-timeout.py @@ -49,9 +49,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBinds, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: @@ -65,10 +64,11 @@ def cbFun(sendRequestHandle, print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) # Prepare and send a request message -cmdgen.GetCommandGenerator().sendReq( +cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,1,0), None), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,1,0), None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/get-v3-custom-context.py b/examples/v3arch/manager/cmdgen/get-v3-custom-context.py index 7a863d6..0be8da9 100644 --- a/examples/v3arch/manager/cmdgen/get-v3-custom-context.py +++ b/examples/v3arch/manager/cmdgen/get-v3-custom-context.py @@ -51,9 +51,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBinds, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: @@ -67,13 +66,15 @@ def cbFun(sendRequestHandle, print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) # Prepare and send a request message, pass custom ContextEngineId & ContextName -cmdgen.GetCommandGenerator().sendReq( +cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,1,0), None), ), - cbFun, - contextEngineId=rfc1902.OctetString(hexValue='80004fb805636c6f75644dab22cc'), - contextName=rfc1902.OctetString('da761cfc8c94d3aceef4f60f049105ba') + # contextEngineId + rfc1902.OctetString(hexValue='80004fb805636c6f75644dab22cc'), + # contextName + rfc1902.OctetString('da761cfc8c94d3aceef4f60f049105ba'), + [ ((1,3,6,1,2,1,1,1,0), None) ], + cbFun ) # Run I/O dispatcher which would send pending queries and process responses diff --git a/examples/v3arch/manager/cmdgen/get-v3-observe-request-processing.py b/examples/v3arch/manager/cmdgen/get-v3-observe-request-processing.py index 0916b87..09c543b 100644 --- a/examples/v3arch/manager/cmdgen/get-v3-observe-request-processing.py +++ b/examples/v3arch/manager/cmdgen/get-v3-observe-request-processing.py @@ -73,9 +73,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBinds, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: @@ -89,10 +88,11 @@ def cbFun(sendRequestHandle, print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) # Prepare and send a request message -cmdgen.GetCommandGenerator().sendReq( +cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,1,0), None), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,1,0), None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/get-v3.py b/examples/v3arch/manager/cmdgen/get-v3.py index 95eba5d..e898904 100644 --- a/examples/v3arch/manager/cmdgen/get-v3.py +++ b/examples/v3arch/manager/cmdgen/get-v3.py @@ -48,9 +48,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBinds, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: @@ -64,10 +63,11 @@ def cbFun(sendRequestHandle, print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) # Prepare and send a request message -cmdgen.GetCommandGenerator().sendReq( +cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,1,0), None), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,1,0), None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/getbulk-v2c.py b/examples/v3arch/manager/cmdgen/getbulk-v2c.py index 62b4dd9..697c4cd 100644 --- a/examples/v3arch/manager/cmdgen/getbulk-v2c.py +++ b/examples/v3arch/manager/cmdgen/getbulk-v2c.py @@ -48,8 +48,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequesthandle, errorIndication, errorStatus, errorIndex, - varBindTable, cbCtx): +def cbFun(snmpEngine, sendRequesthandle, errorIndication, + errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return # stop on error @@ -66,12 +66,13 @@ def cbFun(sendRequesthandle, errorIndication, errorStatus, errorIndex, return True # signal dispatcher to continue walking # Prepare initial request to be sent -cmdgen.BulkCommandGenerator().sendReq( +cmdgen.BulkCommandGenerator().sendVarBinds( snmpEngine, 'my-router', + None, '', # contextEngineId, contextName 0, 25, # non-repeaters, max-repetitions - ( ((1,3,6,1,2,1,1), None), - ((1,3,6,1,4,1,1), None) ), + [ ((1,3,6,1,2,1,1), None), + ((1,3,6,1,4,1,1), None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/getbulk-v3.py b/examples/v3arch/manager/cmdgen/getbulk-v3.py index 5cdb598..660dcb2 100644 --- a/examples/v3arch/manager/cmdgen/getbulk-v3.py +++ b/examples/v3arch/manager/cmdgen/getbulk-v3.py @@ -50,8 +50,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequesthandle, errorIndication, errorStatus, errorIndex, - varBindTable, cbCtx): +def cbFun(snmpEngine, sendRequesthandle, errorIndication, + errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return # stop on error @@ -68,9 +68,10 @@ def cbFun(sendRequesthandle, errorIndication, errorStatus, errorIndex, return True # signal dispatcher to continue walking # Prepare initial request to be sent -cmdgen.BulkCommandGenerator().sendReq( +cmdgen.BulkCommandGenerator().sendVarBinds( snmpEngine, 'my-router', + None, '', # contextEngineId, contextName 0, 25, # non-repeaters, max-repetitions ( ((1,3,6,1,2,1,1), None), ((1,3,6,1,4,1,1), None) ), diff --git a/examples/v3arch/manager/cmdgen/getnext-v1.py b/examples/v3arch/manager/cmdgen/getnext-v1.py index 967186e..a5a17b4 100644 --- a/examples/v3arch/manager/cmdgen/getnext-v1.py +++ b/examples/v3arch/manager/cmdgen/getnext-v1.py @@ -47,9 +47,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBindTable, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return @@ -68,11 +67,12 @@ def cbFun(sendRequestHandle, return 1 # signal dispatcher to continue # Prepare initial request to be sent -cmdgen.NextCommandGenerator().sendReq( +cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1), None), - ((1,3,6,1,4,1,1), None), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1), None), + ((1,3,6,1,4,1,1), None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/getnext-v2c-from-specific-address.py b/examples/v3arch/manager/cmdgen/getnext-v2c-from-specific-address.py index fb167ba..dd8e4fd 100644 --- a/examples/v3arch/manager/cmdgen/getnext-v2c-from-specific-address.py +++ b/examples/v3arch/manager/cmdgen/getnext-v2c-from-specific-address.py @@ -48,9 +48,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBindTable, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return @@ -67,11 +66,12 @@ def cbFun(sendRequestHandle, return 1 # signal dispatcher to continue # Prepare initial request to be sent -cmdgen.NextCommandGenerator().sendReq( +cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1), None), - ((1,3,6,1,2,1,11), None), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1), None), + ((1,3,6,1,2,1,11), None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/getnext-v3-over-ipv6.py b/examples/v3arch/manager/cmdgen/getnext-v3-over-ipv6.py index 3377328..2a9e93a 100644 --- a/examples/v3arch/manager/cmdgen/getnext-v3-over-ipv6.py +++ b/examples/v3arch/manager/cmdgen/getnext-v3-over-ipv6.py @@ -48,9 +48,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBindTable, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return @@ -67,11 +66,12 @@ def cbFun(sendRequestHandle, return True # signal dispatcher to continue # Prepare initial request to be sent -cmdgen.NextCommandGenerator().sendReq( +cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1), None), - ((1,3,6,1,4,1,1), None), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1), None), + ((1,3,6,1,4,1,1), None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/getnext-v3-pull-subtree.py b/examples/v3arch/manager/cmdgen/getnext-v3-pull-subtree.py index 0ecdbad..0c870a7 100644 --- a/examples/v3arch/manager/cmdgen/getnext-v3-pull-subtree.py +++ b/examples/v3arch/manager/cmdgen/getnext-v3-pull-subtree.py @@ -51,9 +51,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBindTable, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBindTable, cbCtx): if errorIndication: print(errorIndication) return @@ -73,10 +72,11 @@ def cbFun(sendRequestHandle, return True # signal dispatcher to continue # Prepare initial request to be sent -cmdgen.NextCommandGenerator().sendReq( +cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( (initialOID, None), ), + None, '', # contextEngineId, contextName + [ (initialOID, None) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/set-v1.py b/examples/v3arch/manager/cmdgen/set-v1.py index c64b0fe..ba94a3b 100644 --- a/examples/v3arch/manager/cmdgen/set-v1.py +++ b/examples/v3arch/manager/cmdgen/set-v1.py @@ -47,9 +47,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBinds, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, @@ -65,11 +64,12 @@ def cbFun(sendRequestHandle, print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) # Prepare and send a request message -cmdgen.SetCommandGenerator().sendReq( +cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my value')), - ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my value')), + ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/set-v2c.py b/examples/v3arch/manager/cmdgen/set-v2c.py index d004433..00db8a0 100644 --- a/examples/v3arch/manager/cmdgen/set-v2c.py +++ b/examples/v3arch/manager/cmdgen/set-v2c.py @@ -47,9 +47,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBinds, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: @@ -63,10 +62,11 @@ def cbFun(sendRequestHandle, print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) # Prepare and send a request message -cmdgen.SetCommandGenerator().sendReq( +cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ], cbFun ) diff --git a/examples/v3arch/manager/cmdgen/set-v3.py b/examples/v3arch/manager/cmdgen/set-v3.py index 7764d7d..fd48438 100644 --- a/examples/v3arch/manager/cmdgen/set-v3.py +++ b/examples/v3arch/manager/cmdgen/set-v3.py @@ -48,9 +48,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(sendRequestHandle, - errorIndication, errorStatus, errorIndex, - varBinds, cbCtx): +def cbFun(snmpEngine, sendRequestHandle, errorIndication, + errorStatus, errorIndex, varBinds, cbCtx): if errorIndication: print(errorIndication) elif errorStatus: @@ -64,10 +63,11 @@ def cbFun(sendRequestHandle, print('%s = %s' % (oid.prettyPrint(), val.prettyPrint())) # Prepare and send a request message -cmdgen.SetCommandGenerator().sendReq( +cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my new value')), ), + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my new value')) ], cbFun ) diff --git a/examples/v3arch/twisted/agent/ntforg/inform-v2c.py b/examples/v3arch/twisted/agent/ntforg/inform-v2c.py index 2bd91d2..95ba561 100644 --- a/examples/v3arch/twisted/agent/ntforg/inform-v2c.py +++ b/examples/v3arch/twisted/agent/ntforg/inform-v2c.py @@ -91,6 +91,8 @@ df = ntfOrg.sendVarBinds( '', # notification name (SNMPv2-MIB::coldStart) (1,3,6,1,6,3,1,1,5,1), + # notification objects instance index + None, # 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')) ] diff --git a/examples/v3arch/twisted/agent/ntforg/inform-v3.py b/examples/v3arch/twisted/agent/ntforg/inform-v3.py index def2ad6..376da6e 100644 --- a/examples/v3arch/twisted/agent/ntforg/inform-v3.py +++ b/examples/v3arch/twisted/agent/ntforg/inform-v3.py @@ -89,6 +89,8 @@ df = ntfOrg.sendVarBinds( '', # notification name (SNMPv2-MIB::coldStart) (1,3,6,1,6,3,1,1,5,1), + # notification objects instance index + None, # additional var-binds: ( (oid, value), ... ) [ ((1,3,6,1,2,1,1,5,0), rfc1902.OctetString('system name')) ] ) diff --git a/examples/v3arch/twisted/agent/ntforg/trap-v1.py b/examples/v3arch/twisted/agent/ntforg/trap-v1.py index 557b352..6863e0d 100644 --- a/examples/v3arch/twisted/agent/ntforg/trap-v1.py +++ b/examples/v3arch/twisted/agent/ntforg/trap-v1.py @@ -84,6 +84,8 @@ ntfOrg.sendVarBinds( # notification name: Generic Trap #6 (enterpriseSpecific) # and Specific Trap 432 '1.3.6.1.4.1.20408.4.1.1.2.0.432', + # notification objects instance index + None, # additional var-binds holding SNMPv1 TRAP details [ # Uptime value with 12345 diff --git a/examples/v3arch/twisted/agent/ntforg/trap-v2c-multiple-targets.py b/examples/v3arch/twisted/agent/ntforg/trap-v2c-multiple-targets.py index 0717c7f..c63dc37 100644 --- a/examples/v3arch/twisted/agent/ntforg/trap-v2c-multiple-targets.py +++ b/examples/v3arch/twisted/agent/ntforg/trap-v2c-multiple-targets.py @@ -97,9 +97,10 @@ ntfOrg.sendVarBinds( snmpContext, # contextName '', - # notification name - # Trap OID (SNMPv2-MIB::coldStart) + # notification name (SNMPv2-MIB::coldStart) (1,3,6,1,6,3,1,1,5,1), + # notification objects instance index + None, # 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')) ] diff --git a/examples/v3arch/twisted/agent/ntforg/trap-v3.py b/examples/v3arch/twisted/agent/ntforg/trap-v3.py index 6c14fc5..c38e474 100644 --- a/examples/v3arch/twisted/agent/ntforg/trap-v3.py +++ b/examples/v3arch/twisted/agent/ntforg/trap-v3.py @@ -81,6 +81,8 @@ ntfOrg.sendVarBinds( '', # notification name (SNMPv2-MIB::coldStart) (1,3,6,1,6,3,1,1,5,1), + # notification objects instance index + None, # additional var-binds: ( (oid, value), ... ) [ ((1,3,6,1,2,1,1,5,0), rfc1902.OctetString('system name')) ] ) diff --git a/examples/v3arch/twisted/manager/cmdgen/get-v1.py b/examples/v3arch/twisted/manager/cmdgen/get-v1.py index 1ccf1ab..38428c6 100644 --- a/examples/v3arch/twisted/manager/cmdgen/get-v1.py +++ b/examples/v3arch/twisted/manager/cmdgen/get-v1.py @@ -48,8 +48,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBinds) = cbCtx +def cbFun(response, *args): + snmpEngine, errorIndication, errorStatus, errorIndex, varBinds = response if errorIndication: print(errorIndication) # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, @@ -67,10 +67,11 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.GetCommandGenerator().sendReq( +df = cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ('1.3.6.1.2.1.1.1.0', None), ('1.3.6.1.2.1.1.2.0', None) ), + None, '', # contextEngineId, contextName + [ ('1.3.6.1.2.1.1.1.0', None), ('1.3.6.1.2.1.1.2.0', None) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/get-v2c-custom-timeout.py b/examples/v3arch/twisted/manager/cmdgen/get-v2c-custom-timeout.py index 5e36d99..246a1b9 100644 --- a/examples/v3arch/twisted/manager/cmdgen/get-v2c-custom-timeout.py +++ b/examples/v3arch/twisted/manager/cmdgen/get-v2c-custom-timeout.py @@ -51,8 +51,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBinds) = cbCtx +def cbFun(response, *args): + snmpEngine, errorIndication, errorStatus, errorIndex, varBinds = response if errorIndication: print(errorIndication) elif errorStatus: @@ -68,10 +68,11 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.GetCommandGenerator().sendReq( +df = cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ('1.3.6.1.2.1.1.1.0', None), ), + None, '', # contextEngineId, contextName + [ ('1.3.6.1.2.1.1.1.0', None) ], ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/get-v3-custom-context.py b/examples/v3arch/twisted/manager/cmdgen/get-v3-custom-context.py index 516bbba..e85babe 100644 --- a/examples/v3arch/twisted/manager/cmdgen/get-v3-custom-context.py +++ b/examples/v3arch/twisted/manager/cmdgen/get-v3-custom-context.py @@ -4,7 +4,7 @@ # Send a SNMP GET request # with SNMPv3 with user 'usr-md5-none', SHA auth and no privacy protocols # for MIB instance identified by -# contextEngineId: 80004fb805636c6f75644dab22cc +# contextEngineId: 0x80004fb805636c6f75644dab22cc # contextName: da761cfc8c94d3aceef4f60f049105ba # using Twisted framework for network transport # over IPv4/UDP @@ -53,8 +53,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBinds) = cbCtx +def cbFun(response, *args): + snmpEngine, errorIndication, errorStatus, errorIndex, varBinds = response if errorIndication: print(errorIndication) elif errorStatus: @@ -70,12 +70,12 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.GetCommandGenerator().sendReq( +df = cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ('1.3.6.1.2.1.1.1.0', None), ), - contextEngineId=rfc1902.OctetString(hexValue='80004fb805636c6f75644dab22cc'), - contextName=rfc1902.OctetString('da761cfc8c94d3aceef4f60f049105ba') + rfc1902.OctetString(hexValue='80004fb805636c6f75644dab22cc'), + rfc1902.OctetString('da761cfc8c94d3aceef4f60f049105ba'), + [ ('1.3.6.1.2.1.1.1.0', None) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/get-v3.py b/examples/v3arch/twisted/manager/cmdgen/get-v3.py index 967e024..0e3ab3e 100644 --- a/examples/v3arch/twisted/manager/cmdgen/get-v3.py +++ b/examples/v3arch/twisted/manager/cmdgen/get-v3.py @@ -50,8 +50,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBinds) = cbCtx +def cbFun(response, *args): + snmpEngine, errorIndication, errorStatus, errorIndex, varBinds = response if errorIndication: print(errorIndication) elif errorStatus: @@ -67,10 +67,11 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.GetCommandGenerator().sendReq( +df = cmdgen.GetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ('1.3.6.1.2.1.1.1.0', None), ), + None, '', # contextEngineId, contextName + [ ('1.3.6.1.2.1.1.1.0', None) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/getbulk-v2c.py b/examples/v3arch/twisted/manager/cmdgen/getbulk-v2c.py index 7a67f74..fd761c9 100644 --- a/examples/v3arch/twisted/manager/cmdgen/getbulk-v2c.py +++ b/examples/v3arch/twisted/manager/cmdgen/getbulk-v2c.py @@ -51,8 +51,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBindTable) = cbCtx +def cbFun(response, *args): + snmpEngine, errorIndication, errorStatus, errorIndex, varBindTable = response if errorIndication: print(errorIndication) elif errorStatus: @@ -84,11 +84,12 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.BulkCommandGenerator().sendReq( +df = cmdgen.BulkCommandGenerator().sendVarBinds( snmpEngine, 'my-router', 0, 25, # non-repeaters, max-repetitions - ( ('1.3.6.1.2.1.1', None), ('1.3.6.1.4.1.1', None) ) + None, '', # contextEngineId, contextName + [ ('1.3.6.1.2.1.1', None), ('1.3.6.1.4.1.1', None) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/getbulk-v3.py b/examples/v3arch/twisted/manager/cmdgen/getbulk-v3.py index e93927d..49017dc 100644 --- a/examples/v3arch/twisted/manager/cmdgen/getbulk-v3.py +++ b/examples/v3arch/twisted/manager/cmdgen/getbulk-v3.py @@ -53,8 +53,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBindTable) = cbCtx +def cbFun(response): + snmpEngine, errorIndication, errorStatus, errorIndex, varBindTable = response if errorIndication: print(errorIndication) elif errorStatus: @@ -85,11 +85,12 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.BulkCommandGenerator().sendReq( +df = cmdgen.BulkCommandGenerator().sendVarBinds( snmpEngine, - 'my-router', + 'my-router', 0, 25, # non-repeaters, max-repetitions - ( ((1,3,6,1,2,1,1), None), ((1,3,6,1,4,1,1), None) ) + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1), None), ((1,3,6,1,4,1,1), None) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/getnext-v1.py b/examples/v3arch/twisted/manager/cmdgen/getnext-v1.py index d47b552..dede0ab 100644 --- a/examples/v3arch/twisted/manager/cmdgen/getnext-v1.py +++ b/examples/v3arch/twisted/manager/cmdgen/getnext-v1.py @@ -50,8 +50,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBindTable) = cbCtx +def cbFun(response): + snmpEngine, errorIndication, errorStatus, errorIndex, varBindTable = response if errorIndication: print(errorIndication) # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, @@ -84,10 +84,11 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.NextCommandGenerator().sendReq( +df = cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ('1.3.6.1.2.1.1', None), ('1.3.6.1.4.1.1', None) ), + None, '', # contextEngineId, contextName + [ ('1.3.6.1.2.1.1', None), ('1.3.6.1.4.1.1', None) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/getnext-v2c-from-specific-address.py b/examples/v3arch/twisted/manager/cmdgen/getnext-v2c-from-specific-address.py index 0b7f88a..c27b643 100644 --- a/examples/v3arch/twisted/manager/cmdgen/getnext-v2c-from-specific-address.py +++ b/examples/v3arch/twisted/manager/cmdgen/getnext-v2c-from-specific-address.py @@ -51,8 +51,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBindTable) = cbCtx +def cbFun(response, *args): + snmpEngine, errorIndication, errorStatus, errorIndex, varBindTable = response if errorIndication: print(errorIndication) elif errorStatus: @@ -84,10 +84,11 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.NextCommandGenerator().sendReq( +df = cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ('1.3.6.1.2.1.1', None), ('1.3.6.1.2.1.11', None) ) + None, '', # contextEngineId, contextName + [ ('1.3.6.1.2.1.1', None), ('1.3.6.1.2.1.11', None) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/getnext-v3-pull-subtree.py b/examples/v3arch/twisted/manager/cmdgen/getnext-v3-pull-subtree.py index 77499d8..bff697e 100644 --- a/examples/v3arch/twisted/manager/cmdgen/getnext-v3-pull-subtree.py +++ b/examples/v3arch/twisted/manager/cmdgen/getnext-v3-pull-subtree.py @@ -53,8 +53,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBindTable) = cbCtx +def cbFun(response, *args): + snmpEngine, errorIndication, errorStatus, errorIndex, varBindTable = response if errorIndication: print(errorIndication) elif errorStatus: @@ -89,10 +89,11 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.NextCommandGenerator().sendReq( +df = cmdgen.NextCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( (initialOID, None), ) + None, '', # contextEngineId, contextName + [ (initialOID, None) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/set-v1.py b/examples/v3arch/twisted/manager/cmdgen/set-v1.py index a58a67e..c372104 100644 --- a/examples/v3arch/twisted/manager/cmdgen/set-v1.py +++ b/examples/v3arch/twisted/manager/cmdgen/set-v1.py @@ -49,8 +49,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBinds) = cbCtx +def cbFun(response, *args): + snmpEngine, errorIndication, errorStatus, errorIndex, varBinds = response if errorIndication: print(errorIndication) # SNMPv1 response may contain noSuchName error *and* SNMPv2c exception, @@ -68,11 +68,12 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.SetCommandGenerator().sendReq( +df = cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my value')), - ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.Integer(123)) ) + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my value')), + ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.Integer(123)) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/set-v2c.py b/examples/v3arch/twisted/manager/cmdgen/set-v2c.py index 981842d..5fd91f1 100644 --- a/examples/v3arch/twisted/manager/cmdgen/set-v2c.py +++ b/examples/v3arch/twisted/manager/cmdgen/set-v2c.py @@ -49,8 +49,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBinds) = cbCtx +def cbFun(response): + snmpEngine, errorIndication, errorStatus, errorIndex, varBinds = response if errorIndication: print(errorIndication) elif errorStatus: @@ -66,10 +66,11 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.SetCommandGenerator().sendReq( +df = cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.Integer(123)), ) + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.Integer(123)) ] ) # Register error/response receiver function at deferred diff --git a/examples/v3arch/twisted/manager/cmdgen/set-v3.py b/examples/v3arch/twisted/manager/cmdgen/set-v3.py index 5d32570..1fb7ce8 100644 --- a/examples/v3arch/twisted/manager/cmdgen/set-v3.py +++ b/examples/v3arch/twisted/manager/cmdgen/set-v3.py @@ -50,8 +50,8 @@ config.addTargetAddr( ) # Error/response receiver -def cbFun(cbCtx): - (errorIndication, errorStatus, errorIndex, varBinds) = cbCtx +def cbFun(response): + snmpEngine, errorIndication, errorStatus, errorIndex, varBinds = response if errorIndication: print(errorIndication) elif errorStatus: @@ -67,10 +67,11 @@ def cbFun(cbCtx): reactor.stop() # Prepare request to be sent yielding Twisted deferred object -df = cmdgen.SetCommandGenerator().sendReq( +df = cmdgen.SetCommandGenerator().sendVarBinds( snmpEngine, 'my-router', - ( ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my new value')), ) + None, '', # contextEngineId, contextName + [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my new value')) ] ) # Register error/response receiver function at deferred -- cgit v1.2.1