diff --git a/ROADMAP.md b/ROADMAP.md index fc385810..a1a604fc 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -29,6 +29,7 @@ Planned tasks are - [x] Identified how the new GET NEXT and GET BULK related API should be designed. - [x] Adapt to Python 3.8 end of life. +- [x] PEP 8 cleanup on method names. - [ ] TODOs Breaking changes are @@ -38,8 +39,8 @@ Breaking changes are For example, calls to ``UdpTransportTarget()`` need to move to ``await UdpTransportTarget.create()``. -- nextCmd and bulkCmd parameters and return types are revised. -- walkCmd and bulkWalkCmd are updated accordingly. +- ``next_cmd`` and ``bulk_cmd`` parameters and return types are revised. +- ``walk_cmd`` and ``bulk_walk_cmd`` are updated accordingly. ## 8.0 Releases diff --git a/docs/source/docs/hlapi/v1arch/asyncio/agent/ntforg/notification.rst b/docs/source/docs/hlapi/v1arch/asyncio/agent/ntforg/notification.rst index b18f89e8..f111fa67 100644 --- a/docs/source/docs/hlapi/v1arch/asyncio/agent/ntforg/notification.rst +++ b/docs/source/docs/hlapi/v1arch/asyncio/agent/ntforg/notification.rst @@ -5,4 +5,4 @@ TRAP/INFORM Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v1arch.asyncio.sendNotification +.. autofunction:: pysnmp.hlapi.v1arch.asyncio.send_notification diff --git a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/bulkcmd.rst b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/bulkcmd.rst index 27bdac1f..28be1eb4 100644 --- a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/bulkcmd.rst +++ b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/bulkcmd.rst @@ -5,4 +5,4 @@ GETBULK Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v1arch.asyncio.bulkCmd +.. autofunction:: pysnmp.hlapi.v1arch.asyncio.bulk_cmd diff --git a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/bulkwalkcmd.rst b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/bulkwalkcmd.rst index 9ee3f08b..10104cf5 100644 --- a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/bulkwalkcmd.rst +++ b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/bulkwalkcmd.rst @@ -5,4 +5,4 @@ BULK WALK Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v1arch.asyncio.bulkWalkCmd +.. autofunction:: pysnmp.hlapi.v1arch.asyncio.bulk_walk_cmd diff --git a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/getcmd.rst b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/getcmd.rst index 28bd519e..a81832dc 100644 --- a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/getcmd.rst +++ b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/getcmd.rst @@ -5,4 +5,4 @@ GET Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v1arch.asyncio.getCmd +.. autofunction:: pysnmp.hlapi.v1arch.asyncio.get_cmd diff --git a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/nextcmd.rst b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/nextcmd.rst index 41c74b24..e861335a 100644 --- a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/nextcmd.rst +++ b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/nextcmd.rst @@ -5,4 +5,4 @@ GETNEXT Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v1arch.asyncio.nextCmd +.. autofunction:: pysnmp.hlapi.v1arch.asyncio.next_cmd diff --git a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/setcmd.rst b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/setcmd.rst index 2e32671f..c8d575f5 100644 --- a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/setcmd.rst +++ b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/setcmd.rst @@ -5,4 +5,4 @@ SET Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v1arch.asyncio.setCmd +.. autofunction:: pysnmp.hlapi.v1arch.asyncio.set_cmd diff --git a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/walkcmd.rst b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/walkcmd.rst index e012aad9..9b04ab59 100644 --- a/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/walkcmd.rst +++ b/docs/source/docs/hlapi/v1arch/asyncio/manager/cmdgen/walkcmd.rst @@ -4,4 +4,4 @@ WALK Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v1arch.asyncio.walkCmd +.. autofunction:: pysnmp.hlapi.v1arch.asyncio.walk_cmd diff --git a/docs/source/docs/hlapi/v3arch/asyncio/agent/ntforg/notification.rst b/docs/source/docs/hlapi/v3arch/asyncio/agent/ntforg/notification.rst index 94a2f4ac..efa87eb2 100644 --- a/docs/source/docs/hlapi/v3arch/asyncio/agent/ntforg/notification.rst +++ b/docs/source/docs/hlapi/v3arch/asyncio/agent/ntforg/notification.rst @@ -5,4 +5,4 @@ TRAP/INFORM Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v3arch.asyncio.sendNotification +.. autofunction:: pysnmp.hlapi.v3arch.asyncio.send_notification diff --git a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/bulkcmd.rst b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/bulkcmd.rst index 232eb751..8c7cb7b2 100644 --- a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/bulkcmd.rst +++ b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/bulkcmd.rst @@ -5,4 +5,4 @@ GETBULK Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v3arch.asyncio.bulkCmd +.. autofunction:: pysnmp.hlapi.v3arch.asyncio.bulk_cmd diff --git a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/bulkwalkcmd.rst b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/bulkwalkcmd.rst index 6846ac5f..1596f107 100644 --- a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/bulkwalkcmd.rst +++ b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/bulkwalkcmd.rst @@ -5,4 +5,4 @@ BULK WALK Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v3arch.asyncio.bulkWalkCmd +.. autofunction:: pysnmp.hlapi.v3arch.asyncio.bulk_walk_cmd diff --git a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/getcmd.rst b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/getcmd.rst index e304fc90..c9a8e5b4 100644 --- a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/getcmd.rst +++ b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/getcmd.rst @@ -5,4 +5,4 @@ GET Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v3arch.asyncio.getCmd +.. autofunction:: pysnmp.hlapi.v3arch.asyncio.get_cmd diff --git a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/nextcmd.rst b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/nextcmd.rst index 45321d94..30ca4ba2 100644 --- a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/nextcmd.rst +++ b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/nextcmd.rst @@ -5,4 +5,4 @@ GETNEXT Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v3arch.asyncio.nextCmd +.. autofunction:: pysnmp.hlapi.v3arch.asyncio.next_cmd diff --git a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/setcmd.rst b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/setcmd.rst index 3b36beb3..3a9c6e97 100644 --- a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/setcmd.rst +++ b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/setcmd.rst @@ -5,4 +5,4 @@ SET Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v3arch.asyncio.setCmd +.. autofunction:: pysnmp.hlapi.v3arch.asyncio.set_cmd diff --git a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/walkcmd.rst b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/walkcmd.rst index 6681277c..d28c6f30 100644 --- a/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/walkcmd.rst +++ b/docs/source/docs/hlapi/v3arch/asyncio/manager/cmdgen/walkcmd.rst @@ -4,4 +4,4 @@ WALK Operation .. toctree:: :maxdepth: 2 -.. autofunction:: pysnmp.hlapi.v3arch.asyncio.walkCmd +.. autofunction:: pysnmp.hlapi.v3arch.asyncio.walk_cmd diff --git a/docs/source/docs/pysnmp-hlapi-tutorial.rst b/docs/source/docs/pysnmp-hlapi-tutorial.rst index fb102c88..fedff18c 100644 --- a/docs/source/docs/pysnmp-hlapi-tutorial.rst +++ b/docs/source/docs/pysnmp-hlapi-tutorial.rst @@ -41,17 +41,17 @@ Making SNMP Query We will send SNMP GET command to read a MIB object from SNMP agent. For that purpose we will call asyncio based, high-level -:py:func:`~pysnmp.hlapi.v3arch.asyncio.getCmd` function. +:py:func:`~pysnmp.hlapi.v3arch.asyncio.get_cmd` function. Other SNMP commands can be used in a vary similar way by calling corresponding functions. .. code-block:: python >>> from pysnmp.hlapi.v3arch.asyncio import * - >>> [ x for x in dir() if 'Cmd' in x] - ['bulkCmd', 'getCmd', 'nextCmd', 'setCmd'] - >>> getCmd - + >>> [ x for x in dir() if 'cmd' in x] + ['bulk_cmd', 'get_cmd', 'next_cmd', 'set_cmd'] + >>> get_cmd + Choosing SNMP Protocol and Credentials -------------------------------------- @@ -99,7 +99,7 @@ insecure, it's still the most popular SNMP version in use. >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await getCmd(SnmpEngine(), CommunityData('public'), + >>> g = await get_cmd(SnmpEngine(), CommunityData('public'), ... Setting Transport and Target @@ -116,7 +116,7 @@ SNMP LCD in form of properly initialized >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await getCmd(SnmpEngine(), + >>> g = await get_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... @@ -139,7 +139,7 @@ For this example we will use the 'empty' context (default). >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await getCmd(SnmpEngine(), + >>> g = await get_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -238,7 +238,7 @@ in `RFC3418`_ ``SNMPv2-MIB`` module. .. code-block:: python >>> from pysnmp.hlapi.v3arch.asyncio import * - >>> g = await getCmd(SnmpEngine(), + >>> g = await get_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -266,7 +266,7 @@ something meaningful in response. >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await getCmd(SnmpEngine(), + >>> g = await get_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -362,7 +362,7 @@ Let's read TCP-MIB::tcpConnectionState object for a TCP connection: >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await getCmd(SnmpEngine(), + >>> g = await get_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -378,13 +378,13 @@ SNMP Command Operations SNMP allows you to request a MIB object that is "next" to the given one. That way you can read MIB objects you are not aware about in advance. MIB objects are conceptually sorted by their OIDs. -This feature is implemented by the :py:func:`~pysnmp.hlapi.v3arch.asyncio.nextCmd` +This feature is implemented by the :py:func:`~pysnmp.hlapi.v3arch.asyncio.next_cmd` function. .. code-block:: python >>> from pysnmp.hlapi.v3arch.asyncio import * - >>> g = await nextCmd(SnmpEngine(), + >>> g = await next_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -393,7 +393,7 @@ function. (None, 0, 0, [ObjectType(ObjectIdentity('1.3.6.1.2.1.1.1.0'), DisplayString('SunOS zeus.pysnmp.com'))]) Iteration over the generator object "walk" over SNMP agent's MIB objects -requires :py:func:`~pysnmp.hlapi.v3arch.asyncio.walkCmd` function to be +requires :py:func:`~pysnmp.hlapi.v3arch.asyncio.walk_cmd` function to be called. SNMPv2c introduced significant optimization to the *GETNEXT* command - @@ -403,7 +403,7 @@ non-repeaters and max-repetitions parameters can be used to influence MIB objects batching. PySNMP hides this *GETBULK* optimization at the protocol level, the -:py:func:`~pysnmp.hlapi.v3arch.asyncio.bulkWalkCmd` function exposes the +:py:func:`~pysnmp.hlapi.v3arch.asyncio.bulk_walk_cmd` function exposes the same generator API as *getNext()* for convenience. .. code-block:: python @@ -411,7 +411,7 @@ same generator API as *getNext()* for convenience. >>> from pysnmp.hlapi.v3arch.asyncio import * >>> >>> N, R = 0, 25 - >>> g = await bulkCmd(SnmpEngine(), + >>> g = await bulk_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -430,7 +430,7 @@ of MIB objects. >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await nextCmd(SnmpEngine(), + >>> g = await next_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -447,7 +447,7 @@ values in exactly the same order as they were in request message. >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await getCmd(SnmpEngine(), + >>> g = await get_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -463,14 +463,14 @@ somewhat demanding (due to locking and transactional behavior requirements). So vendors tend to leave it out thus rendering managed entity being read-only. -PySNMP supports *SET* uniformly through :py:func:`~pysnmp.hlapi.v3arch.asyncio.setCmd` +PySNMP supports *SET* uniformly through :py:func:`~pysnmp.hlapi.v3arch.asyncio.set_cmd` function. .. code-block:: python >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await setCmd(SnmpEngine(), + >>> g = await set_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -534,7 +534,7 @@ or acknowledgement is sent. >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await sendNotification(SnmpEngine(), + >>> g = await send_notification(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 162)), ... ContextData(), @@ -552,7 +552,7 @@ well as for agent-to-manager. >>> from pysnmp.hlapi.v3arch.asyncio import * >>> - >>> g = await sendNotification(SnmpEngine(), + >>> g = await send_notification(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 162)), ... ContextData(), @@ -582,7 +582,7 @@ object OIDs to current values. ... ObjectIdentifier('1.3.6.1.2.1.2.2.1.7.123'): 'testing', ... ObjectIdentifier('1.3.6.1.2.1.2.2.1.8.123'): 'up'} >>> - >>> g = await sendNotification(SnmpEngine(), + >>> g = await send_notification(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 162)), ... ContextData(), diff --git a/docs/source/faq/listening-on-multiple-interfaces.rst b/docs/source/faq/listening-on-multiple-interfaces.rst index 71cc644b..a858c70c 100644 --- a/docs/source/faq/listening-on-multiple-interfaces.rst +++ b/docs/source/faq/listening-on-multiple-interfaces.rst @@ -2,12 +2,12 @@ Listening on multiple network interfaces ---------------------------------------- -Q. I need my receiving entity (CommandResponder or Notification Receiver) - to listen for SNMP messages on multiple network interfaces. How do +Q. I need my receiving entity (CommandResponder or Notification Receiver) + to listen for SNMP messages on multiple network interfaces. How do I do that with pysnmp? -A. Simply register multiple network transports with your SNMP engine. - Each transport would be bound to an individual local transport +A. Simply register multiple network transports with your SNMP engine. + Each transport would be bound to an individual local transport endpoint (for instance, IP address & UDP port pair). .. code-block:: python @@ -15,22 +15,22 @@ A. Simply register multiple network transports with your SNMP engine. # Security setup would follow ... # Setup first transport endpoint - config.addSocketTransport( + config.add_socket_transport( snmpEngine, udp.domainName + (1,), - udp.UdpSocketTransport().openServerMode(('127.0.0.1', 162)) + udp.UdpSocketTransport().open_server_mode(('127.0.0.1', 162)) ) # Setup second transport endpoint - config.addSocketTransport( + config.add_socket_transport( snmpEngine, udp.domainName + (2,), - udp.UdpSocketTransport().openServerMode(('192.168.1.1', 162)) + udp.UdpSocketTransport().open_server_mode(('192.168.1.1', 162)) ) # Receiver callback function implementation and Dispatcher invocation # would follow ... - Notice extended transport domain specification (udp.domainName) in - the code above. There we register each transport endpoint under distinct + Notice extended transport domain specification (udp.domainName) in + the code above. There we register each transport endpoint under distinct OID, however always within the canonical transport domain OID. diff --git a/docs/source/faq/oids-not-increasing.rst b/docs/source/faq/oids-not-increasing.rst index ce9360f3..b7b86071 100644 --- a/docs/source/faq/oids-not-increasing.rst +++ b/docs/source/faq/oids-not-increasing.rst @@ -2,7 +2,7 @@ Dealing with the "OID not increasing" error ------------------------------------------- -Q. I'm walking a particular Agent with the `walkCmd()` or `bulkWalkCmd()` +Q. I'm walking a particular Agent with the `walk_cmd()` or `bulk_walk_cmd()` functions. It works for some OIDs, but invariably fails at certain OID with the *OID not increasing* error. What does it mean and how do I fix that? @@ -19,7 +19,7 @@ A. The Agent you are talking to seems to be broken. The If you have to work with a broken Agent and can terminate the GETNEXT/GETBULK command at some point, you can pass the - `ignoreNonIncreasingOid=True` keyword parameter to the `walkCmd()` or `bulkWalkCmd()` + `ignoreNonIncreasingOid=True` keyword parameter to the `walk_cmd()` or `bulk_walk_cmd()` to disable OID verification at the Manager side. .. code-block:: python @@ -28,7 +28,7 @@ A. The Agent you are talking to seems to be broken. The async for (errorIndication, errorStatus, errorIndex, - varBinds) in walkCmd(snmpEngine, + varBinds) in walk_cmd(snmpEngine, CommunityData('public'), await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ContextData(), diff --git a/docs/source/faq/pass-custom-mib-to-manager.rst b/docs/source/faq/pass-custom-mib-to-manager.rst index 03bc7e05..ecb75955 100644 --- a/docs/source/faq/pass-custom-mib-to-manager.rst +++ b/docs/source/faq/pass-custom-mib-to-manager.rst @@ -28,8 +28,8 @@ A. Starting from PySNMP 4.3.x, plain-text (ASN.1) MIBs can be from pysnmp import hlapi from pysnmp.smi import compiler engine = hlapi.Engine() - builder = engine.getMibBuilder() - compiler.addMibCompiler(builder, sources=[ + builder = engine.get_mib_builder() + compiler.add_mib_compiler(builder, sources=[ '/usr/share/snmp/mibs', os.path.expanduser('~/.snmp/mibs'), 'https://mibs.pysnmp.com/asn1/@mib@', @@ -44,9 +44,9 @@ add the directory to your MibBuilder's MibSources. .. code:: - builder = engine.getMibBuilder() + builder = engine.get_mib_builder() # Make ./mibs available to all OIDs that are created # e.g. with "MIB-NAME-MIB::identifier" - builder.addMibSources(builder_module.DirMibSource( + builder.add_mib_sources(builder_module.DirMibSource( os.path.join( HERE, 'mibs') )) diff --git a/docs/source/faq/snmp-data-constraints-verification-failure.rst b/docs/source/faq/snmp-data-constraints-verification-failure.rst index 6b2aad23..f5020dfb 100644 --- a/docs/source/faq/snmp-data-constraints-verification-failure.rst +++ b/docs/source/faq/snmp-data-constraints-verification-failure.rst @@ -17,20 +17,20 @@ A. Yes, it can do that. The Manager will verify the values you pass to SET .. code-block:: python - errorIndication, errorStatus, errorIndex, varBinds = await cmdGen.setCmd( + errorIndication, errorStatus, errorIndex, varBinds = await cmdGen.set_cmd( cmdgen.CommunityData('public'), await cmdgen.UdpTransportTarget(('localhost', 161)), ( cmdgen.MibVariable('SNMPv2-MIB', 'sysName', 0), 'new system name' ) ) To verify the response values, you should pass at least lookupValues flag -to CommandGenerator \*cmd() method you use. In the following example +to CommandGenerator \*_cmd() method you use. In the following example PySNMP will make sure that Agent-supplied value for SNMPv2-MIB::sysName Managed Object satisfies MIB constraints (if any). .. code-block:: python - errorIndication, errorStatus, errorIndex, varBinds = await cmdGen.getCmd( + errorIndication, errorStatus, errorIndex, varBinds = await cmdGen.get_cmd( cmdgen.CommunityData('public'), await cmdgen.UdpTransportTarget(('localhost', 161)), cmdgen.MibVariable('SNMPv2-MIB', 'sysName', 0), diff --git a/docs/source/upgrade.rst b/docs/source/upgrade.rst index 4de1132b..2205ce8f 100644 --- a/docs/source/upgrade.rst +++ b/docs/source/upgrade.rst @@ -166,12 +166,11 @@ The goals are Breaking changes are - Transport type construction API is completely changed to support - async DNS queries. - - For example, calls to ``UdpTransportTarget()`` need to move to - ``await UdpTransportTarget.create()``. -- nextCmd and bulkCmd parameters and return types are revised. -- walkCmd and bulkWalkCmd are updated accordingly. + async DNS queries. For example, to create transport targets now users + need to write ``await UdpTransportTarget.create()`` instead of + ``UdpTransportTarget()``. +- ``next_cmd`` and ``bulk_cmd`` parameters and return types are revised. +- ``walk_cmd`` and ``bulk_walk_cmd`` are updated accordingly. - Dropped Python 3.8 support. Related Resources diff --git a/examples/hlapi/v1arch/asyncio/agent/ntforg/default-v1-trap.py b/examples/hlapi/v1arch/asyncio/agent/ntforg/default-v1-trap.py index 329f6baf..086d7c45 100644 --- a/examples/hlapi/v1arch/asyncio/agent/ntforg/default-v1-trap.py +++ b/examples/hlapi/v1arch/asyncio/agent/ntforg/default-v1-trap.py @@ -45,7 +45,7 @@ async def run(): if errorIndication: print(errorIndication) - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() asyncio.run(run()) diff --git a/examples/hlapi/v1arch/asyncio/manager/cmdgen/getbulk-to-eom.py b/examples/hlapi/v1arch/asyncio/manager/cmdgen/getbulk-to-eom.py index 92b9287c..93a3deed 100644 --- a/examples/hlapi/v1arch/asyncio/manager/cmdgen/getbulk-to-eom.py +++ b/examples/hlapi/v1arch/asyncio/manager/cmdgen/getbulk-to-eom.py @@ -55,7 +55,7 @@ async def run(varBinds): if is_end_of_mib(varBinds): break - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() asyncio.run(run([ObjectType(ObjectIdentity("SNMPv2-MIB", "sysDescr"))])) diff --git a/examples/hlapi/v1arch/asyncio/manager/cmdgen/v1-get.py b/examples/hlapi/v1arch/asyncio/manager/cmdgen/v1-get.py index b0a3b262..aa3bdae7 100644 --- a/examples/hlapi/v1arch/asyncio/manager/cmdgen/v1-get.py +++ b/examples/hlapi/v1arch/asyncio/manager/cmdgen/v1-get.py @@ -45,7 +45,7 @@ async def run(): for varBind in varBinds: print(" = ".join([x.prettyPrint() for x in varBind])) - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() asyncio.run(run()) diff --git a/examples/v3arch/asyncio/agent/ntforg/send-custom-pdu.py b/examples/v3arch/asyncio/agent/ntforg/send-custom-pdu.py index c363a201..3c83508d 100644 --- a/examples/v3arch/asyncio/agent/ntforg/send-custom-pdu.py +++ b/examples/v3arch/asyncio/agent/ntforg/send-custom-pdu.py @@ -99,4 +99,4 @@ def cbFun( print("Notification is scheduled to be sent") # Run I/O dispatcher which would send pending message and process response -snmpEngine.openDispatcher() +snmpEngine.oepn_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/custom-contextengineid-and-contextname.py b/examples/v3arch/asyncio/manager/cmdgen/custom-contextengineid-and-contextname.py index 6ef3720e..50332cd4 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/custom-contextengineid-and-contextname.py +++ b/examples/v3arch/asyncio/manager/cmdgen/custom-contextengineid-and-contextname.py @@ -82,6 +82,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/custom-timeout-and-retries.py b/examples/v3arch/asyncio/manager/cmdgen/custom-timeout-and-retries.py index d79edeea..37970c8c 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/custom-timeout-and-retries.py +++ b/examples/v3arch/asyncio/manager/cmdgen/custom-timeout-and-retries.py @@ -85,6 +85,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/fetch-variables-over-ipv6.py b/examples/v3arch/asyncio/manager/cmdgen/fetch-variables-over-ipv6.py index dbc04214..f967ac0f 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/fetch-variables-over-ipv6.py +++ b/examples/v3arch/asyncio/manager/cmdgen/fetch-variables-over-ipv6.py @@ -80,6 +80,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py b/examples/v3arch/asyncio/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py index f0ce025e..16b75178 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py +++ b/examples/v3arch/asyncio/manager/cmdgen/getbulk-fetch-scalar-and-table-variables.py @@ -90,6 +90,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/getbulk-multiple-oids-to-eom.py b/examples/v3arch/asyncio/manager/cmdgen/getbulk-multiple-oids-to-eom.py index 1f15c9bc..5ad0d9e2 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/getbulk-multiple-oids-to-eom.py +++ b/examples/v3arch/asyncio/manager/cmdgen/getbulk-multiple-oids-to-eom.py @@ -84,6 +84,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py b/examples/v3arch/asyncio/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py index e0a3a55a..eb97c911 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py +++ b/examples/v3arch/asyncio/manager/cmdgen/getnext-multiple-oids-and-resolve-with-mib.py @@ -27,7 +27,7 @@ # This call will fail if PySMI is not present on the system compiler.add_mib_compiler(snmpEngine.get_mib_builder()) # ... alternatively, this call will not complain on missing PySMI -# compiler.addMibCompiler(snmpEngine.getMibBuilder(), ifAvailable=True) +# compiler.addMibCompiler(snmpEngine.get_mib_builder(), ifAvailable=True) # Used for MIB objects resolution mibViewController = view.MibViewController(snmpEngine.get_mib_builder()) @@ -59,7 +59,7 @@ # Error/response receiver # noinspection PyUnusedLocal,PyUnusedLocal,PyUnusedLocal -def cbFun( +def __callback( snmpEngine, sendRequestHandle, errorIndication, @@ -102,10 +102,10 @@ def cbFun( mibViewController ), ], - cbFun, + __callback, ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.open_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/getnext-multiple-oids-to-eom.py b/examples/v3arch/asyncio/manager/cmdgen/getnext-multiple-oids-to-eom.py index 322c8dec..0c42ccb8 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/getnext-multiple-oids-to-eom.py +++ b/examples/v3arch/asyncio/manager/cmdgen/getnext-multiple-oids-to-eom.py @@ -84,6 +84,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/observe-request-processing.py b/examples/v3arch/asyncio/manager/cmdgen/observe-request-processing.py index ca22ffe0..71779a44 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/observe-request-processing.py +++ b/examples/v3arch/asyncio/manager/cmdgen/observe-request-processing.py @@ -122,7 +122,7 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.observer.unregisterObserver() diff --git a/examples/v3arch/asyncio/manager/cmdgen/pull-subtree.py b/examples/v3arch/asyncio/manager/cmdgen/pull-subtree.py index a7ea9ea1..ad0d53fb 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/pull-subtree.py +++ b/examples/v3arch/asyncio/manager/cmdgen/pull-subtree.py @@ -89,6 +89,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/send-packets-from-specific-interface.py b/examples/v3arch/asyncio/manager/cmdgen/send-packets-from-specific-interface.py index 50ad164b..f806e39e 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/send-packets-from-specific-interface.py +++ b/examples/v3arch/asyncio/manager/cmdgen/send-packets-from-specific-interface.py @@ -85,6 +85,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/set-multiple-scalar-values.py b/examples/v3arch/asyncio/manager/cmdgen/set-multiple-scalar-values.py index f3d91c72..679f3c47 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/set-multiple-scalar-values.py +++ b/examples/v3arch/asyncio/manager/cmdgen/set-multiple-scalar-values.py @@ -84,6 +84,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/usm-sha-aes128.py b/examples/v3arch/asyncio/manager/cmdgen/usm-sha-aes128.py index 1a9255ae..60f59651 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/usm-sha-aes128.py +++ b/examples/v3arch/asyncio/manager/cmdgen/usm-sha-aes128.py @@ -82,6 +82,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/usm-sha-none.py b/examples/v3arch/asyncio/manager/cmdgen/usm-sha-none.py index 5dc37919..16df1134 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/usm-sha-none.py +++ b/examples/v3arch/asyncio/manager/cmdgen/usm-sha-none.py @@ -77,6 +77,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/v1-get.py b/examples/v3arch/asyncio/manager/cmdgen/v1-get.py index db477f40..09b9d3aa 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/v1-get.py +++ b/examples/v3arch/asyncio/manager/cmdgen/v1-get.py @@ -78,6 +78,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/examples/v3arch/asyncio/manager/cmdgen/v2c-set.py b/examples/v3arch/asyncio/manager/cmdgen/v2c-set.py index a8e5cc17..7be8e55d 100644 --- a/examples/v3arch/asyncio/manager/cmdgen/v2c-set.py +++ b/examples/v3arch/asyncio/manager/cmdgen/v2c-set.py @@ -76,6 +76,6 @@ def cbFun( ) # Run I/O dispatcher which would send pending queries and process responses -snmpEngine.openDispatcher(3) +snmpEngine.oepn_dispatcher(3) snmpEngine.close_dispatcher() diff --git a/pysnmp/carrier/asyncio/dgram/base.py b/pysnmp/carrier/asyncio/dgram/base.py index 9523c003..854def5a 100644 --- a/pysnmp/carrier/asyncio/dgram/base.py +++ b/pysnmp/carrier/asyncio/dgram/base.py @@ -55,19 +55,19 @@ connection_lost(exc): Cleans up after connection is lost. - openClientMode(iface=None, allow_broadcast=False): + open_client_mode(iface=None, allow_broadcast=False): Opens client mode. - openServerMode(iface=None, sock=None): + open_server_mode(iface=None, sock=None): Opens server mode. - closeTransport(): + close_transport(): Closes the transport. - sendMessage(outgoingMessage, transportAddress): + send_message(outgoingMessage, transportAddress): Sends a message to the transport. - normalizeAddress(transportAddress): + normalize_address(transportAddress): Returns a transport address object. """ import asyncio diff --git a/pysnmp/hlapi/v1arch/asyncio/cmdgen.py b/pysnmp/hlapi/v1arch/asyncio/cmdgen.py index a77fab4f..f8a0bb91 100644 --- a/pysnmp/hlapi/v1arch/asyncio/cmdgen.py +++ b/pysnmp/hlapi/v1arch/asyncio/cmdgen.py @@ -113,7 +113,7 @@ class instances (if `lookupMib` is `True`) representing MIB variables >>> from pysnmp.hlapi.v1arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await getCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await get_cmd( ... SnmpDispatcher(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), @@ -244,7 +244,7 @@ class instances (if `lookupMib` is `True`) representing MIB variables >>> from pysnmp.hlapi.v1arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await setCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await set_cmd( ... SnmpDispatcher(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), @@ -378,7 +378,7 @@ async def next_cmd( >>> from pysnmp.hlapi.v1arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await nextCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await next_cmd( ... SnmpDispatcher(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), @@ -550,7 +550,7 @@ async def bulk_cmd( >>> from pysnmp.hlapi.v1arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await bulkCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await bulk_cmd( ... SnmpDispatcher(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), @@ -694,7 +694,7 @@ async def walk_cmd( Notes ----- - The `walkCmd` generator will be exhausted on any of the following + The `walk_cmd` generator will be exhausted on any of the following conditions: * SNMP engine error occurs thus `errorIndication` is `True` @@ -712,7 +712,7 @@ async def walk_cmd( Examples -------- >>> from pysnmp.hlapi.v1arch.asyncio import * - >>> g = await walkCmd(SnmpEngine(), + >>> g = await walk_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'))) @@ -887,7 +887,7 @@ async def bulk_walk_cmd( Notes ----- - The `bulkWalkCmd` generator will be exhausted on any of the following + The `bulk_walk_cmd` generator will be exhausted on any of the following conditions: * SNMP engine error occurs thus `errorIndication` is `True` @@ -909,7 +909,7 @@ async def bulk_walk_cmd( Examples -------- >>> from pysnmp.hlapi.v1arch.asyncio import * - >>> g = await bulkWalkCmd(SnmpEngine(), + >>> g = await bulk_walk_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... 0, 25, diff --git a/pysnmp/hlapi/v1arch/asyncio/ntforg.py b/pysnmp/hlapi/v1arch/asyncio/ntforg.py index 277afcbb..7d8794ce 100644 --- a/pysnmp/hlapi/v1arch/asyncio/ntforg.py +++ b/pysnmp/hlapi/v1arch/asyncio/ntforg.py @@ -120,7 +120,7 @@ class instances (if `lookupMib` is `True`) representing MIB variables >>> from pysnmp.hlapi.v1arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await sendNotification( + ... errorIndication, errorStatus, errorIndex, varBinds = await send_notification( ... SnmpDispatcher(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 162)), diff --git a/pysnmp/hlapi/v1arch/asyncio/slim.py b/pysnmp/hlapi/v1arch/asyncio/slim.py index e6e52324..3c30e680 100644 --- a/pysnmp/hlapi/v1arch/asyncio/slim.py +++ b/pysnmp/hlapi/v1arch/asyncio/slim.py @@ -55,7 +55,7 @@ def __init__(self, version: int = 2): def close(self): """Closes the wrapper to release its resources.""" - self.__snmp_dispatcher.transportDispatcher.close_dispatcher() + self.__snmp_dispatcher.transport_dispatcher.close_dispatcher() def __enter__(self): """Returns the wrapper object.""" diff --git a/pysnmp/hlapi/v1arch/dispatch.py b/pysnmp/hlapi/v1arch/dispatch.py index ffbbfe5a..3eda7437 100644 --- a/pysnmp/hlapi/v1arch/dispatch.py +++ b/pysnmp/hlapi/v1arch/dispatch.py @@ -5,6 +5,7 @@ # License: https://www.pysnmp.com/pysnmp/license.html # from time import time +import warnings from pyasn1.codec.ber import decoder, encoder from pysnmp import debug @@ -36,34 +37,33 @@ class AbstractSnmpDispatcher: """ PROTO_DISPATCHER = None + transport_dispatcher: AbstractTransportDispatcher - def __init__(self, transportDispatcher: AbstractTransportDispatcher = None): + def __init__(self, transportDispatcher: AbstractTransportDispatcher = None): # type: ignore if transportDispatcher: - self.transportDispatcher = transportDispatcher + self.transport_dispatcher = transportDispatcher else: - self.transportDispatcher = self.PROTO_DISPATCHER() + self.transport_dispatcher = self.PROTO_DISPATCHER() - self._automaticDispatcher = transportDispatcher is not self.transportDispatcher + self._automaticDispatcher = transportDispatcher is not self.transport_dispatcher self._configuredTransports = set() self._pendingReqs = {} - self.transportDispatcher.register_recv_callback(self._recv_callback) - self.transportDispatcher.register_timer_callback(self._timer_callback) + self.transport_dispatcher.register_recv_callback(self._recv_callback) + self.transport_dispatcher.register_timer_callback(self._timer_callback) self.cache = {} def __repr__(self): - return ( - f"{self.__class__.__name__}(transportDispatcher={self.transportDispatcher})" - ) + return f"{self.__class__.__name__}(transportDispatcher={self.transport_dispatcher})" def close(self): - self.transportDispatcher.unregister_recv_callback() - self.transportDispatcher.unregister_timer_callback() + self.transport_dispatcher.unregister_recv_callback() + self.transport_dispatcher.unregister_timer_callback() if self._automaticDispatcher: - self.transportDispatcher.close() + self.transport_dispatcher.close() for requestId, stateInfo in self._pendingReqs.items(): cbFun = stateInfo["cbFun"] @@ -86,7 +86,7 @@ def send_pdu( self._automaticDispatcher and transportTarget.TRANSPORT_DOMAIN not in self._configuredTransports ): - self.transportDispatcher.register_transport( + self.transport_dispatcher.register_transport( transportTarget.TRANSPORT_DOMAIN, transportTarget.PROTO_TRANSPORT().open_client_mode(), ) @@ -112,7 +112,7 @@ def send_pdu( retries=0, ) - self.transportDispatcher.send_message( + self.transport_dispatcher.send_message( outgoingMsg, transportTarget.TRANSPORT_DOMAIN, transportTarget.transport_address, @@ -123,7 +123,7 @@ def send_pdu( ) or reqPdu.__class__ is getattr(pMod, "TrapPDU", None): return requestId - self.transportDispatcher.job_started(id(self)) + self.transport_dispatcher.job_started(id(self)) return requestId @@ -154,7 +154,7 @@ def _recv_callback( except KeyError: continue - self.transportDispatcher.job_finished(id(self)) + self.transport_dispatcher.job_finished(id(self)) cbFun = stateInfo["cbFun"] cbCtx = stateInfo["cbCtx"] @@ -185,7 +185,7 @@ def _timer_callback(self, timeNow): None, cbCtx, ) - self.transportDispatcher.job_finished(id(self)) + self.transport_dispatcher.job_finished(id(self)) continue stateInfo["retries"] += 1 @@ -193,8 +193,27 @@ def _timer_callback(self, timeNow): outgoingMsg = stateInfo["outgoingMsg"] - self.transportDispatcher.send_message( + self.transport_dispatcher.send_message( outgoingMsg, transportTarget.TRANSPORT_DOMAIN, transportTarget.transport_address, ) + + # compatibility with legacy code + # Old to new attribute mapping + deprecated_attributes = { + "transportDispatcher": "transport_dispatcher", + "sendPdu": "send_pdu", + } + + def __getattr__(self, attr: str): + if new_attr := self.deprecated_attributes.get(attr): + warnings.warn( + f"{attr} is deprecated. Please use {new_attr} instead.", + DeprecationWarning, + stacklevel=2, + ) + return getattr(self, new_attr) + raise AttributeError( + f"'{self.__class__.__name__}' object has no attribute '{attr}'" + ) diff --git a/pysnmp/hlapi/v3arch/asyncio/cmdgen.py b/pysnmp/hlapi/v3arch/asyncio/cmdgen.py index 2516be5c..c63634f6 100644 --- a/pysnmp/hlapi/v3arch/asyncio/cmdgen.py +++ b/pysnmp/hlapi/v3arch/asyncio/cmdgen.py @@ -137,7 +137,7 @@ async def get_cmd( >>> from pysnmp.hlapi.v3arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await getCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await get_cmd( ... SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), @@ -258,7 +258,7 @@ async def set_cmd( >>> from pysnmp.hlapi.v3arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await setCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await set_cmd( ... SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), @@ -387,7 +387,7 @@ async def next_cmd( >>> from pysnmp.hlapi.v3arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await nextCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await next_cmd( ... SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), @@ -554,7 +554,7 @@ async def bulk_cmd( >>> from pysnmp.hlapi.v3arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await bulkCmd( + ... errorIndication, errorStatus, errorIndex, varBinds = await bulk_cmd( ... SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), @@ -696,7 +696,7 @@ async def walk_cmd( Notes ----- - The `walkCmd` generator will be exhausted on any of the following + The `walk_cmd` generator will be exhausted on any of the following conditions: * SNMP engine error occurs thus `errorIndication` is `True` @@ -714,7 +714,7 @@ async def walk_cmd( Examples -------- >>> from pysnmp.hlapi.v3arch.asyncio import * - >>> g = await walkCmd(SnmpEngine(), + >>> g = await walk_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), @@ -895,7 +895,7 @@ async def bulk_walk_cmd( Notes ----- - The `bulkWalkCmd` generator will be exhausted on any of the following + The `bulk_walk_cmd` generator will be exhausted on any of the following conditions: * SNMP engine error occurs thus `errorIndication` is `True` @@ -917,7 +917,7 @@ async def bulk_walk_cmd( Examples -------- >>> from pysnmp.hlapi.v3arch.asyncio import * - >>> g = await bulkWalkCmd(SnmpEngine(), + >>> g = await bulk_walk_cmd(SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 161)), ... ContextData(), diff --git a/pysnmp/hlapi/v3arch/asyncio/ntforg.py b/pysnmp/hlapi/v3arch/asyncio/ntforg.py index 5fe19541..b04a5b0e 100644 --- a/pysnmp/hlapi/v3arch/asyncio/ntforg.py +++ b/pysnmp/hlapi/v3arch/asyncio/ntforg.py @@ -118,7 +118,7 @@ async def send_notification( >>> from pysnmp.hlapi.v3arch.asyncio import * >>> >>> async def run(): - ... errorIndication, errorStatus, errorIndex, varBinds = await sendNotification( + ... errorIndication, errorStatus, errorIndex, varBinds = await send_notification( ... SnmpEngine(), ... CommunityData('public'), ... await UdpTransportTarget.create(('demo.pysnmp.com', 162)), diff --git a/pysnmp/proto/rfc1902.py b/pysnmp/proto/rfc1902.py index aa6e778b..4880ae3c 100644 --- a/pysnmp/proto/rfc1902.py +++ b/pysnmp/proto/rfc1902.py @@ -83,10 +83,10 @@ class Integer32(univ.Integer): Integer32(2) >>> int(Integer32(321)) 321 - >>> SmallInteger = Integer32.withRange(1,3) + >>> SmallInteger = Integer32.with_range(1,3) >>> SmallInteger(1) Integer32(1) - >>> DiscreetInteger = Integer32.withValues(4, 8, 1) + >>> DiscreetInteger = Integer32.with_values(4, 8, 1) >>> DiscreetInteger(4) Integer32(4) >>> @@ -157,7 +157,7 @@ class Integer(Integer32): Integer(2) >>> int(Integer(321)) 321 - >>> SomeState = Integer.withNamedValues(enable=1, disable=0) + >>> SomeState = Integer.with_named_values(enable=1, disable=0) >>> SomeState(1) Integer('enable') >>> int(SomeState('disable')) @@ -218,7 +218,7 @@ class instance. OctetString('some apples and oranges') >>> str(OctetString('some apples')) 'some apples' - >>> SomeString = OctetString.withSize(3, 12) + >>> SomeString = OctetString.with_size(3, 12) >>> str(SomeString(hexValue='deadbeef')) '\xde\xad\xbe\xef' >>> @@ -666,7 +666,7 @@ class Bits(OctetString): Examples -------- >>> from pysnmp.proto.rfc1902 import * - >>> SomeBits = Bits.withNamedBits(apple=0, orange=1, peach=2) + >>> SomeBits = Bits.with_named_bits(apple=0, orange=1, peach=2) >>> SomeBits(('apple', 'orange')).prettyPrint() 'apple, orange' >>> SomeBits(('apple', 'orange')) diff --git a/pysnmp/smi/rfc1902.py b/pysnmp/smi/rfc1902.py index 38d3062d..23ea6a7d 100644 --- a/pysnmp/smi/rfc1902.py +++ b/pysnmp/smi/rfc1902.py @@ -62,7 +62,7 @@ class ObjectIdentity: Notes ----- Actual conversion between MIB variable representation formats occurs - upon :py:meth:`~pysnmp.smi.rfc1902.ObjectIdentity.resolveWithMib` + upon :py:meth:`~pysnmp.smi.rfc1902.ObjectIdentity.resolve_with_mib` invocation. Examples @@ -116,8 +116,8 @@ class instance representing MIB variable instance index. Examples -------- >>> objectIdentity = ObjectIdentity('1.3.6.1.2.1.1.1.0') - >>> objectIdentity.resolveWithMib(mibViewController) - >>> objectIdentity.getMibSymbol() + >>> objectIdentity.resolve_with_mib(mibViewController) + >>> objectIdentity.get_mib_symbol() ('SNMPv2-MIB', 'sysDescr', (0,)) >>> @@ -143,8 +143,8 @@ def get_oid(self): Examples -------- >>> objectIdentity = ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0) - >>> objectIdentity.resolveWithMib(mibViewController) - >>> objectIdentity.getOid() + >>> objectIdentity.resolve_with_mib(mibViewController) + >>> objectIdentity.get_oid() ObjectName('1.3.6.1.2.1.1.1.0') >>> @@ -179,8 +179,8 @@ def get_label(self): Examples -------- >>> objectIdentity = ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0) - >>> objectIdentity.resolveWithMib(mibViewController) - >>> objectIdentity.getOid() + >>> objectIdentity.resolve_with_mib(mibViewController) + >>> objectIdentity.get_oid() ('iso', 'org', 'dod', 'internet', 'mgmt', 'mib-2', 'system', 'sysDescr') >>> @@ -219,10 +219,10 @@ def is_fully_resolved(self): Examples -------- >>> objectIdentity = ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0) - >>> objectIdentity.isFullyResolved() + >>> objectIdentity.is_fully_resolved() False - >>> objectIdentity.resolveWithMib(mibViewController) - >>> objectIdentity.isFullyResolved() + >>> objectIdentity.resolve_with_mib(mibViewController) + >>> objectIdentity.is_fully_resolved() True >>> @@ -257,7 +257,7 @@ def add_asn1_mib_source(self, *asn1Sources, **kwargs): Examples -------- - >>> ObjectIdentity('SNMPv2-MIB', 'sysDescr').addAsn1MibSource('https://mibs.pysnmp.com/asn1/@mib@') + >>> ObjectIdentity('SNMPv2-MIB', 'sysDescr').add_asn1_mib_source('https://mibs.pysnmp.com/asn1/@mib@') ObjectIdentity('SNMPv2-MIB', 'sysDescr') >>> @@ -296,7 +296,7 @@ def add_mib_source(self, *mibSources): Examples -------- - >>> ObjectIdentity('SNMPv2-MIB', 'sysDescr').addMibSource('/opt/pysnmp/mibs', 'pysnmp_mibs') + >>> ObjectIdentity('SNMPv2-MIB', 'sysDescr').add_mib_source('/opt/pysnmp/mibs', 'pysnmp_mibs') ObjectIdentity('SNMPv2-MIB', 'sysDescr') >>> @@ -324,7 +324,7 @@ def load_mibs(self, *modNames): Examples -------- - >>> ObjectIdentity('SNMPv2-MIB', 'sysDescr').loadMibs('IF-MIB', 'TCP-MIB') + >>> ObjectIdentity('SNMPv2-MIB', 'sysDescr').load_mibs('IF-MIB', 'TCP-MIB') ObjectIdentity('SNMPv2-MIB', 'sysDescr') >>> @@ -380,7 +380,7 @@ class instance Examples -------- >>> objectIdentity = ObjectIdentity('SNMPv2-MIB', 'sysDescr') - >>> objectIdentity.resolveWithMib(mibViewController) + >>> objectIdentity.resolve_with_mib(mibViewController) ObjectIdentity('SNMPv2-MIB', 'sysDescr') >>> @@ -835,7 +835,7 @@ class instance (identifying MIB variable) and optional value belonging Notes ----- Actual conversion between MIB variable representation formats occurs - upon :py:meth:`~pysnmp.smi.rfc1902.ObjectType.resolveWithMib` + upon :py:meth:`~pysnmp.smi.rfc1902.ObjectType.resolve_with_mib` invocation. Examples @@ -910,7 +910,7 @@ def add_asn1_mib_source(self, *asn1Sources, **kwargs): Examples -------- - >>> ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')).addAsn1MibSource('https://mibs.pysnmp.com/asn1/@mib@') + >>> ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')).add_asn1_mib_source('https://mibs.pysnmp.com/asn1/@mib@') ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')) >>> @@ -942,7 +942,7 @@ def add_mib_source(self, *mibSources): Examples -------- - >>> ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')).addMibSource('/opt/pysnmp/mibs', 'pysnmp_mibs') + >>> ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')).add_mib_source('/opt/pysnmp/mibs', 'pysnmp_mibs') ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')) >>> @@ -966,7 +966,7 @@ def load_mibs(self, *modNames): Examples -------- - >>> ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')).loadMibs('IF-MIB', 'TCP-MIB') + >>> ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')).load_mibs('IF-MIB', 'TCP-MIB') ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr')) >>> @@ -1003,15 +1003,15 @@ class instance representing MIB browsing functionality. Notes ----- Calling this method involves - :py:meth:`~pysnmp.smi.rfc1902.ObjectIdentity.resolveWithMib` + :py:meth:`~pysnmp.smi.rfc1902.ObjectIdentity.resolve_with_mib` method invocation. Examples -------- >>> from pysmi.hlapi.v3arch.asyncio import varbinds - >>> mibViewController = varbinds.MibViewControllerManager.getMibViewController(engine.cache) + >>> mibViewController = varbinds.MibViewControllerManager.get_mib_view_controller(engine.cache) >>> objectType = ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'), 'Linux i386') - >>> objectType.resolveWithMib(mibViewController) + >>> objectType.resolve_with_mib(mibViewController) ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr'), DisplayString('Linux i386')) >>> str(objectType) 'SNMPv2-MIB::sysDescr."0" = Linux i386' @@ -1024,7 +1024,7 @@ class instance representing MIB browsing functionality. object_identity: ObjectIdentity = self.__args[0] object_identity.resolve_with_mib(mibViewController) - MibScalar, MibTableColumn = mibViewController.mibBuilder.import_symbols( + MibScalar, MibTableColumn = mibViewController.mibBuilder.import_symbols( # type: ignore "SNMPv2-SMI", "MibScalar", "MibTableColumn" ) @@ -1169,7 +1169,7 @@ class instance (identifying particular notification) and a collection Notes ----- Actual notification type and MIB variables look up occurs - upon :py:meth:`~pysnmp.smi.rfc1902.NotificationType.resolveWithMib` + upon :py:meth:`~pysnmp.smi.rfc1902.NotificationType.resolve_with_mib` invocation. Examples @@ -1231,7 +1231,7 @@ def add_varbinds(self, *varBinds): Examples -------- >>> nt = NotificationType(ObjectIdentity('IP-MIB', 'linkDown')) - >>> nt.addVarBinds(ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))) + >>> nt.add_varbinds(ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))) NotificationType(ObjectIdentity('IP-MIB', 'linkDown'), (), {}) >>> @@ -1269,7 +1269,7 @@ def add_asn1_mib_source(self, *asn1Sources, **kwargs): Examples -------- - >>> NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}).addAsn1MibSource('https://mibs.pysnmp.com/asn1/@mib@') + >>> NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}).add_asn1_mib_source('https://mibs.pysnmp.com/asn1/@mib@') NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}) >>> @@ -1301,7 +1301,7 @@ def add_mib_source(self, *mibSources): Examples -------- - >>> NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}).addMibSource('/opt/pysnmp/mibs', 'pysnmp_mibs') + >>> NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}).add_mib_source('/opt/pysnmp/mibs', 'pysnmp_mibs') NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}) >>> @@ -1325,7 +1325,7 @@ def load_mibs(self, *modNames): Examples -------- - >>> NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}).loadMibs('IF-MIB', 'TCP-MIB') + >>> NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}).load_mibs('IF-MIB', 'TCP-MIB') NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}) >>> @@ -1368,7 +1368,7 @@ class instance representing MIB browsing functionality. Calling this method might cause the following sequence of events (exact details depends on many factors): - * :py:meth:`pysnmp.smi.rfc1902.ObjectIdentity.resolveWithMib` is called + * :py:meth:`pysnmp.smi.rfc1902.ObjectIdentity.resolve_with_mib` is called * MIB variables names are read from NOTIFICATION-TYPE->OBJECTS clause, :py:class:`~pysnmp.smi.rfc1902.ObjectType` instances are created from MIB variable OID and `indexInstance` suffix. @@ -1378,7 +1378,7 @@ class instance representing MIB browsing functionality. Examples -------- >>> notificationType = NotificationType(ObjectIdentity('IF-MIB', 'linkDown')) - >>> notificationType.resolveWithMib(mibViewController) + >>> notificationType.resolve_with_mib(mibViewController) NotificationType(ObjectIdentity('IF-MIB', 'linkDown'), (), {}) >>> diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_get.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_get.py index b69d985b..ed0f8cd0 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_get.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_get.py @@ -31,7 +31,7 @@ async def test_v1_get(): name = pysnmp_errorStatus.namedValues.getName(errorStatus) assert name == "noError" - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -58,7 +58,7 @@ async def test_v1_get_ipv6(): name = pysnmp_errorStatus.namedValues.getName(errorStatus) assert name == "noError" - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() # TODO: @@ -67,7 +67,7 @@ async def test_v1_get_ipv6(): # snmpDispatcher = SnmpDispatcher() # async def run_get(): -# errorIndication, errorStatus, errorIndex, varBinds = await getCmd( +# errorIndication, errorStatus, errorIndex, varBinds = await get_cmd( # snmpDispatcher, # CommunityData("community_string"), # await UdpTransportTarget.create(("1.2.3.4", 161), timeout=1, retries=0), @@ -85,7 +85,7 @@ async def test_v1_get_ipv6(): # except asyncio.TimeoutError: # assert False, "Test case timed out" # finally: -# snmpDispatcher.transportDispatcher.close_dispatcher() +# snmpDispatcher.transport_dispatcher.close_dispatcher() # @pytest.mark.asyncio @@ -94,7 +94,7 @@ async def test_v1_get_ipv6(): # snmpDispatcher = SnmpDispatcher() # async def run_get(): -# errorIndication, errorStatus, errorIndex, varBinds = await getCmd( +# errorIndication, errorStatus, errorIndex, varBinds = await get_cmd( # snmpDispatcher, # CommunityData("public", mpModel=0), # await UdpTransportTarget.create( @@ -114,7 +114,7 @@ async def test_v1_get_ipv6(): # except asyncio.TimeoutError: # assert False, "Test case timed out" # finally: -# snmpDispatcher.transportDispatcher.close_dispatcher() +# snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -131,4 +131,4 @@ async def test_v1_get_no_access_object(): ) assert errorIndication is None assert errorStatus.prettyPrint() == "noSuchName" # v1 does not have noAccess - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_next.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_next.py index 72fd3078..967bd746 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_next.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_next.py @@ -44,4 +44,4 @@ async def test_v1_next(): ) # IMPORTANT: MIB is needed to resolve this name assert type(varBinds[0][1]).__name__ == "ObjectIdentity" - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_set.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_set.py index a4beb26a..3be5e90c 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_set.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_set.py @@ -30,7 +30,7 @@ async def test_v1_set(): assert varBinds[0][1].prettyPrint() == "Shanghai" assert isinstance(varBinds[0][1], OctetString) - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -94,4 +94,4 @@ async def test_v1_set_table_creation(): assert len(objects_list) == object_counts + 4 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_walk.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_walk.py index 2dbc22ee..7c8b0943 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_walk.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v1_walk.py @@ -32,7 +32,7 @@ async def test_v1_walk(): assert len(objects_list) == 267 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -65,4 +65,4 @@ async def test_v1_walk_subtree(): assert len(objects_list) == 8 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2_walk.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2_walk.py index f6e82ae9..b015c695 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2_walk.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2_walk.py @@ -32,7 +32,7 @@ async def test_v2_walk(): # some agents have different v2 GET NEXT behavior assert len(objects_list) == 267 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -65,4 +65,4 @@ async def test_v2_walk_subtree(): assert len(objects_list) == 8 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_bulk.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_bulk.py index a62f60b0..e40daafd 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_bulk.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_bulk.py @@ -28,7 +28,7 @@ async def test_v2c_bulk(num_bulk): if num_bulk > 2: assert varBinds[2][0].prettyPrint() == "SNMPv2-MIB::sysContact.0" - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_bulkwalk.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_bulkwalk.py index bba98751..99f5e6c4 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_bulkwalk.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_bulkwalk.py @@ -37,7 +37,7 @@ async def test_v2c_get_table_bulk(max_repetitions): assert len(objects_list) == 60 / max_repetitions - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -76,7 +76,7 @@ async def test_v2c_get_table_bulk_0_4_subtree(): assert index == 7 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -112,7 +112,7 @@ async def test_v2c_get_table_bulk_0_1_subtree(): assert index == 28 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -147,7 +147,7 @@ async def test_v2c_get_table_bulk_0_7(): # assert varBinds[0][0].prettyPrint() == "SNMPv2-MIB::sysName.0" assert len(objects_list) == 9 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -181,7 +181,7 @@ async def test_v2c_get_table_bulk_0_8(): # assert varBinds[0][0].prettyPrint() == "SNMPv2-MIB::sysName.0" assert len(objects_list) == 8 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -216,7 +216,7 @@ async def test_v2c_get_table_bulk_0_31(): # assert varBinds[0][0].prettyPrint() == "SNMPv2-MIB::sysName.0" assert len(objects_list) == 2 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -244,7 +244,7 @@ async def test_v2c_get_table_bulk_0_60(): assert varBinds[0][0].prettyPrint() == "SNMPv2-MIB::sysObjectID.0" assert len(objects_list) == 1 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -276,7 +276,7 @@ async def test_v2c_get_table_bulk_0_5_subtree(): assert len(varBinds) == 1 assert len(objects_list) == 4 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -308,4 +308,4 @@ async def test_v2c_get_table_bulk_0_6_subtree(): assert len(varBinds) == 4 assert len(objects_list) == 3 - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_get.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_get.py index 51994052..f687c25b 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_get.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_get.py @@ -21,7 +21,7 @@ async def test_v2_get(): assert varBinds[0][1].prettyPrint().startswith("PySNMP engine version") assert isinstance(varBinds[0][1], OctetString) - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -39,7 +39,7 @@ async def test_v2_get_no_access_object(): assert errorIndication is None assert errorStatus.prettyPrint() == "noAccess" # v2c and v3 use noAccess - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() @pytest.mark.asyncio @@ -59,4 +59,4 @@ async def test_v2_get_legacy_object(): assert ( errorStatus.prettyPrint() == "noAccess" ) # PySMI <1.3.0 generates such objects - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_next.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_next.py index f5f7226f..22827e29 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_next.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_next.py @@ -38,4 +38,4 @@ async def test_v2_next(): assert len(varBinds) == 1 assert varBinds[0][0].prettyPrint() == "SNMPv2-MIB::sysObjectID.0" - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher() diff --git a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_set.py b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_set.py index 704097f3..eaf50c3e 100644 --- a/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_set.py +++ b/tests/hlapi/v1arch/asyncio/manager/cmdgen/test_v1arch_v2c_set.py @@ -23,4 +23,4 @@ async def test_v2_set(): assert varBinds[0][1].prettyPrint() == "Shanghai" assert isinstance(varBinds[0][1], OctetString) - snmpDispatcher.transportDispatcher.close_dispatcher() + snmpDispatcher.transport_dispatcher.close_dispatcher()