From 483c99653c66d6c05f7ac9d56f68d0c608468455 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 --- .../multiple-different-notifications-at-once.py | 29 ++++++++++++++-------- .../ntforg/send-inform-to-multiple-managers.py | 22 ++++++++++------ .../ntforg/send-notification-over-ipv4-and-ipv6.py | 24 +++++++++++------- .../ntforg/send-packet-from-specific-address.py | 20 +++++++++------ .../v3arch/asyncore/agent/ntforg/usm-md5-none.py | 17 +++++++++---- examples/v3arch/asyncore/agent/ntforg/v1-trap.py | 23 +++++++++++------ .../v3arch/asyncore/agent/ntforg/v2c-inform.py | 25 ++++++++++++------- .../agent/ntforg/v2c-trap-via-notification-type.py | 14 +++++++---- examples/v3arch/asyncore/agent/ntforg/v2c-trap.py | 29 ++++++++++++++-------- examples/v3arch/asyncore/agent/ntforg/v3-trap.py | 22 ++++++++++------ .../custom-contextengineid-and-contextname.py | 17 +++++++------ .../manager/cmdgen/custom-timeout-and-retries.py | 10 ++++---- .../manager/cmdgen/fetch-variables-over-ipv6.py | 12 ++++----- .../getbulk-fetch-scalar-and-table-variables.py | 7 +++--- .../manager/cmdgen/getbulk-multiple-oids-to-eom.py | 11 ++++---- .../manager/cmdgen/getnext-multiple-oids-to-eom.py | 12 ++++----- .../manager/cmdgen/observe-request-processing.py | 10 ++++---- .../v3arch/asyncore/manager/cmdgen/pull-subtree.py | 10 ++++---- .../cmdgen/send-packets-from-specific-interface.py | 12 ++++----- .../manager/cmdgen/set-multiple-scalar-values.py | 12 ++++----- .../asyncore/manager/cmdgen/usm-sha-aes128.py | 10 ++++---- .../v3arch/asyncore/manager/cmdgen/usm-sha-none.py | 10 ++++---- examples/v3arch/asyncore/manager/cmdgen/v1-get.py | 10 ++++---- examples/v3arch/asyncore/manager/cmdgen/v2c-set.py | 10 ++++---- 24 files changed, 222 insertions(+), 156 deletions(-) (limited to 'examples/v3arch') diff --git a/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py b/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py index 2c4e9bd7..a3fbb8d5 100644 --- a/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py +++ b/examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.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/asyncore/agent/ntforg/send-inform-to-multiple-managers.py b/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py index 51cd7e1f..329268f1 100644 --- a/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py +++ b/examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.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/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py b/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py index 6215d5a0..ea204f2c 100644 --- a/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py +++ b/examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.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/asyncore/agent/ntforg/send-packet-from-specific-address.py b/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py index 090e5994..2bfa05d6 100644 --- a/examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py +++ b/examples/v3arch/asyncore/agent/ntforg/send-packet-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/asyncore/agent/ntforg/usm-md5-none.py b/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py index 8d1ca469..facebe34 100644 --- a/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py +++ b/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.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/asyncore/agent/ntforg/v1-trap.py b/examples/v3arch/asyncore/agent/ntforg/v1-trap.py index 6fa8e5b4..f21bde50 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v1-trap.py +++ b/examples/v3arch/asyncore/agent/ntforg/v1-trap.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/asyncore/agent/ntforg/v2c-inform.py b/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py index 0d46c12e..08993b0e 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py +++ b/examples/v3arch/asyncore/agent/ntforg/v2c-inform.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/asyncore/agent/ntforg/v2c-trap-via-notification-type.py b/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py index 5a9da888..e4ac2e01 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.py +++ b/examples/v3arch/asyncore/agent/ntforg/v2c-trap-via-notification-type.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/asyncore/agent/ntforg/v2c-trap.py b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py index 612074b7..4e3465b2 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py +++ b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.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/asyncore/agent/ntforg/v3-trap.py b/examples/v3arch/asyncore/agent/ntforg/v3-trap.py index d53ac598..bff341a3 100644 --- a/examples/v3arch/asyncore/agent/ntforg/v3-trap.py +++ b/examples/v3arch/asyncore/agent/ntforg/v3-trap.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/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py b/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py index 7a863d6c..0be8da9c 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py +++ b/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.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/asyncore/manager/cmdgen/custom-timeout-and-retries.py b/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py index 15f4abf6..5ea17a41 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py +++ b/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.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/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py b/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py index 33773283..2a9e93a1 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py +++ b/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-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/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py b/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py index 5cdb5981..660dcb2a 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py +++ b/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.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/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py b/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py index 62b4dd96..697c4cd8 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py +++ b/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.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/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py index 967186ef..a5a17b48 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py +++ b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.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/asyncore/manager/cmdgen/observe-request-processing.py b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py index 0916b87c..09c543bc 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py +++ b/examples/v3arch/asyncore/manager/cmdgen/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/asyncore/manager/cmdgen/pull-subtree.py b/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py index 0ecdbad2..0c870a7d 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py +++ b/examples/v3arch/asyncore/manager/cmdgen/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/asyncore/manager/cmdgen/send-packets-from-specific-interface.py b/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py index fb167ba6..dd8e4fdd 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py +++ b/examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.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/asyncore/manager/cmdgen/set-multiple-scalar-values.py b/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py index c64b0fe1..ba94a3b3 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py +++ b/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.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/asyncore/manager/cmdgen/usm-sha-aes128.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py index 95eba5d0..e8989049 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py +++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.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/asyncore/manager/cmdgen/usm-sha-none.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py index 7764d7d3..fd48438d 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py +++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.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/asyncore/manager/cmdgen/v1-get.py b/examples/v3arch/asyncore/manager/cmdgen/v1-get.py index f1fb907b..4fbfb8be 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/v1-get.py +++ b/examples/v3arch/asyncore/manager/cmdgen/v1-get.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/asyncore/manager/cmdgen/v2c-set.py b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py index d004433f..00db8a07 100644 --- a/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py +++ b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.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 ) -- cgit v1.2.1