from pysnmp.hlapi.lcd import * from pysnmp.hlapi.varbinds import * from pysnmp.hlapi.asyncio.transport import * from pysnmp.entity.rfc3413 import cmdgen try: import asyncio except ImportError: import trollius as asyncio __all__ = ['getCmd', 'nextCmd', 'setCmd', 'bulkCmd', 'isEndOfMib'] vbProcessor = CommandGeneratorVarBinds() lcd = CommandGeneratorLcdConfigurator() isEndOfMib = lambda x: not cmdgen.getNextVarBinds(x)[1] @asyncio.coroutine def getCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Creates a generator to perform SNMP GET query. When itereator gets advanced by :py:mod:`asyncio` main loop, SNMP GET request is send (:RFC:`1905#section-4.2.1`). The iterator yields :py:class:`asyncio.Future` which gets done whenever response arrives or error occurs. Parameters ---------- snmpEngine : :py:class:`~pysnmp.hlapi.SnmpEngine`
from pysnmp.hlapi.auth import * from pysnmp.hlapi.context import * from pysnmp.hlapi.lcd import * from pysnmp.hlapi.varbinds import * from pysnmp.hlapi.twisted.transport import * from pysnmp.entity.rfc3413 import cmdgen from pysnmp.error import PySnmpError from twisted.internet.defer import Deferred from twisted.python.failure import Failure __all__ = ['getCmd', 'nextCmd', 'setCmd', 'bulkCmd', 'isEndOfMib'] vbProcessor = CommandGeneratorVarBinds() lcd = CommandGeneratorLcdConfigurator() isEndOfMib = lambda x: not cmdgen.getNextVarBinds(x)[1] def getCmd(snmpEngine, authData, transportTarget, contextData, *varBinds, **options): """Performs SNMP GET query. Based on passed parameters, prepares SNMP GET packet (:RFC:`1905#section-4.2.1`) and schedules its transmission by :mod:`twisted` I/O framework at a later point of time. Parameters ---------- snmpEngine : :class:`~pysnmp.hlapi.SnmpEngine` Class instance representing SNMP engine. authData : :class:`~pysnmp.hlapi.CommunityData` or :class:`~pysnmp.hlapi.UsmUserData`