summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorIlya Etingof <etingof@gmail.com>2016-04-01 22:58:56 +0200
committerIlya Etingof <etingof@gmail.com>2016-04-01 22:58:56 +0200
commit020791a97232849c9504024834906dd4a4ffb36c (patch)
tree6e5d69aa01877ee004efb77645b8148e586610cc /examples
parent9541f201e33cd613995cee2e7a7656aa687deb51 (diff)
downloadpysnmp-git-020791a97232849c9504024834906dd4a4ffb36c.tar.gz
pep8 reformatted
Diffstat (limited to 'examples')
-rw-r--r--examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py2
-rw-r--r--examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py6
-rw-r--r--examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py14
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py4
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py10
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py2
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py8
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py54
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py2
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py2
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py2
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py4
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py8
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py6
-rw-r--r--examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py4
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/multiple-different-notifications-at-once.py20
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py14
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/send-inform-to-multiple-managers.py10
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/send-notification-over-ipv4-and-ipv6.py10
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/send-packet-from-specific-address.py6
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py12
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py14
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/v1-trap.py6
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/v2c-inform.py16
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py4
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/v2c-trap.py14
-rw-r--r--examples/v3arch/asyncore/agent/ntforg/v3-trap.py8
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py13
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py17
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py17
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py20
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-to-eom.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/send-packets-from-specific-interface.py15
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py13
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/v1-get.py11
-rw-r--r--examples/v3arch/asyncore/manager/cmdgen/v2c-set.py11
-rw-r--r--examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py13
-rw-r--r--examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py11
-rw-r--r--examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py13
-rw-r--r--examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py11
-rw-r--r--examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py15
-rw-r--r--examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py15
-rw-r--r--examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py21
-rw-r--r--examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py18
-rw-r--r--examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py16
-rw-r--r--examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py22
-rw-r--r--examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py8
-rw-r--r--examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py2
-rw-r--r--examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py4
-rw-r--r--examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py6
-rw-r--r--examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py11
-rw-r--r--examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py10
59 files changed, 342 insertions, 337 deletions
diff --git a/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py b/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py
index e7f4eca0..25a396c6 100644
--- a/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py
+++ b/examples/v1arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py
@@ -92,7 +92,7 @@ def cbFun(transportDispatcher, transportDomain, transportAddress, wholeMsg):
rspMsg = pMod.apiMessage.getResponse(reqMsg)
rspPDU = pMod.apiMessage.getPDU(rspMsg)
reqPDU = pMod.apiMessage.getPDU(reqMsg)
- varBinds = [];
+ varBinds = []
pendingErrors = []
errorIndex = 0
# GETNEXT PDU
diff --git a/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py b/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py
index b0b7e5bd..e3ee3aa4 100644
--- a/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py
+++ b/examples/v3arch/asyncio/agent/cmdrsp/multiple-usm-users.py
@@ -65,9 +65,9 @@ config.addV3User(
)
# Allow full MIB access for each user at VACM
-config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
-config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
-config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
+config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
+config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py b/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py
index 429b117d..1b434702 100644
--- a/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py
+++ b/examples/v3arch/asyncio/manager/ntfrcv/multiple-interfaces.py
@@ -19,7 +19,7 @@ receiver:
Requires Python 3.4 and later!
-"""#
+""" #
from pysnmp.entity import engine, config
from pysnmp.carrier.asyncio.dgram import udp
from pysnmp.entity.rfc3413 import ntfrcv
@@ -53,6 +53,7 @@ config.addTransport(
# SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public')
+
# Callback function for receiving notifications
# noinspection PyUnusedLocal
def cbFun(snmpEngine,
@@ -61,14 +62,13 @@ def cbFun(snmpEngine,
varBinds,
cbCtx):
transportDomain, transportAddress = snmpEngine.msgAndPduDsp.getTransportInfo(stateReference)
- print('Notification from %s, SNMP Engine %s, Context %s' % (
- transportAddress, contextEngineId.prettyPrint(),
- contextName.prettyPrint()
- )
- )
+ print('Notification from %s, SNMP Engine %s, Context %s' % (transportAddress,
+ contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
-
+
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py b/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py
index fa3bc6b5..5903b54c 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/alternative-mib-tree.py
@@ -45,7 +45,7 @@ config.addV3User(
)
# Allow full MIB access for each user at VACM
-config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Create an SNMP context with ContextEngineId = 8000000001020304
snmpContext = context.SnmpContext(
@@ -56,7 +56,7 @@ snmpContext = context.SnmpContext(
# Management Instrumentation Controller and register at SNMP Context
# under ContextName 'my-context'
snmpContext.registerContextName(
- v2c.OctetString('my-context'), # Context Name
+ v2c.OctetString('my-context'), # Context Name
instrum.MibInstrumController(builder.MibBuilder()) # Managed Objects
)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py b/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py
index 1711133d..54aec899 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/custom-mib-controller.py
@@ -43,23 +43,25 @@ config.addV3User(
)
# Allow full MIB access for each user at VACM
-config.addVacmUser(snmpEngine, 3, 'usr-none-none', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 3, 'usr-none-none', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Create an SNMP context
snmpContext = context.SnmpContext(snmpEngine)
+
# Very basic Management Instrumentation Controller without
# any Managed Objects attached. It supports only GET's and
# always echos request var-binds in response.
class EchoMibInstrumController(instrum.AbstractMibInstrumController):
def readVars(self, vars, acInfo=(None, None)):
- return [ (ov[0], v2c.OctetString('You queried OID %s' % ov[0])) for ov in vars]
+ return [(ov[0], v2c.OctetString('You queried OID %s' % ov[0])) for ov in vars]
+
# Create a custom Management Instrumentation Controller and register at
# SNMP Context under ContextName 'my-context'
snmpContext.registerContextName(
- v2c.OctetString('my-context'), # Context Name
- EchoMibInstrumController() # Management Instrumentation
+ v2c.OctetString('my-context'), # Context Name
+ EchoMibInstrumController() # Management Instrumentation
)
# Register GET&SET Applications at the SNMP engine for a custom SNMP context
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py b/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py
index e2452ca3..5e9a535a 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/custom-snmp-engine-id.py
@@ -43,7 +43,7 @@ config.addV3User(
)
# Allow full MIB access for each user at VACM
-config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py b/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py
index 24d76d35..878f97a9 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/implementing-scalar-mib-objects.py
@@ -40,7 +40,7 @@ config.addTransport(
config.addV1System(snmpEngine, 'my-area', 'public')
# Allow read MIB access for this user / securityModels at VACM
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,5))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 5))
# Create an SNMP context
snmpContext = context.SnmpContext(snmpEngine)
@@ -53,6 +53,7 @@ MibScalar, MibScalarInstance = mibBuilder.importSymbols(
'SNMPv2-SMI', 'MibScalar', 'MibScalarInstance'
)
+
class MyStaticMibScalarInstance(MibScalarInstance):
# noinspection PyUnusedLocal,PyUnusedLocal
def getValue(self, name, idx):
@@ -60,9 +61,10 @@ class MyStaticMibScalarInstance(MibScalarInstance):
'Python %s running on a %s platform' % (sys.version, sys.platform)
)
+
mibBuilder.exportSymbols(
- '__MY_MIB', MibScalar((1,3,6,5,1), v2c.OctetString()),
- MyStaticMibScalarInstance((1,3,6,5,1), (0,), v2c.OctetString())
+ '__MY_MIB', MibScalar((1, 3, 6, 5, 1), v2c.OctetString()),
+ MyStaticMibScalarInstance((1, 3, 6, 5, 1), (0,), v2c.OctetString())
)
# --- end of Managed Object Instance initialization ----
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py b/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py
index 7c2a102d..0e15599a 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/implementing-snmp-table.py
@@ -47,7 +47,7 @@ config.addTransport(
config.addV1System(snmpEngine, 'my-area', 'public')
# Allow read MIB access for this user / securityModels at VACM
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,6), (1,3,6,6))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 6), (1, 3, 6, 6))
# Create an SNMP context
snmpContext = context.SnmpContext(snmpEngine)
@@ -56,43 +56,43 @@ snmpContext = context.SnmpContext(snmpEngine)
mibBuilder = snmpContext.getMibInstrum().getMibBuilder()
-( MibTable,
- MibTableRow,
- MibTableColumn,
- MibScalarInstance ) = mibBuilder.importSymbols(
- 'SNMPv2-SMI',
+(MibTable,
+ MibTableRow,
+ MibTableColumn,
+ MibScalarInstance) = mibBuilder.importSymbols(
+ 'SNMPv2-SMI',
'MibTable',
'MibTableRow',
'MibTableColumn',
'MibScalarInstance'
- )
+)
RowStatus, = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus')
mibBuilder.exportSymbols(
- '__EXAMPLE-MIB',
- # table object
- exampleTable=MibTable((1,3,6,6,1)).setMaxAccess('readcreate'),
- # table row object, also carries references to table indices
- exampleTableEntry=MibTableRow((1,3,6,6,1,5)).setMaxAccess('readcreate').setIndexNames((0, '__EXAMPLE-MIB', 'exampleTableColumn1')),
- # table column: string index
- exampleTableColumn1=MibTableColumn((1,3,6,6,1,5,1), v2c.OctetString()).setMaxAccess('readcreate'),
- # table column: string value
- exampleTableColumn2=MibTableColumn((1,3,6,6,1,5,2), v2c.OctetString()).setMaxAccess('readcreate'),
- # table column: integer value with default
- exampleTableColumn3=MibTableColumn((1,3,6,6,1,5,3), v2c.Integer32(123)).setMaxAccess('readcreate'),
- # table column: row status
- exampleTableStatus=MibTableColumn((1,3,6,6,1,5,4), RowStatus('notExists')).setMaxAccess('readcreate')
+ '__EXAMPLE-MIB',
+ # table object
+ exampleTable=MibTable((1, 3, 6, 6, 1)).setMaxAccess('readcreate'),
+ # table row object, also carries references to table indices
+ exampleTableEntry=MibTableRow((1, 3, 6, 6, 1, 5)).setMaxAccess('readcreate').setIndexNames((0, '__EXAMPLE-MIB', 'exampleTableColumn1')),
+ # table column: string index
+ exampleTableColumn1=MibTableColumn((1, 3, 6, 6, 1, 5, 1), v2c.OctetString()).setMaxAccess('readcreate'),
+ # table column: string value
+ exampleTableColumn2=MibTableColumn((1, 3, 6, 6, 1, 5, 2), v2c.OctetString()).setMaxAccess('readcreate'),
+ # table column: integer value with default
+ exampleTableColumn3=MibTableColumn((1, 3, 6, 6, 1, 5, 3), v2c.Integer32(123)).setMaxAccess('readcreate'),
+ # table column: row status
+ exampleTableStatus=MibTableColumn((1, 3, 6, 6, 1, 5, 4), RowStatus('notExists')).setMaxAccess('readcreate')
)
# --- end of custom SNMP table definition, empty table now exists ---
# --- populate custom SNMP table with one row ---
-( exampleTableEntry,
- exampleTableColumn2,
- exampleTableColumn3,
- exampleTableStatus ) = mibBuilder.importSymbols(
+(exampleTableEntry,
+ exampleTableColumn2,
+ exampleTableColumn3,
+ exampleTableStatus) = mibBuilder.importSymbols(
'__EXAMPLE-MIB',
'exampleTableEntry',
'exampleTableColumn2',
@@ -102,9 +102,9 @@ mibBuilder.exportSymbols(
rowInstanceId = exampleTableEntry.getInstIdFromIndices('example record one')
mibInstrumentation = snmpContext.getMibInstrum()
mibInstrumentation.writeVars(
- ( (exampleTableColumn2.name+rowInstanceId, 'my string value'),
- (exampleTableColumn3.name+rowInstanceId, 123456),
- (exampleTableStatus.name+rowInstanceId, 'createAndGo') )
+ ((exampleTableColumn2.name + rowInstanceId, 'my string value'),
+ (exampleTableColumn3.name + rowInstanceId, 123456),
+ (exampleTableStatus.name + rowInstanceId, 'createAndGo'))
)
# --- end of SNMP table population ---
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py b/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py
index 24de0618..ef5c6239 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/listen-on-ipv4-and-ipv6-interfaces.py
@@ -46,7 +46,7 @@ config.addTransport(
config.addV1System(snmpEngine, 'my-area', 'public')
# Allow full MIB access for this user / securityModels at VACM
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py b/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py
index 25beef3f..7a7eadbc 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/listen-on-multiple-interfaces.py
@@ -45,7 +45,7 @@ config.addTransport(
config.addV1System(snmpEngine, 'my-area', 'public')
# Allow full MIB access for this user / securityModels at VACM
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py b/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py
index 1e862706..dd270b6e 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/listening-on-virtual-network-interface.py
@@ -68,7 +68,7 @@ config.addV3User(
)
# Allow full MIB access for each user at VACM
-config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py b/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py
index 5780025f..005069ad 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-communities.py
@@ -43,8 +43,8 @@ config.addV1System(snmpEngine, 'my-read-area', 'public')
config.addV1System(snmpEngine, 'my-write-area', 'private')
# Allow full MIB access for this user / securityModels at VACM
-config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1,3,6,1,2,1))
-config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1))
+config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py b/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py
index 0a7b3a20..6e818247 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/multiple-snmp-engines.py
@@ -33,15 +33,15 @@ from pysnmp.carrier.asyncore.dgram import udp
# Configuration parameters for each of SNMP Engines
snmpEngineInfo = (
- ( '0102030405060708', udp.domainName + (0,), ('127.0.0.1', 161) ),
- ( '0807060504030201', udp.domainName + (1,), ('127.0.0.2', 161) )
+ ('0102030405060708', udp.domainName + (0,), ('127.0.0.1', 161)),
+ ('0807060504030201', udp.domainName + (1,), ('127.0.0.2', 161))
)
# Instantiate the single transport dispatcher object
transportDispatcher = AsyncoreDispatcher()
# Setup a custom data routing function to select snmpEngine by transportDomain
-transportDispatcher.registerRoutingCbFun(lambda td,t,d: td)
+transportDispatcher.registerRoutingCbFun(lambda td, t, d: td)
# Instantiate and configure SNMP Engines
for snmpEngineId, transportDomain, transportAddress in snmpEngineInfo:
@@ -71,7 +71,7 @@ for snmpEngineId, transportDomain, transportAddress in snmpEngineInfo:
)
# Allow full MIB access for this user / securityModels at VACM
- config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6), (1,3,6,1,2,1))
+ config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py b/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py
index 150a0f48..3b1119dd 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/multiple-usm-users.py
@@ -56,9 +56,9 @@ config.addV3User(
)
# Allow full MIB access for each user at VACM
-config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
-config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
-config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
+config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
+config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py b/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py
index 06b5b563..bffedd40 100644
--- a/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py
+++ b/examples/v3arch/asyncore/agent/cmdrsp/observe-request-processing.py
@@ -27,6 +27,7 @@ from pysnmp.carrier.asyncore.dgram import udp
# Create SNMP engine
snmpEngine = engine.SnmpEngine()
+
# Execution point observer setup
# Register a callback to be invoked at specified execution point of
@@ -43,6 +44,7 @@ def requestObserver(snmpEngine, execpoint, variables, cbCtx):
print('* contextName: %s' % variables['contextName'].prettyPrint())
print('* PDU: %s' % variables['pdu'].prettyPrint())
+
snmpEngine.observer.registerObserver(
requestObserver,
'rfc3412.receiveMessage:request',
@@ -68,7 +70,7 @@ config.addV3User(
)
# Allow full MIB access for each user at VACM
-config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
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 e316e674..45e485ff 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
@@ -79,34 +79,34 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (2&3), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
-config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6))
+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()
+
# Error/confirmation receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
errorStatus, errorIndex, varBinds, cbCtx):
- print('Notification %s, status - %s' % (
- sendRequestHandle, errorIndication and errorIndication or 'delivered'
- )
- )
-
+ print('Notification %s, status - %s' % (sendRequestHandle,
+ errorIndication and errorIndication or 'delivered'))
+
+
# Build and submit notification message to dispatcher
sendRequestHandle = ntfOrg.sendVarBinds(
snmpEngine,
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
[
# SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
- ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))),
# 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, 1, 0), v2c.OctetString('Example Notificator'))
],
cbFun
)
diff --git a/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py b/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py
index 5df87e80..4f7496ab 100644
--- a/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py
+++ b/examples/v3arch/asyncore/agent/ntforg/send-custom-pdu.py
@@ -50,37 +50,39 @@ config.addTargetAddr(
# *** SNMP engine configuration is complete by this line ***
# Create SNMP v2c TRAP PDU with defaults
-trapPDU = v2c.TrapPDU()
+trapPDU = v2c.TrapPDU()
v2c.apiTrapPDU.setDefaults(trapPDU)
# Set custom var-binds to TRAP PDU
v2c.apiTrapPDU.setVarBinds(
trapPDU, [
# sysUpTime
- ( v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'), v2c.TimeTicks(123) ),
+ (v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'), v2c.TimeTicks(123)),
# snmpTrapPDU
- ( (1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1)) )
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1)))
]
)
# Create Notification Originator App instance.
ntfOrg = ntforg.NotificationOriginator()
+
# Error/confirmation receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
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.sendPdu(
snmpEngine,
# Notification targets
- 'my-nms', # target address
- None, '', # contextEngineId, contextName
+ 'my-nms', # target address
+ None, '', # contextEngineId, contextName
trapPDU,
cbFun
)
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 77686670..de0b78ee 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
@@ -75,7 +75,7 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6))
# *** SNMP engine configuration is complete by this line ***
@@ -87,14 +87,14 @@ ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
[
# SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
- ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))),
# 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'))
+ ((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'))
]
)
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 467d0132..19798277 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
@@ -74,7 +74,7 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6))
# *** SNMP engine configuration is complete by this line ***
@@ -86,14 +86,14 @@ ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
[
# SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
- ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))),
# 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'))
+ ((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'))
]
)
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 2577aaed..68ce95c5 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
@@ -57,7 +57,7 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (1), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6))
# *** SNMP engine configuration is complete by this line ***
@@ -68,11 +68,11 @@ ntfOrg = ntforg.NotificationOriginator()
ntfOrg.sendVarBinds(
snmpEngine,
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
[
# SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
- ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1)))
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1)))
]
)
diff --git a/examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py b/examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py
index bf2e39d9..83ef3b8b 100644
--- a/examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py
+++ b/examples/v3arch/asyncore/agent/ntforg/send-trap-to-multiple-managers.py
@@ -74,26 +74,26 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+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()
-
+
# Build and submit notification message to dispatcher
ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
[
# SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
- ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))),
# 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'))
+ ((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'))
]
)
diff --git a/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py b/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py
index 904aafe0..408e6f67 100644
--- a/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py
+++ b/examples/v3arch/asyncore/agent/ntforg/usm-md5-none.py
@@ -56,30 +56,32 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (3), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 3, 'usr-md5-none', 'authNoPriv', (), (), (1,3,6))
+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()
-
+
+
# Error/confirmation receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
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.sendVarBinds(
snmpEngine,
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds: SNMPv2-MIB::coldStart, ...
- [ ((1,3,6,1,6,3,1,1,5,1), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
- ((1,3,6,1,2,1,1,5,0), v2c.OctetString('system name')) ],
+ [((1, 3, 6, 1, 6, 3, 1, 1, 5, 1), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))),
+ ((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 46f072bf..ee40319d 100644
--- a/examples/v3arch/asyncore/agent/ntforg/v1-trap.py
+++ b/examples/v3arch/asyncore/agent/ntforg/v1-trap.py
@@ -59,7 +59,7 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (1), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+config.addVacmUser(snmpEngine, 1, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6))
# *** SNMP engine configuration is complete by this line ***
@@ -71,9 +71,9 @@ ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
- [
+ [
# Uptime value with 12345
(v2c.ObjectIdentifier('1.3.6.1.2.1.1.3.0'),
v2c.TimeTicks(12345)),
diff --git a/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py b/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py
index 8c3c90b4..1de1a2fb 100644
--- a/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py
+++ b/examples/v3arch/asyncore/agent/ntforg/v2c-inform.py
@@ -28,7 +28,7 @@ from pysnmp.proto.api import v2c
snmpEngine = engine.SnmpEngine()
# SecurityName <-> CommunityName mapping (+ transport binding)
-config.addV1System(snmpEngine, 'my-area', 'public',
+config.addV1System(snmpEngine, 'my-area', 'public',
transportTag='all-my-managers')
# Specify security settings per SecurityName (SNMPv2c -> 1)
@@ -58,34 +58,36 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+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()
+
# Error/confirmation receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
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.sendVarBinds(
snmpEngine,
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
[
# SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
- ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))),
# 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'))
+ ((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-with-notification-objects.py b/examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py
index 4d8f1756..c86af227 100644
--- a/examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py
+++ b/examples/v3arch/asyncore/agent/ntforg/v2c-trap-with-notification-objects.py
@@ -83,7 +83,7 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1, 3, 6))
# *** SNMP engine configuration is complete by this line ***
@@ -94,7 +94,7 @@ ntfOrg = ntforg.NotificationOriginator()
ntfOrg.sendVarBinds(
snmpEngine,
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
rfc1902.NotificationType(
rfc1902.ObjectIdentity('IF-MIB', 'linkUp'),
instanceIndex=instanceIndex,
diff --git a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py
index b2ecfa9b..d4c5f533 100644
--- a/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py
+++ b/examples/v3arch/asyncore/agent/ntforg/v2c-trap.py
@@ -57,35 +57,37 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (2), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (), (), (1,3,6))
+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()
+
# Error/confirmation receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
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.sendVarBinds(
snmpEngine,
# Notification targets
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
[
# SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
- ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))),
# 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'))
+ ((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/v3-trap.py b/examples/v3arch/asyncore/agent/ntforg/v3-trap.py
index b7dd29bb..e84b2b9f 100644
--- a/examples/v3arch/asyncore/agent/ntforg/v3-trap.py
+++ b/examples/v3arch/asyncore/agent/ntforg/v3-trap.py
@@ -61,7 +61,7 @@ config.addNotificationTarget(
# Allow NOTIFY access to Agent's MIB by this SNMP model (3), securityLevel
# and SecurityName
config.addContext(snmpEngine, '')
-config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1,3,6))
+config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (), (), (1, 3, 6))
# *** SNMP engine configuration is complete by this line ***
@@ -73,13 +73,13 @@ ntfOrg.sendVarBinds(
snmpEngine,
# Notification targets
'my-notification', # notification targets
- None, '', # contextEngineId, contextName
+ None, '', # contextEngineId, contextName
# var-binds
[
# SNMPv2-SMI::snmpTrapOID.0 = SNMPv2-MIB::coldStart
- ((1,3,6,1,6,3,1,1,4,1,0), v2c.ObjectIdentifier((1,3,6,1,6,3,1,1,5,1))),
+ ((1, 3, 6, 1, 6, 3, 1, 1, 4, 1, 0), v2c.ObjectIdentifier((1, 3, 6, 1, 6, 3, 1, 1, 5, 1))),
# additional var-binds: ( (oid, value), ... )
- ((1,3,6,1,2,1,1,5,0), v2c.OctetString('Notificator Example'))
+ ((1, 3, 6, 1, 2, 1, 1, 5, 0), v2c.OctetString('Notificator Example'))
]
)
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 eb1900c2..1f3fdaf2 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/custom-contextengineid-and-contextname.py
@@ -53,6 +53,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -60,15 +61,13 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
if errorIndication:
print(errorIndication)
elif errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message, pass custom ContextEngineId & ContextName
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
@@ -77,7 +76,7 @@ cmdgen.GetCommandGenerator().sendVarBinds(
rfc1902.OctetString(hexValue='80004fb805636c6f75644dab22cc'),
# contextName
rfc1902.OctetString('da761cfc8c94d3aceef4f60f049105ba'),
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)],
cbFun
)
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 1e49ffef..c30ff4c1 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/custom-timeout-and-retries.py
@@ -51,6 +51,7 @@ config.addTargetAddr(
retryCount=5
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -58,21 +59,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
if errorIndication:
print(errorIndication)
elif errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
- None, '', # contextEngineId, contextName
- [ ((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 916537da..45460c92 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/fetch-variables-over-ipv6.py
@@ -50,6 +50,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -58,24 +59,22 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
print(errorIndication)
return
if errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?'))
return # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return True # signal dispatcher to continue
+ return True # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((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/getbulk-fetch-scalar-and-table-variables.py b/examples/v3arch/asyncore/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py
index 516951f8..8c4bf3dd 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
@@ -52,6 +52,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequesthandle, errorIndication,
@@ -60,25 +61,23 @@ def cbFun(snmpEngine, sendRequesthandle, errorIndication,
print(errorIndication)
return # stop on error
if errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?'))
return # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return True # signal dispatcher to continue walking
+ return True # signal dispatcher to continue walking
+
# Prepare initial request to be sent
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) ),
+ 0, 25, # non-repeaters, max-repetitions
+ (((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-multiple-oids-to-eom.py b/examples/v3arch/asyncore/manager/cmdgen/getbulk-multiple-oids-to-eom.py
index 2cd37cda..29c480c1 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
@@ -49,6 +49,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequesthandle, errorIndication,
@@ -57,25 +58,23 @@ def cbFun(snmpEngine, sendRequesthandle, errorIndication,
print(errorIndication)
return # stop on error
if errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?'))
return # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return True # signal dispatcher to continue walking
+ return True # signal dispatcher to continue walking
+
# Prepare initial request to be sent
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) ],
+ 0, 25, # non-repeaters, max-repetitions
+ [((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-and-resolve-with-mib.py b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py
index f4667bef..9caf6a89 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py
@@ -27,7 +27,7 @@ snmpEngine = engine.SnmpEngine()
# This call will fail if PySMI is not present on the system
compiler.addMibCompiler(snmpEngine.getMibBuilder())
# ... alternatively, this call will not complain on missing PySMI
-#compiler.addMibCompiler(snmpEngine.getMibBuilder(), ifAvailable=True)
+# compiler.addMibCompiler(snmpEngine.getMibBuilder(), ifAvailable=True)
# Used for MIB objects resolution
mibViewController = view.MibViewController(snmpEngine.getMibBuilder())
@@ -60,6 +60,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -70,24 +71,23 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
if errorStatus and errorStatus != 2:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?'))
return # stop on error
for varBindRow in varBindTable:
for varBind in varBindRow:
- print(rfc1902.ObjectType(rfc1902.ObjectIdentity(varBind[0]), varBind[1]).resolveWithMib(mibViewController).prettyPrint())
- return 1 # signal dispatcher to continue
+ print(rfc1902.ObjectType(rfc1902.ObjectIdentity(varBind[0]),
+ varBind[1]).resolveWithMib(mibViewController).prettyPrint())
+ return 1 # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ rfc1902.ObjectType(rfc1902.ObjectIdentity('iso.org.dod')).resolveWithMib(mibViewController),
- rfc1902.ObjectType(rfc1902.ObjectIdentity('IF-MIB', 'ifMIB')).resolveWithMib(mibViewController) ],
+ [rfc1902.ObjectType(rfc1902.ObjectIdentity('iso.org.dod')).resolveWithMib(mibViewController),
+ rfc1902.ObjectType(rfc1902.ObjectIdentity('IF-MIB', 'ifMIB')).resolveWithMib(mibViewController)],
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 f2bcc43e..d90c35bb 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
@@ -49,6 +49,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -59,24 +60,22 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
if errorStatus and errorStatus != 2:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?'))
return # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return 1 # signal dispatcher to continue
+ return 1 # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((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/observe-request-processing.py b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py
index 86187923..6034624c 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/observe-request-processing.py
@@ -25,6 +25,7 @@ from pysnmp.entity.rfc3413 import cmdgen
# Create SNMP engine instance
snmpEngine = engine.SnmpEngine()
+
# Execution point observer setup
# Register a callback to be invoked at specified execution point of
@@ -41,8 +42,9 @@ def requestObserver(snmpEngine, execpoint, variables, cbCtx):
print('* contextName: %s' % variables['contextName'].prettyPrint())
print('* PDU: %s' % variables['pdu'].prettyPrint())
+
snmpEngine.observer.registerObserver(
- requestObserver,
+ requestObserver,
'rfc3412.sendPdu',
'rfc3412.receiveMessage:response'
)
@@ -76,6 +78,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -83,21 +86,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
if errorIndication:
print(errorIndication)
elif errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((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 36e461fb..cbaa1d0b 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/pull-subtree.py
@@ -52,6 +52,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -60,26 +61,24 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
print(errorIndication)
return
if errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?'))
return # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
if initialOID.isPrefixOf(oid):
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
else:
- return False # signal dispatcher to stop
- return True # signal dispatcher to continue
+ return False # signal dispatcher to stop
+ return True # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ (initialOID, None) ],
+ [(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 27acf769..2d6805fa 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
@@ -50,6 +50,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -58,24 +59,22 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
print(errorIndication)
return
if errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBindTable[-1][int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBindTable[-1][int(errorIndex) - 1][0] or '?'))
return # stop on error
for varBindRow in varBindTable:
for oid, val in varBindRow:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
- return 1 # signal dispatcher to continue
+ return 1 # signal dispatcher to continue
+
# Prepare initial request to be sent
cmdgen.NextCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1), None),
- ((1,3,6,1,2,1,11), None) ],
+ [((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 28095a76..25a33fd0 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/set-multiple-scalar-values.py
@@ -49,6 +49,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -58,22 +59,20 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
elif errorStatus and errorStatus != 2:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.SetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
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)) ],
+ [((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/spoof-source-address.py b/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py
index 953f80e6..229ffdab 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/spoof-source-address.py
@@ -70,6 +70,7 @@ config.addTargetAddr(
sourceAddress=('1.2.3.4', 0)
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -79,21 +80,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
elif errorStatus and errorStatus != 2:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((1, 3, 6, 1, 2, 1, 1, 1, 0), None)],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py
index 58154ba1..49b20831 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-aes128.py
@@ -49,6 +49,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -56,21 +57,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
if errorIndication:
print(errorIndication)
elif errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((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 45692e4c..807822bf 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/usm-sha-none.py
@@ -50,6 +50,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -57,21 +58,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
if errorIndication:
print(errorIndication)
elif errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.SetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,9,1,3,1), rfc1902.OctetString('my new value')) ],
+ [((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 9e9019cd..88078331 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/v1-get.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/v1-get.py
@@ -46,6 +46,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -55,21 +56,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
# SNMPv1 response may contain noSuchName error *and* SNMPv2c exception,
# so we ignore noSuchName error here
elif errorStatus and errorStatus != 2:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.GetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,1,0), None) ],
+ [((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 7936f174..8a084b20 100644
--- a/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py
+++ b/examples/v3arch/asyncore/manager/cmdgen/v2c-set.py
@@ -48,6 +48,7 @@ config.addTargetAddr(
'my-creds'
)
+
# Error/response receiver
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, sendRequestHandle, errorIndication,
@@ -55,21 +56,19 @@ def cbFun(snmpEngine, sendRequestHandle, errorIndication,
if errorIndication:
print(errorIndication)
elif errorStatus:
- print('%s at %s' % (
- errorStatus.prettyPrint(),
- errorIndex and varBinds[int(errorIndex)-1][0] or '?'
- )
- )
+ print('%s at %s' % (errorStatus.prettyPrint(),
+ errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for oid, val in varBinds:
print('%s = %s' % (oid.prettyPrint(), val.prettyPrint()))
+
# Prepare and send a request message
cmdgen.SetCommandGenerator().sendVarBinds(
snmpEngine,
'my-router',
None, '', # contextEngineId, contextName
- [ ((1,3,6,1,2,1,1,9,1,4,1), rfc1902.TimeTicks(123)) ],
+ [((1, 3, 6, 1, 2, 1, 1, 9, 1, 4, 1), rfc1902.TimeTicks(123))],
cbFun
)
diff --git a/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py b/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py
index 87880e41..d7d9b6d3 100644
--- a/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py
+++ b/examples/v3arch/asyncore/manager/ntfrcv/determine-peer-network-address.py
@@ -38,6 +38,7 @@ config.addTransport(
# SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public')
+
# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
@@ -48,19 +49,17 @@ def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
)
# ... and use inner SNMP engine data to figure out peer address
- print('Notification from %s, ContextEngineId "%s", ContextName "%s"' % (
- '@'.join([str(x) for x in execContext['transportAddress']]),
- contextEngineId.prettyPrint(),
- contextName.prettyPrint()
- )
- )
+ print('Notification from %s, ContextEngineId "%s", ContextName "%s"' % ('@'.join([str(x) for x in execContext['transportAddress']]),
+ contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send confirmations
try:
diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py
index 63c86926..30b41706 100644
--- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py
+++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-interfaces.py
@@ -46,22 +46,21 @@ config.addTransport(
# SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public')
+
# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
varBinds, cbCtx):
- print('Notification from ContextEngineId "%s", ContextName "%s"' % (
- contextEngineId.prettyPrint(),
- contextName.prettyPrint()
- )
- )
+ print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send confirmations
try:
diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py
index c0e2eeae..994c73dd 100644
--- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py
+++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-network-transports.py
@@ -40,29 +40,28 @@ config.addTransport(
snmpEngine,
udp6.domainName,
udp6.Udp6Transport().openServerMode(('::1', 162))
- )
+)
# SNMPv1/2c setup
# SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public')
+
# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
varBinds, cbCtx):
- print('Notification from ContextEngineId "%s", ContextName "%s"' % (
- contextEngineId.prettyPrint(),
- contextName.prettyPrint()
- )
- )
+ print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send confirmations
try:
diff --git a/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py b/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py
index 1a0ae8bd..50aaee26 100644
--- a/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py
+++ b/examples/v3arch/asyncore/manager/ntfrcv/multiple-usm-users.py
@@ -87,22 +87,21 @@ config.addV3User(
securityEngineId=v2c.OctetString(hexValue='8000000001020304')
)
+
# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
varBinds, cbCtx):
- print('Notification from ContextEngineId "%s", ContextName "%s"' % (
- contextEngineId.prettyPrint(),
- contextName.prettyPrint()
- )
- )
+ print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send confirmations
try:
diff --git a/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py b/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py
index 6dd9b305..9f3a2c40 100644
--- a/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py
+++ b/examples/v3arch/asyncore/manager/ntfrcv/observe-request-processing.py
@@ -27,6 +27,7 @@ from pysnmp.entity.rfc3413 import ntfrcv
# to socket transport dispatcher
snmpEngine = engine.SnmpEngine()
+
# Execution point observer setup
# Register a callback to be invoked at specified execution point of
@@ -43,6 +44,7 @@ def requestObserver(snmpEngine, execpoint, variables, cbCtx):
print('* contextName: %s' % variables['contextName'].prettyPrint())
print('* PDU: %s' % variables['pdu'].prettyPrint())
+
snmpEngine.observer.registerObserver(
requestObserver,
'rfc3412.receiveMessage:request',
@@ -63,29 +65,28 @@ config.addTransport(
snmpEngine,
udp6.domainName,
udp6.Udp6Transport().openServerMode(('::1', 162))
- )
+)
# SNMPv1/2c setup
# SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public')
+
# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
varBinds, cbCtx):
- print('Notification from ContextEngineId "%s", ContextName "%s"' % (
- contextEngineId.prettyPrint(),
- contextName.prettyPrint()
- )
- )
+ print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send confirmations
try:
diff --git a/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py b/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py
index 0e808ec9..769aa2f5 100644
--- a/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py
+++ b/examples/v3arch/asyncore/manager/ntfrcv/regexp-community-name.py
@@ -35,7 +35,8 @@ import re
# to socket transport dispatcher
snmpEngine = engine.SnmpEngine()
-# Register a callback to be invoked at specified execution point of
+
+# Register a callback to be invoked at specified execution point of
# SNMP Engine and passed local variables at execution point's local scope.
# If at this execution point passed variables are modified, their new
# values will be propagated back and used by SNMP Engine for securityName
@@ -46,6 +47,7 @@ def requestObserver(snmpEngine, execpoint, variables, cbCtx):
print('Rewriting communityName \'%s\' from %s into \'public\'' % (variables['communityName'], ':'.join([str(x) for x in variables['transportInformation'][1]])))
variables['communityName'] = variables['communityName'].clone('public')
+
snmpEngine.observer.registerObserver(
requestObserver,
'rfc2576.processIncomingMsg:writable'
@@ -65,22 +67,21 @@ config.addTransport(
# SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public')
+
# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
varBinds, cbCtx):
- print('Notification from ContextEngineId "%s", ContextName "%s"' % (
- contextEngineId.prettyPrint(),
- contextName.prettyPrint()
- )
- )
+ print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send confirmations
try:
diff --git a/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py b/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py
index d06261a3..475435ee 100644
--- a/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py
+++ b/examples/v3arch/asyncore/proxy/command/udp6-to-udp4-conversion.py
@@ -70,8 +70,7 @@ config.addV1System(snmpEngine, '1-my-area', 'public')
# to let it match first in snmpCommunityTable on response processing.
#
-config.addV1System(snmpEngine, '0-distant-area', 'public',
- transportTag='remote')
+config.addV1System(snmpEngine, '0-distant-area', 'public', transportTag='remote')
#
# Transport target used by Manager
@@ -81,20 +80,21 @@ config.addTargetParams(
snmpEngine, 'distant-agent-auth', '0-distant-area', 'noAuthNoPriv', 1
)
config.addTargetAddr(
- snmpEngine, 'distant-agent',
- udp.domainName, ('195.218.195.228', 161),
- 'distant-agent-auth', retryCount=0, tagList='remote'
+ snmpEngine, 'distant-agent',
+ udp.domainName, ('195.218.195.228', 161),
+ 'distant-agent-auth', retryCount=0, tagList='remote'
)
# Default SNMP context
config.addContext(snmpEngine, '')
+
class CommandResponder(cmdrsp.CommandResponderBase):
- cmdGenMap = {
+ cmdGenMap = {
v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(),
v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(),
v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(),
- v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
+ v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
}
pduTypes = cmdGenMap.keys() # This app will handle these PDUs
@@ -105,14 +105,14 @@ class CommandResponder(cmdrsp.CommandResponderBase):
contextEngineId = None # address authoritative SNMP Engine
try:
self.cmdGenMap[PDU.tagSet].sendPdu(
- snmpEngine, 'distant-agent',
+ snmpEngine, 'distant-agent',
contextEngineId, contextName,
PDU,
self.handleResponsePdu, cbCtx
)
except error.PySnmpError:
self.handleResponsePdu(
- stateReference, 'error', None, cbCtx
+ snmpEngine, stateReference, 'error', None, cbCtx
)
# SNMP response relay
@@ -131,9 +131,10 @@ class CommandResponder(cmdrsp.CommandResponderBase):
self.releaseStateInformation(stateReference)
+
CommandResponder(snmpEngine, context.SnmpContext(snmpEngine))
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send responses
try:
diff --git a/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py b/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py
index c8dc63eb..71e2347e 100644
--- a/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py
+++ b/examples/v3arch/asyncore/proxy/command/v2c-to-v1-conversion.py
@@ -79,20 +79,21 @@ config.addTargetParams(snmpEngine, 'distant-agent-auth', 'distant-area',
'noAuthNoPriv', 0)
config.addTargetAddr(
- snmpEngine, 'distant-agent',
- udp.domainName + (2,), ('195.218.195.228', 161),
- 'distant-agent-auth', retryCount=0, tagList='distant'
+ snmpEngine, 'distant-agent',
+ udp.domainName + (2,), ('195.218.195.228', 161),
+ 'distant-agent-auth', retryCount=0, tagList='distant'
)
# Default SNMP context
config.addContext(snmpEngine, '')
+
class CommandResponder(cmdrsp.CommandResponderBase):
- cmdGenMap = {
+ cmdGenMap = {
v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(),
v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(),
v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(),
- v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
+ v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
}
pduTypes = cmdGenMap.keys() # This app will handle these PDUs
@@ -103,14 +104,14 @@ class CommandResponder(cmdrsp.CommandResponderBase):
contextEngineId = None # address authoritative SNMP Engine
try:
self.cmdGenMap[PDU.tagSet].sendPdu(
- snmpEngine, 'distant-agent',
+ snmpEngine, 'distant-agent',
contextEngineId, contextName,
PDU,
self.handleResponsePdu, cbCtx
)
except error.PySnmpError:
self.handleResponsePdu(
- stateReference, 'error', None, cbCtx
+ snmpEngine, stateReference, 'error', None, cbCtx
)
# SNMP response relay
@@ -129,9 +130,10 @@ class CommandResponder(cmdrsp.CommandResponderBase):
self.releaseStateInformation(stateReference)
+
CommandResponder(snmpEngine, context.SnmpContext(snmpEngine))
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send responses
try:
diff --git a/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py b/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py
index e232e19e..e49d604b 100644
--- a/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py
+++ b/examples/v3arch/asyncore/proxy/command/v2c-to-v3-conversion.py
@@ -79,20 +79,21 @@ config.addTargetParams(
snmpEngine, 'distant-agent-auth', 'usr-md5-none', 'authNoPriv'
)
config.addTargetAddr(
- snmpEngine, 'distant-agent',
- udp.domainName + (2,), ('195.218.195.228', 161),
- 'distant-agent-auth', retryCount=0
+ snmpEngine, 'distant-agent',
+ udp.domainName + (2,), ('195.218.195.228', 161),
+ 'distant-agent-auth', retryCount=0
)
# Default SNMP context
config.addContext(snmpEngine, '')
+
class CommandResponder(cmdrsp.CommandResponderBase):
- cmdGenMap = {
+ cmdGenMap = {
v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(),
v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(),
v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(),
- v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
+ v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
}
pduTypes = cmdGenMap.keys() # This app will handle these PDUs
@@ -110,7 +111,7 @@ class CommandResponder(cmdrsp.CommandResponderBase):
)
except error.PySnmpError:
self.handleResponsePdu(
- stateReference, 'error', None, cbCtx
+ snmpEngine, stateReference, 'error', None, cbCtx
)
# SNMP response relay
@@ -129,9 +130,10 @@ class CommandResponder(cmdrsp.CommandResponderBase):
self.releaseStateInformation(stateReference)
+
CommandResponder(snmpEngine, context.SnmpContext(snmpEngine))
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send responses
try:
diff --git a/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py b/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py
index 8247e45e..2cc397c7 100644
--- a/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py
+++ b/examples/v3arch/asyncore/proxy/command/v3-to-v2c-conversion.py
@@ -82,20 +82,21 @@ config.addTargetParams(snmpEngine, 'distant-agent-auth', 'my-area',
'noAuthNoPriv', 0)
config.addTargetAddr(
- snmpEngine, 'distant-agent',
- udp.domainName + (2,), ('195.218.195.228', 161),
- 'distant-agent-auth', retryCount=0
+ snmpEngine, 'distant-agent',
+ udp.domainName + (2,), ('195.218.195.228', 161),
+ 'distant-agent-auth', retryCount=0
)
# Default SNMP context
config.addContext(snmpEngine, '')
+
class CommandResponder(cmdrsp.CommandResponderBase):
- cmdGenMap = {
+ cmdGenMap = {
v2c.GetRequestPDU.tagSet: cmdgen.GetCommandGenerator(),
v2c.SetRequestPDU.tagSet: cmdgen.SetCommandGenerator(),
v2c.GetNextRequestPDU.tagSet: cmdgen.NextCommandGeneratorSingleRun(),
- v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
+ v2c.GetBulkRequestPDU.tagSet: cmdgen.BulkCommandGeneratorSingleRun()
}
pduTypes = cmdGenMap.keys() # This app will handle these PDUs
@@ -106,14 +107,14 @@ class CommandResponder(cmdrsp.CommandResponderBase):
contextEngineId = None # address authoritative SNMP Engine
try:
self.cmdGenMap[PDU.tagSet].sendPdu(
- snmpEngine, 'distant-agent',
+ snmpEngine, 'distant-agent',
contextEngineId, contextName,
PDU,
self.handleResponsePdu, cbCtx
)
except error.PySnmpError:
self.handleResponsePdu(
- stateReference, 'error', None, cbCtx
+ snmpEngine, stateReference, 'error', None, cbCtx
)
# SNMP response relay
@@ -126,15 +127,14 @@ class CommandResponder(cmdrsp.CommandResponderBase):
PDU = v2c.apiPDU.getResponse(reqPDU)
PDU.setErrorStatus(PDU, 5)
- self.sendPdu(
- snmpEngine, stateReference, PDU
- )
+ self.sendPdu(snmpEngine, stateReference, PDU)
self.releaseStateInformation(stateReference)
+
CommandResponder(snmpEngine, context.SnmpContext(snmpEngine))
-snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
+snmpEngine.transportDispatcher.jobStarted(1) # this job would never finish
# Run I/O dispatcher which would receive queries and send responses
try:
diff --git a/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py b/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py
index 80a2411b..2a145c73 100644
--- a/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py
+++ b/examples/v3arch/twisted/agent/cmdrsp/implementing-scalar-mib-objects.py
@@ -43,7 +43,7 @@ config.addTransport(
config.addV1System(snmpEngine, 'my-area', 'public')
# Allow read MIB access for this user / securityModels at VACM
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,5))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 5))
# Create an SNMP context
snmpContext = context.SnmpContext(snmpEngine)
@@ -56,6 +56,7 @@ MibScalar, MibScalarInstance = mibBuilder.importSymbols(
'SNMPv2-SMI', 'MibScalar', 'MibScalarInstance'
)
+
class MyStaticMibScalarInstance(MibScalarInstance):
# noinspection PyUnusedLocal,PyUnusedLocal
def getValue(self, name, idx):
@@ -63,9 +64,10 @@ class MyStaticMibScalarInstance(MibScalarInstance):
'Python %s running on a %s platform' % (sys.version, sys.platform)
)
+
mibBuilder.exportSymbols(
- '__MY_MIB', MibScalar((1,3,6,5,1), rfc1902.OctetString()),
- MyStaticMibScalarInstance((1,3,6,5,1), (0,), rfc1902.OctetString())
+ '__MY_MIB', MibScalar((1, 3, 6, 5, 1), rfc1902.OctetString()),
+ MyStaticMibScalarInstance((1, 3, 6, 5, 1), (0,), rfc1902.OctetString())
)
# --- end of Managed Object Instance initialization ----
diff --git a/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py b/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py
index a9e3e002..dc4729f6 100644
--- a/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py
+++ b/examples/v3arch/twisted/agent/cmdrsp/multiple-interfaces.py
@@ -48,7 +48,7 @@ config.addTransport(
config.addV1System(snmpEngine, 'my-area', 'public')
# Allow full MIB access for this user / securityModels at VACM
-config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 2, 'my-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py b/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py
index da6cc5f4..ec6799ad 100644
--- a/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py
+++ b/examples/v3arch/twisted/agent/cmdrsp/multiple-snmp-communities.py
@@ -44,8 +44,8 @@ config.addV1System(snmpEngine, 'my-read-area', 'public')
config.addV1System(snmpEngine, 'my-write-area', 'private')
# Allow full MIB access for this user / securityModels at VACM
-config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1,3,6,1,2,1))
-config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 1, 'my-read-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1))
+config.addVacmUser(snmpEngine, 1, 'my-write-area', 'noAuthNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py b/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py
index 91fd9557..372fc886 100644
--- a/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py
+++ b/examples/v3arch/twisted/agent/cmdrsp/multiple-usm-users.py
@@ -60,9 +60,9 @@ config.addV3User(
)
# Allow full MIB access for each user at VACM
-config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
-config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
-config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1,3,6,1,2,1), (1,3,6,1,2,1))
+config.addVacmUser(snmpEngine, 3, 'usr-md5-des', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
+config.addVacmUser(snmpEngine, 3, 'usr-sha-none', 'authNoPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
+config.addVacmUser(snmpEngine, 3, 'usr-sha-aes128', 'authPriv', (1, 3, 6, 1, 2, 1), (1, 3, 6, 1, 2, 1))
# Get default SNMP context this SNMP engine serves
snmpContext = context.SnmpContext(snmpEngine)
diff --git a/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py b/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py
index 33066091..842b454c 100644
--- a/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py
+++ b/examples/v3arch/twisted/manager/ntfrcv/multiple-interfaces.py
@@ -49,18 +49,17 @@ config.addTransport(
# SecurityName <-> CommunityName mapping
config.addV1System(snmpEngine, 'my-area', 'public')
+
# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
varBinds, cbCtx):
- print('Notification from ContextEngineId "%s", Context "%s"' % (
- contextEngineId.prettyPrint(),
- contextName.prettyPrint()
- )
- )
+ print('Notification from ContextEngineId "%s", Context "%s"' % (contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
-
+
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)
diff --git a/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py b/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py
index a9f7e45a..7d058c88 100644
--- a/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py
+++ b/examples/v3arch/twisted/manager/ntfrcv/multiple-usm-users.py
@@ -88,19 +88,19 @@ config.addV3User(
securityEngineId=rfc1902.OctetString(hexValue='8000000001020304')
)
+
# -- end of SNMPv3/USM setup
# Callback function for receiving notifications
# noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal
def cbFun(snmpEngine, stateReference, contextEngineId, contextName,
varBinds, cbCtx):
- print('Notification from ContextEngineId "%s", ContextName "%s"' % (
- contextEngineId.prettyPrint(), contextName.prettyPrint()
- )
- )
+ print('Notification from ContextEngineId "%s", ContextName "%s"' % (contextEngineId.prettyPrint(),
+ contextName.prettyPrint()))
for name, val in varBinds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))
-
+
+
# Register SNMP Application at the SNMP engine
ntfrcv.NotificationReceiver(snmpEngine, cbFun)