Skip to content

Commit

Permalink
Fixed documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Oct 13, 2024
1 parent fbeb35d commit 2334846
Show file tree
Hide file tree
Showing 59 changed files with 211 additions and 192 deletions.
5 changes: 3 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ TRAP/INFORM Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v1arch.asyncio.sendNotification
.. autofunction:: pysnmp.hlapi.v1arch.asyncio.send_notification
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ GETBULK Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v1arch.asyncio.bulkCmd
.. autofunction:: pysnmp.hlapi.v1arch.asyncio.bulk_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ BULK WALK Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v1arch.asyncio.bulkWalkCmd
.. autofunction:: pysnmp.hlapi.v1arch.asyncio.bulk_walk_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ GET Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v1arch.asyncio.getCmd
.. autofunction:: pysnmp.hlapi.v1arch.asyncio.get_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ GETNEXT Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v1arch.asyncio.nextCmd
.. autofunction:: pysnmp.hlapi.v1arch.asyncio.next_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ SET Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v1arch.asyncio.setCmd
.. autofunction:: pysnmp.hlapi.v1arch.asyncio.set_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ WALK Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v1arch.asyncio.walkCmd
.. autofunction:: pysnmp.hlapi.v1arch.asyncio.walk_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ TRAP/INFORM Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v3arch.asyncio.sendNotification
.. autofunction:: pysnmp.hlapi.v3arch.asyncio.send_notification
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ GETBULK Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v3arch.asyncio.bulkCmd
.. autofunction:: pysnmp.hlapi.v3arch.asyncio.bulk_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ BULK WALK Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v3arch.asyncio.bulkWalkCmd
.. autofunction:: pysnmp.hlapi.v3arch.asyncio.bulk_walk_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ GET Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v3arch.asyncio.getCmd
.. autofunction:: pysnmp.hlapi.v3arch.asyncio.get_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ GETNEXT Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v3arch.asyncio.nextCmd
.. autofunction:: pysnmp.hlapi.v3arch.asyncio.next_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ SET Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v3arch.asyncio.setCmd
.. autofunction:: pysnmp.hlapi.v3arch.asyncio.set_cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ WALK Operation
.. toctree::
:maxdepth: 2

.. autofunction:: pysnmp.hlapi.v3arch.asyncio.walkCmd
.. autofunction:: pysnmp.hlapi.v3arch.asyncio.walk_cmd
46 changes: 23 additions & 23 deletions docs/source/docs/pysnmp-hlapi-tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
<function getCmd at 0x222b330>
>>> [ x for x in dir() if 'cmd' in x]
['bulk_cmd', 'get_cmd', 'next_cmd', 'set_cmd']
>>> get_cmd
<function get_cmd at 0x222b330>
Choosing SNMP Protocol and Credentials
--------------------------------------
Expand Down Expand Up @@ -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
Expand All @@ -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)),
...
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand All @@ -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 -
Expand All @@ -403,15 +403,15 @@ 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
>>> 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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
20 changes: 10 additions & 10 deletions docs/source/faq/listening-on-multiple-interfaces.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,35 @@
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
# 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.
6 changes: 3 additions & 3 deletions docs/source/faq/oids-not-increasing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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
Expand All @@ -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(),
Expand Down
8 changes: 4 additions & 4 deletions docs/source/faq/pass-custom-mib-to-manager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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@',
Expand All @@ -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')
))
Loading

0 comments on commit 2334846

Please sign in to comment.