many backward-compatibility aids dropped
parent
f38ae966c0
commit
0a29dd1f35
|
@ -8,6 +8,10 @@ Revision 5.0.0, released 2018-03-??
|
|||
- By switching to pysnmpcrypto, pysnmp effectively migrates from
|
||||
PyCryptodomex to pyca/cryptography whenever available on the
|
||||
platform.
|
||||
- Many really old backward-compatibility code snippets removed.
|
||||
Most importantly, the `pysnmp.entity.rfc3413.oneliner` and
|
||||
everything related to (non-standard) UNIX domain socket transport
|
||||
are gone.
|
||||
|
||||
Revision 4.4.4, released 2018-01-03
|
||||
-----------------------------------
|
||||
|
|
|
@ -20,7 +20,7 @@ with Command Generators - UDP over IPv4 and UDP over IPv6.
|
|||
|
||||
"""#
|
||||
from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6
|
||||
from pyasn1.codec.ber import encoder, decoder
|
||||
from pysnmp.proto import api
|
||||
import time, bisect
|
||||
|
@ -150,11 +150,6 @@ transportDispatcher.registerTransport(
|
|||
udp6.domainName, udp6.Udp6SocketTransport().openServerMode(('::1', 161))
|
||||
)
|
||||
|
||||
## Local domain socket
|
||||
# transportDispatcher.registerTransport(
|
||||
# unix.domainName, unix.UnixSocketTransport().openServerMode('/tmp/snmp-agent')
|
||||
# )
|
||||
|
||||
transportDispatcher.jobStarted(1)
|
||||
|
||||
try:
|
||||
|
|
|
@ -23,7 +23,7 @@ The following Net-SNMP commands will produce similar SNMP notification:
|
|||
|
||||
"""#
|
||||
from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6
|
||||
from pyasn1.codec.ber import encoder
|
||||
from pysnmp.proto import api
|
||||
|
||||
|
@ -64,14 +64,6 @@ transportDispatcher.sendMessage(
|
|||
encoder.encode(trapMsg), udp6.domainName, ('::1', 162)
|
||||
)
|
||||
|
||||
## Local domain socket
|
||||
# transportDispatcher.registerTransport(
|
||||
# unix.domainName, unix.UnixSocketTransport().openClientMode()
|
||||
# )
|
||||
# transportDispatcher.sendMessage(
|
||||
# encoder.encode(trapMsg), unix.domainName, '/tmp/snmp-manager'
|
||||
# )
|
||||
|
||||
# Dispatcher will finish as all scheduled messages are sent
|
||||
transportDispatcher.runDispatcher()
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ This script performs similar to the following Net-SNMP command:
|
|||
|
||||
"""#
|
||||
from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6
|
||||
from pyasn1.codec.ber import encoder, decoder
|
||||
from pysnmp.proto import api
|
||||
from time import time
|
||||
|
@ -92,17 +92,6 @@ transportDispatcher.jobStarted(1)
|
|||
# )
|
||||
# transportDispatcher.jobStarted(1)
|
||||
|
||||
## Local domain socket
|
||||
# transportDispatcher.registerTransport(
|
||||
# unix.domainName, unix.UnixSocketTransport().openClientMode()
|
||||
# )
|
||||
#
|
||||
# Pass message to dispatcher
|
||||
# transportDispatcher.sendMessage(
|
||||
# encoder.encode(reqMsg), unix.domainName, '/tmp/snmp-agent'
|
||||
# )
|
||||
# transportDispatcher.jobStarted(1)
|
||||
|
||||
# Dispatcher will finish as job#1 counter reaches zero
|
||||
transportDispatcher.runDispatcher()
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ with Notification Originators - UDP over IPv4 and UDP over IPv6.
|
|||
|
||||
"""#
|
||||
from pysnmp.carrier.asyncore.dispatch import AsyncoreDispatcher
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6
|
||||
from pyasn1.codec.ber import decoder
|
||||
from pysnmp.proto import api
|
||||
|
||||
|
@ -73,11 +73,6 @@ transportDispatcher.registerTransport(
|
|||
udp6.domainName, udp6.Udp6SocketTransport().openServerMode(('::1', 162))
|
||||
)
|
||||
|
||||
## Local domain socket
|
||||
# transportDispatcher.registerTransport(
|
||||
# unix.domainName, unix.UnixSocketTransport().openServerMode('/tmp/snmp-manager')
|
||||
# )
|
||||
|
||||
transportDispatcher.jobStarted(1)
|
||||
|
||||
try:
|
||||
|
|
|
@ -1,5 +1,2 @@
|
|||
# http://www.python.org/dev/peps/pep-0396/
|
||||
__version__ = '5.0.0'
|
||||
# backward compatibility
|
||||
version = tuple([int(x) for x in __version__.split('.')])
|
||||
majorVersionId = version[0]
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
#
|
||||
# This file is part of pysnmp software.
|
||||
#
|
||||
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
|
||||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
import os
|
||||
import random
|
||||
|
||||
try:
|
||||
from socket import AF_UNIX
|
||||
except ImportError:
|
||||
AF_UNIX = None
|
||||
from pysnmp.carrier.base import AbstractTransportAddress
|
||||
from pysnmp.carrier.asyncore.dgram.base import DgramSocketTransport
|
||||
|
||||
domainName = snmpLocalDomain = (1, 3, 6, 1, 2, 1, 100, 1, 13)
|
||||
|
||||
random.seed()
|
||||
|
||||
|
||||
class UnixTransportAddress(str, AbstractTransportAddress):
|
||||
pass
|
||||
|
||||
|
||||
class UnixSocketTransport(DgramSocketTransport):
|
||||
sockFamily = AF_UNIX
|
||||
addressType = UnixTransportAddress
|
||||
_iface = ''
|
||||
|
||||
def openClientMode(self, iface=None):
|
||||
if iface is None:
|
||||
# UNIX domain sockets must be explicitly bound
|
||||
iface = ''
|
||||
while len(iface) < 8:
|
||||
iface += chr(random.randrange(65, 91))
|
||||
iface += chr(random.randrange(97, 123))
|
||||
iface = os.path.sep + 'tmp' + os.path.sep + 'pysnmp' + iface
|
||||
if os.path.exists(iface):
|
||||
os.remove(iface)
|
||||
DgramSocketTransport.openClientMode(self, iface)
|
||||
self._iface = iface
|
||||
return self
|
||||
|
||||
def openServerMode(self, iface):
|
||||
DgramSocketTransport.openServerMode(self, iface)
|
||||
self._iface = iface
|
||||
return self
|
||||
|
||||
def closeTransport(self):
|
||||
DgramSocketTransport.closeTransport(self)
|
||||
try:
|
||||
os.remove(self._iface)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
UnixTransport = UnixSocketTransport
|
||||
|
||||
# Compatibility stub
|
||||
UnixDgramSocketTransport = UnixSocketTransport
|
|
@ -1,7 +0,0 @@
|
|||
#
|
||||
# This file is part of pysnmp software.
|
||||
#
|
||||
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
|
||||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
from pysnmp.carrier.asyncore.dgram.unix import *
|
|
@ -1,46 +0,0 @@
|
|||
#
|
||||
# This file is part of pysnmp software.
|
||||
#
|
||||
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
|
||||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
import sys
|
||||
from twisted.internet import reactor
|
||||
from pysnmp.carrier.base import AbstractTransportAddress
|
||||
from pysnmp.carrier.twisted.dgram.base import DgramTwistedTransport
|
||||
from pysnmp.carrier import error
|
||||
|
||||
domainName = snmpLocalDomain = (1, 3, 6, 1, 2, 1, 100, 1, 13)
|
||||
|
||||
class UnixTransportAddress(str, AbstractTransportAddress):
|
||||
pass
|
||||
|
||||
class UnixTwistedTransport(DgramTwistedTransport):
|
||||
addressType = UnixTransportAddress
|
||||
_lport = None
|
||||
|
||||
# AbstractTwistedTransport API
|
||||
|
||||
def openClientMode(self, iface=''):
|
||||
try:
|
||||
self._lport = reactor.connectUNIXDatagram(iface, self)
|
||||
except Exception:
|
||||
raise error.CarrierError(sys.exc_info()[1])
|
||||
return self
|
||||
|
||||
def openServerMode(self, iface):
|
||||
try:
|
||||
self._lport = reactor.listenUNIXDatagram(iface, self)
|
||||
except Exception:
|
||||
raise error.CarrierError(sys.exc_info()[1])
|
||||
|
||||
return self
|
||||
|
||||
def closeTransport(self):
|
||||
if self._lport is not None:
|
||||
d = self._lport.stopListening()
|
||||
if d:
|
||||
d.addCallback(lambda x: None)
|
||||
DgramTwistedTransport.closeTransport(self)
|
||||
|
||||
UnixTransport = UnixTwistedTransport
|
|
@ -5,7 +5,7 @@
|
|||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
from pyasn1.compat.octets import null
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6
|
||||
from pysnmp.proto.secmod.rfc3414.auth import hmacmd5, hmacsha, noauth
|
||||
from pysnmp.proto.secmod.rfc3414.priv import des, nopriv
|
||||
from pysnmp.proto.secmod.rfc3826.priv import aes
|
||||
|
@ -19,7 +19,6 @@ from pysnmp import error
|
|||
# Transports
|
||||
snmpUDPDomain = udp.snmpUDPDomain
|
||||
snmpUDP6Domain = udp6.snmpUDP6Domain
|
||||
snmpLocalDomain = unix.snmpLocalDomain
|
||||
|
||||
# Auth protocol
|
||||
usmHMACMD5AuthProtocol = hmacmd5.HmacMd5.serviceID
|
||||
|
@ -129,15 +128,11 @@ def addV3User(snmpEngine, userName,
|
|||
authProtocol=usmNoAuthProtocol, authKey=None,
|
||||
privProtocol=usmNoPrivProtocol, privKey=None,
|
||||
securityEngineId=None,
|
||||
securityName=None,
|
||||
# deprecated parameters follow
|
||||
contextEngineId=None):
|
||||
securityName=None):
|
||||
mibBuilder = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder
|
||||
|
||||
if securityName is None:
|
||||
securityName = userName
|
||||
if securityEngineId is None: # backward compatibility
|
||||
securityEngineId = contextEngineId
|
||||
(snmpEngineID, usmUserEntry, tblIdx1,
|
||||
pysnmpUsmSecretEntry, tblIdx2) = __cookV3UserInfo(snmpEngine, userName, securityEngineId)
|
||||
|
||||
|
@ -203,11 +198,7 @@ def addV3User(snmpEngine, userName,
|
|||
|
||||
def delV3User(snmpEngine,
|
||||
userName,
|
||||
securityEngineId=None,
|
||||
# deprecated parameters follow
|
||||
contextEngineId=None):
|
||||
if securityEngineId is None: # backward compatibility
|
||||
securityEngineId = contextEngineId
|
||||
securityEngineId=None):
|
||||
(snmpEngineID, usmUserEntry, tblIdx1, pysnmpUsmSecretEntry,
|
||||
tblIdx2) = __cookV3UserInfo(snmpEngine, userName, securityEngineId)
|
||||
snmpEngine.msgAndPduDsp.mibInstrumController.writeVars(
|
||||
|
@ -558,40 +549,6 @@ def delVacmUser(snmpEngine, securityModel, securityName, securityLevel,
|
|||
)
|
||||
|
||||
|
||||
# Obsolete shortcuts for add/delVacmUser() wrappers
|
||||
|
||||
def addRoUser(snmpEngine, securityModel, securityName, securityLevel, subTree):
|
||||
addVacmUser(snmpEngine, securityModel, securityName,
|
||||
securityLevel, subTree)
|
||||
|
||||
|
||||
def delRoUser(snmpEngine, securityModel, securityName, securityLevel, subTree):
|
||||
delVacmUser(snmpEngine, securityModel, securityName, securityLevel,
|
||||
subTree)
|
||||
|
||||
|
||||
def addRwUser(snmpEngine, securityModel, securityName, securityLevel, subTree):
|
||||
addVacmUser(snmpEngine, securityModel, securityName, securityLevel,
|
||||
subTree, subTree)
|
||||
|
||||
|
||||
def delRwUser(snmpEngine, securityModel, securityName, securityLevel, subTree):
|
||||
delVacmUser(snmpEngine, securityModel, securityName, securityLevel,
|
||||
subTree, subTree)
|
||||
|
||||
|
||||
def addTrapUser(snmpEngine, securityModel, securityName,
|
||||
securityLevel, subTree):
|
||||
addVacmUser(snmpEngine, securityModel, securityName, securityLevel,
|
||||
(), (), subTree)
|
||||
|
||||
|
||||
def delTrapUser(snmpEngine, securityModel, securityName,
|
||||
securityLevel, subTree):
|
||||
delVacmUser(snmpEngine, securityModel, securityName, securityLevel,
|
||||
(), (), subTree)
|
||||
|
||||
|
||||
# Notification target setup
|
||||
|
||||
def __cookNotificationTargetInfo(snmpEngine, notificationName, paramsName,
|
||||
|
|
|
@ -205,10 +205,6 @@ class CommandGenerator(object):
|
|||
return sendRequestHandle
|
||||
|
||||
|
||||
# backward compatibility stub
|
||||
CommandGeneratorBase = CommandGenerator
|
||||
|
||||
|
||||
class GetCommandGenerator(CommandGenerator):
|
||||
def processResponseVarBinds(self, snmpEngine, sendRequestHandle,
|
||||
errorIndication, PDU, cbCtx):
|
||||
|
@ -410,38 +406,3 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun):
|
|||
sendRequestHandle, statusInformation))
|
||||
cbFun(snmpEngine, sendRequestHandle,
|
||||
statusInformation['errorIndication'], 0, 0, (), cbCtx)
|
||||
|
||||
|
||||
#
|
||||
# Obsolete, compatibility interfaces.
|
||||
#
|
||||
|
||||
def __sendReqCbFun(snmpEngine, sendRequestHandle, errorIndication,
|
||||
errorStatus, errorIndex, varBinds, cbCtx):
|
||||
cbFun, cbCtx = cbCtx
|
||||
return cbFun(sendRequestHandle, errorIndication, errorStatus,
|
||||
errorIndex, varBinds, cbCtx)
|
||||
|
||||
|
||||
def _sendReq(self, snmpEngine, targetName, varBinds, cbFun,
|
||||
cbCtx=None, contextEngineId=None, contextName=''):
|
||||
return self.sendVarBinds(snmpEngine, targetName, contextEngineId,
|
||||
contextName, varBinds, __sendReqCbFun,
|
||||
(cbFun, cbCtx))
|
||||
|
||||
|
||||
def _sendBulkReq(self, snmpEngine, targetName, nonRepeaters, maxRepetitions,
|
||||
varBinds, cbFun, cbCtx=None, contextEngineId=None,
|
||||
contextName=''):
|
||||
return self.sendVarBinds(snmpEngine, targetName, contextEngineId,
|
||||
contextName, nonRepeaters, maxRepetitions,
|
||||
varBinds, __sendReqCbFun, (cbFun, cbCtx))
|
||||
|
||||
|
||||
# install compatibility wrappers
|
||||
GetCommandGenerator.sendReq = _sendReq
|
||||
SetCommandGenerator.sendReq = _sendReq
|
||||
NextCommandGenerator.sendReq = _sendReq
|
||||
NextCommandGeneratorSingleRun.sendReq = _sendReq
|
||||
BulkCommandGenerator.sendReq = _sendBulkReq
|
||||
BulkCommandGeneratorSingleRun.sendReq = _sendBulkReq
|
||||
|
|
|
@ -52,9 +52,6 @@ class CommandResponderBase(object):
|
|||
|
||||
self.sendPdu(snmpEngine, stateReference, PDU)
|
||||
|
||||
# backward compatibility
|
||||
sendRsp = sendVarBinds
|
||||
|
||||
def sendPdu(self, snmpEngine, stateReference, PDU):
|
||||
(messageProcessingModel, securityModel, securityName,
|
||||
securityLevel, contextEngineId, contextName,
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
#
|
||||
# This file is part of pysnmp software.
|
||||
#
|
||||
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
|
||||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
# THESE FUNCTIONS ARE OBSOLETE AND MUST NOT BE USED!
|
||||
# USE pysnmp.entity.rfc3413.oneliner.mibvar INSTEAD
|
||||
#
|
||||
from pyasn1.type import univ
|
||||
from pysnmp.smi.error import NoSuchObjectError
|
||||
|
||||
|
||||
# Name
|
||||
|
||||
def mibNameToOid(mibView, name):
|
||||
if isinstance(name[0], tuple):
|
||||
f = lambda x='', y='': (x, y)
|
||||
modName, symName = f(*name[0])
|
||||
if modName: # load module if needed
|
||||
mibView.mibBuilder.loadModules(modName)
|
||||
else:
|
||||
mibView.mibBuilder.loadModules() # load all (slow)
|
||||
if symName:
|
||||
oid, label, suffix = mibView.getNodeNameByDesc(symName, modName)
|
||||
else:
|
||||
oid, label, suffix = mibView.getFirstNodeName(modName)
|
||||
suffix = name[1:]
|
||||
modName, symName, _s = mibView.getNodeLocation(oid)
|
||||
mibNode, = mibView.mibBuilder.importSymbols(
|
||||
modName, symName
|
||||
)
|
||||
if hasattr(mibNode, 'createTest'): # table column XXX
|
||||
modName, symName, _s = mibView.getNodeLocation(oid[:-1])
|
||||
rowNode, = mibView.mibBuilder.importSymbols(modName, symName)
|
||||
return oid, rowNode.getInstIdFromIndices(*suffix)
|
||||
else: # scalar or incomplete spec
|
||||
return oid, suffix
|
||||
elif not isinstance(name, tuple):
|
||||
name = tuple(univ.ObjectIdentifier(name))
|
||||
|
||||
oid, label, suffix = mibView.getNodeNameByOid(name)
|
||||
|
||||
return oid, suffix
|
||||
|
||||
|
||||
__scalarSuffix = (univ.Integer(0),)
|
||||
|
||||
|
||||
def oidToMibName(mibView, oid):
|
||||
if not isinstance(oid, tuple):
|
||||
oid = tuple(univ.ObjectIdentifier(oid))
|
||||
_oid, label, suffix = mibView.getNodeNameByOid(oid)
|
||||
modName, symName, __suffix = mibView.getNodeLocation(_oid)
|
||||
mibNode, = mibView.mibBuilder.importSymbols(
|
||||
modName, symName
|
||||
)
|
||||
if hasattr(mibNode, 'createTest'): # table column
|
||||
__modName, __symName, __s = mibView.getNodeLocation(_oid[:-1])
|
||||
rowNode, = mibView.mibBuilder.importSymbols(__modName, __symName)
|
||||
return (symName, modName), rowNode.getIndicesFromInstId(suffix)
|
||||
elif not suffix: # scalar
|
||||
return (symName, modName), suffix
|
||||
elif suffix == (0,): # scalar
|
||||
return (symName, modName), __scalarSuffix
|
||||
else:
|
||||
raise NoSuchObjectError(
|
||||
str='No MIB registered that defines %s object, closest known parent is %s (%s::%s)' % (
|
||||
univ.ObjectIdentifier(oid), univ.ObjectIdentifier(mibNode.name), modName, symName)
|
||||
)
|
||||
|
||||
|
||||
# Value
|
||||
|
||||
def cloneFromMibValue(mibView, modName, symName, value):
|
||||
mibNode, = mibView.mibBuilder.importSymbols(
|
||||
modName, symName
|
||||
)
|
||||
if hasattr(mibNode, 'syntax'): # scalar
|
||||
return mibNode.syntax.clone(value)
|
||||
else:
|
||||
return # identifier
|
|
@ -333,66 +333,5 @@ class NotificationOriginator(object):
|
|||
|
||||
return notificationHandle
|
||||
|
||||
|
||||
#
|
||||
# Obsolete, compatibility interfaces.
|
||||
#
|
||||
|
||||
def _sendNotificationCbFun(snmpEngine, sendRequestHandle, errorIndication,
|
||||
errorStatus, errorIndex, varBinds, cbCtx):
|
||||
cbFun, cbCtx = cbCtx
|
||||
|
||||
try:
|
||||
# we need to pass response PDU information to user for INFORMs
|
||||
cbFun(sendRequestHandle, errorIndication,
|
||||
errorStatus, errorIndex, varBinds, cbCtx)
|
||||
except TypeError:
|
||||
# a backward compatible way of calling user function
|
||||
cbFun(sendRequestHandle, errorIndication, cbCtx)
|
||||
|
||||
|
||||
def _sendNotification(self, snmpEngine, notificationTarget, notificationName,
|
||||
additionalVarBinds=(), cbFun=None, cbCtx=None,
|
||||
contextName=null, instanceIndex=None):
|
||||
if self.snmpContext is None:
|
||||
raise error.ProtocolError('SNMP context not specified')
|
||||
|
||||
#
|
||||
# Here we first expand trap OID into associated OBJECTS
|
||||
# and then look them up at context-specific MIB
|
||||
#
|
||||
|
||||
mibViewController = snmpEngine.getUserContext('mibViewController')
|
||||
if not mibViewController:
|
||||
mibViewController = view.MibViewController(snmpEngine.getMibBuilder())
|
||||
snmpEngine.setUserContext(mibViewController=mibViewController)
|
||||
|
||||
# Support the following syntax:
|
||||
# '1.2.3.4'
|
||||
# (1,2,3,4)
|
||||
# ('MIB', 'symbol')
|
||||
if isinstance(notificationName, (tuple, list)) and \
|
||||
notificationName and isinstance(notificationName[0], str):
|
||||
notificationName = rfc1902.ObjectIdentity(*notificationName)
|
||||
else:
|
||||
notificationName = rfc1902.ObjectIdentity(notificationName)
|
||||
|
||||
varBinds = rfc1902.NotificationType(notificationName,
|
||||
instanceIndex=instanceIndex)
|
||||
varBinds.resolveWithMib(mibViewController)
|
||||
|
||||
mibInstrumController = self.snmpContext.getMibInstrum(contextName)
|
||||
|
||||
varBinds = varBinds[:1] + mibInstrumController.readVars(varBinds[1:])
|
||||
|
||||
return self.sendVarBinds(snmpEngine, notificationTarget,
|
||||
self.snmpContext.contextEngineId,
|
||||
contextName, varBinds + list(additionalVarBinds),
|
||||
_sendNotificationCbFun, (cbFun, cbCtx))
|
||||
|
||||
|
||||
# install compatibility wrapper
|
||||
NotificationOriginator.sendNotification = _sendNotification
|
||||
|
||||
# XXX
|
||||
# move/group/implement config setting/retrieval at a stand-alone module
|
||||
|
|
|
@ -23,7 +23,6 @@ class NotificationReceiver(object):
|
|||
)
|
||||
|
||||
self.__snmpTrapCommunity = ''
|
||||
self.__cbFunVer = 0
|
||||
self.__cbFun = cbFun
|
||||
self.__cbCtx = cbCtx
|
||||
|
||||
|
@ -101,15 +100,5 @@ class NotificationReceiver(object):
|
|||
'processPdu: stateReference %s, user cbFun %s, cbCtx %s, varBinds %s' % (
|
||||
stateReference, self.__cbFun, self.__cbCtx, varBinds))
|
||||
|
||||
if self.__cbFunVer:
|
||||
self.__cbFun(snmpEngine, stateReference, contextEngineId,
|
||||
contextName, varBinds, self.__cbCtx)
|
||||
else:
|
||||
# Compatibility stub (handle legacy cbFun interface)
|
||||
try:
|
||||
self.__cbFun(snmpEngine, contextEngineId, contextName,
|
||||
varBinds, self.__cbCtx)
|
||||
except TypeError:
|
||||
self.__cbFunVer = 1
|
||||
self.__cbFun(snmpEngine, stateReference, contextEngineId,
|
||||
contextName, varBinds, self.__cbCtx)
|
||||
self.__cbFun(snmpEngine, stateReference, contextEngineId,
|
||||
contextName, varBinds, self.__cbCtx)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
# This file is necessary to make this directory a package.
|
|
@ -1,254 +0,0 @@
|
|||
#
|
||||
# This file is part of pysnmp software.
|
||||
#
|
||||
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
|
||||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
# All code in this file belongs to obsolete, compatibility wrappers.
|
||||
# Never use interfaces below for new applications!
|
||||
#
|
||||
from pysnmp.hlapi.asyncore import *
|
||||
from pysnmp.hlapi.asyncore import sync
|
||||
from pysnmp.hlapi.varbinds import *
|
||||
from pysnmp.hlapi.lcd import *
|
||||
from pyasn1.compat.octets import null
|
||||
from pyasn1.type import univ
|
||||
|
||||
__all__ = ['AsynCommandGenerator', 'CommandGenerator', 'MibVariable']
|
||||
|
||||
MibVariable = ObjectIdentity
|
||||
|
||||
|
||||
class AsynCommandGenerator(object):
|
||||
_null = univ.Null('')
|
||||
|
||||
vbProcessor = CommandGeneratorVarBinds()
|
||||
lcd = CommandGeneratorLcdConfigurator()
|
||||
|
||||
def __init__(self, snmpEngine=None):
|
||||
if snmpEngine is None:
|
||||
self.snmpEngine = SnmpEngine()
|
||||
else:
|
||||
self.snmpEngine = snmpEngine
|
||||
|
||||
self.mibViewController = self.vbProcessor.getMibViewController(self.snmpEngine)
|
||||
|
||||
def __del__(self):
|
||||
self.lcd.unconfigure(self.snmpEngine)
|
||||
|
||||
def cfgCmdGen(self, authData, transportTarget):
|
||||
return self.lcd.configure(self.snmpEngine, authData, transportTarget)
|
||||
|
||||
def uncfgCmdGen(self, authData=None):
|
||||
return self.lcd.unconfigure(self.snmpEngine, authData)
|
||||
|
||||
# compatibility stub
|
||||
def makeReadVarBinds(self, varNames):
|
||||
return self.makeVarBinds([(x, self._null) for x in varNames])
|
||||
|
||||
def makeVarBinds(self, varBinds):
|
||||
return self.vbProcessor.makeVarBinds(self.snmpEngine, varBinds)
|
||||
|
||||
def unmakeVarBinds(self, varBinds, lookupNames, lookupValues):
|
||||
return self.vbProcessor.unmakeVarBinds(
|
||||
self.snmpEngine, varBinds, lookupNames or lookupValues
|
||||
)
|
||||
|
||||
def getCmd(self, authData, transportTarget, varNames, cbInfo,
|
||||
lookupNames=False, lookupValues=False,
|
||||
contextEngineId=None, contextName=null):
|
||||
|
||||
def __cbFun(snmpEngine, sendRequestHandle,
|
||||
errorIndication, errorStatus, errorIndex,
|
||||
varBindTable, cbInfo):
|
||||
cbFun, cbCtx = cbInfo
|
||||
cbFun(sendRequestHandle,
|
||||
errorIndication, errorStatus, errorIndex,
|
||||
varBindTable, cbCtx)
|
||||
|
||||
# for backward compatibility
|
||||
if contextName is null and authData.contextName:
|
||||
contextName = authData.contextName
|
||||
|
||||
return getCmd(
|
||||
self.snmpEngine, authData, transportTarget,
|
||||
ContextData(contextEngineId, contextName),
|
||||
*[(x, self._null) for x in varNames],
|
||||
**dict(cbFun=__cbFun, cbCtx=cbInfo,
|
||||
lookupMib=lookupNames or lookupValues)
|
||||
)
|
||||
|
||||
asyncGetCmd = getCmd
|
||||
|
||||
def setCmd(self, authData, transportTarget, varBinds, cbInfo,
|
||||
lookupNames=False, lookupValues=False,
|
||||
contextEngineId=None, contextName=null):
|
||||
|
||||
def __cbFun(snmpEngine, sendRequestHandle,
|
||||
errorIndication, errorStatus, errorIndex,
|
||||
varBindTable, cbInfo):
|
||||
cbFun, cbCtx = cbInfo
|
||||
cbFun(sendRequestHandle,
|
||||
errorIndication, errorStatus, errorIndex,
|
||||
varBindTable, cbCtx)
|
||||
|
||||
# for backward compatibility
|
||||
if contextName is null and authData.contextName:
|
||||
contextName = authData.contextName
|
||||
|
||||
return setCmd(
|
||||
self.snmpEngine, authData, transportTarget,
|
||||
ContextData(contextEngineId, contextName), *varBinds,
|
||||
**dict(cbFun=__cbFun, cbCtx=cbInfo,
|
||||
lookupMib=lookupNames or lookupValues)
|
||||
)
|
||||
|
||||
asyncSetCmd = setCmd
|
||||
|
||||
def nextCmd(self, authData, transportTarget, varNames, cbInfo,
|
||||
lookupNames=False, lookupValues=False,
|
||||
contextEngineId=None, contextName=null):
|
||||
|
||||
def __cbFun(snmpEngine, sendRequestHandle,
|
||||
errorIndication, errorStatus, errorIndex,
|
||||
varBindTable, cbInfo):
|
||||
cbFun, cbCtx = cbInfo
|
||||
return cbFun(sendRequestHandle,
|
||||
errorIndication, errorStatus, errorIndex,
|
||||
varBindTable, cbCtx)
|
||||
|
||||
# for backward compatibility
|
||||
if contextName is null and authData.contextName:
|
||||
contextName = authData.contextName
|
||||
|
||||
return nextCmd(
|
||||
self.snmpEngine, authData, transportTarget,
|
||||
ContextData(contextEngineId, contextName),
|
||||
*[(x, self._null) for x in varNames],
|
||||
**dict(cbFun=__cbFun, cbCtx=cbInfo,
|
||||
lookupMib=lookupNames or lookupValues)
|
||||
)
|
||||
|
||||
asyncNextCmd = nextCmd
|
||||
|
||||
def bulkCmd(self, authData, transportTarget,
|
||||
nonRepeaters, maxRepetitions, varNames, cbInfo,
|
||||
lookupNames=False, lookupValues=False,
|
||||
contextEngineId=None, contextName=null):
|
||||
|
||||
def __cbFun(snmpEngine, sendRequestHandle,
|
||||
errorIndication, errorStatus, errorIndex,
|
||||
varBindTable, cbInfo):
|
||||
cbFun, cbCtx = cbInfo
|
||||
return cbFun(sendRequestHandle,
|
||||
errorIndication, errorStatus, errorIndex,
|
||||
varBindTable, cbCtx)
|
||||
|
||||
# for backward compatibility
|
||||
if contextName is null and authData.contextName:
|
||||
contextName = authData.contextName
|
||||
|
||||
return bulkCmd(
|
||||
self.snmpEngine, authData, transportTarget,
|
||||
ContextData(contextEngineId, contextName),
|
||||
nonRepeaters, maxRepetitions,
|
||||
*[(x, self._null) for x in varNames],
|
||||
**dict(cbFun=__cbFun, cbCtx=cbInfo,
|
||||
lookupMib=lookupNames or lookupValues)
|
||||
)
|
||||
|
||||
asyncBulkCmd = bulkCmd
|
||||
|
||||
|
||||
class CommandGenerator(object):
|
||||
_null = univ.Null('')
|
||||
|
||||
def __init__(self, snmpEngine=None, asynCmdGen=None):
|
||||
# compatibility attributes
|
||||
self.snmpEngine = snmpEngine or SnmpEngine()
|
||||
|
||||
def getCmd(self, authData, transportTarget, *varNames, **kwargs):
|
||||
if 'lookupNames' not in kwargs:
|
||||
kwargs['lookupNames'] = False
|
||||
if 'lookupValues' not in kwargs:
|
||||
kwargs['lookupValues'] = False
|
||||
errorIndication, errorStatus, errorIndex, varBinds = None, 0, 0, []
|
||||
for (errorIndication,
|
||||
errorStatus,
|
||||
errorIndex,
|
||||
varBinds) in sync.getCmd(self.snmpEngine, authData, transportTarget,
|
||||
ContextData(kwargs.get('contextEngineId'),
|
||||
kwargs.get('contextName', null)),
|
||||
*[(x, self._null) for x in varNames],
|
||||
**kwargs):
|
||||
break
|
||||
return errorIndication, errorStatus, errorIndex, varBinds
|
||||
|
||||
def setCmd(self, authData, transportTarget, *varBinds, **kwargs):
|
||||
if 'lookupNames' not in kwargs:
|
||||
kwargs['lookupNames'] = False
|
||||
if 'lookupValues' not in kwargs:
|
||||
kwargs['lookupValues'] = False
|
||||
errorIndication, errorStatus, errorIndex, rspVarBinds = None, 0, 0, []
|
||||
for (errorIndication,
|
||||
errorStatus,
|
||||
errorIndex,
|
||||
rspVarBinds) in sync.setCmd(self.snmpEngine, authData, transportTarget,
|
||||
ContextData(kwargs.get('contextEngineId'),
|
||||
kwargs.get('contextName', null)),
|
||||
*varBinds,
|
||||
**kwargs):
|
||||
break
|
||||
|
||||
return errorIndication, errorStatus, errorIndex, rspVarBinds
|
||||
|
||||
def nextCmd(self, authData, transportTarget, *varNames, **kwargs):
|
||||
if 'lookupNames' not in kwargs:
|
||||
kwargs['lookupNames'] = False
|
||||
if 'lookupValues' not in kwargs:
|
||||
kwargs['lookupValues'] = False
|
||||
if 'lexicographicMode' not in kwargs:
|
||||
kwargs['lexicographicMode'] = False
|
||||
errorIndication, errorStatus, errorIndex = None, 0, 0
|
||||
varBindTable = []
|
||||
for (errorIndication,
|
||||
errorStatus,
|
||||
errorIndex,
|
||||
varBinds) in sync.nextCmd(self.snmpEngine, authData, transportTarget,
|
||||
ContextData(kwargs.get('contextEngineId'),
|
||||
kwargs.get('contextName', null)),
|
||||
*[(x, self._null) for x in varNames],
|
||||
**kwargs):
|
||||
if errorIndication or errorStatus:
|
||||
return errorIndication, errorStatus, errorIndex, varBinds
|
||||
|
||||
varBindTable.append(varBinds)
|
||||
|
||||
return errorIndication, errorStatus, errorIndex, varBindTable
|
||||
|
||||
def bulkCmd(self, authData, transportTarget,
|
||||
nonRepeaters, maxRepetitions, *varNames, **kwargs):
|
||||
if 'lookupNames' not in kwargs:
|
||||
kwargs['lookupNames'] = False
|
||||
if 'lookupValues' not in kwargs:
|
||||
kwargs['lookupValues'] = False
|
||||
if 'lexicographicMode' not in kwargs:
|
||||
kwargs['lexicographicMode'] = False
|
||||
errorIndication, errorStatus, errorIndex = None, 0, 0
|
||||
varBindTable = []
|
||||
for (errorIndication,
|
||||
errorStatus,
|
||||
errorIndex,
|
||||
varBinds) in sync.bulkCmd(self.snmpEngine, authData,
|
||||
transportTarget,
|
||||
ContextData(kwargs.get('contextEngineId'),
|
||||
kwargs.get('contextName', null)),
|
||||
nonRepeaters, maxRepetitions,
|
||||
*[(x, self._null) for x in varNames],
|
||||
**kwargs):
|
||||
if errorIndication or errorStatus:
|
||||
return errorIndication, errorStatus, errorIndex, varBinds
|
||||
|
||||
varBindTable.append(varBinds)
|
||||
|
||||
return errorIndication, errorStatus, errorIndex, varBindTable
|
|
@ -1,180 +0,0 @@
|
|||
#
|
||||
# This file is part of pysnmp software.
|
||||
#
|
||||
# Copyright (c) 2005-2018, Ilya Etingof <etingof@gmail.com>
|
||||
# License: http://snmplabs.com/pysnmp/license.html
|
||||
#
|
||||
# All code in this file belongs to obsolete, compatibility wrappers.
|
||||
# Never use interfaces below for new applications!
|
||||
#
|
||||
from pysnmp.hlapi.asyncore import *
|
||||
from pysnmp.hlapi.asyncore import sync
|
||||
from pysnmp.hlapi.varbinds import *
|
||||
from pysnmp.hlapi.lcd import *
|
||||
from pyasn1.compat.octets import null
|
||||
from pysnmp.entity import config
|
||||
from pysnmp.entity.rfc3413 import context
|
||||
|
||||
__all__ = ['AsynNotificationOriginator',
|
||||
'NotificationOriginator',
|
||||
'MibVariable']
|
||||
|
||||
MibVariable = ObjectIdentity
|
||||
|
||||
|
||||
class ErrorIndicationReturn(object):
|
||||
def __init__(self, *vars):
|
||||
self.__vars = vars
|
||||
|
||||
def __getitem__(self, i):
|
||||
return self.__vars[i]
|
||||
|
||||
def __nonzero__(self):
|
||||
return bool(self)
|
||||
|
||||
def __bool__(self):
|
||||
return bool(self.__vars[0])
|
||||
|
||||
def __str__(self):
|
||||
return str(self.__vars[0])
|
||||
|
||||
|
||||
class AsynNotificationOriginator(object):
|
||||
vbProcessor = NotificationOriginatorVarBinds()
|
||||
lcd = NotificationOriginatorLcdConfigurator()
|
||||
|
||||
def __init__(self, snmpEngine=None, snmpContext=None):
|
||||
if snmpEngine is None:
|
||||
self.snmpEngine = snmpEngine = SnmpEngine()
|
||||
else:
|
||||
self.snmpEngine = snmpEngine
|
||||
|
||||
if snmpContext is None:
|
||||
self.snmpContext = context.SnmpContext(self.snmpEngine)
|
||||
config.addContext(
|
||||
self.snmpEngine, '' # this is leaky
|
||||
)
|
||||
else:
|
||||
self.snmpContext = snmpContext
|
||||
|
||||
self.mibViewController = self.vbProcessor.getMibViewController(self.snmpEngine)
|
||||
|
||||
def __del__(self):
|
||||
self.uncfgNtfOrg()
|
||||
|
||||
def cfgNtfOrg(self, authData, transportTarget, notifyType):
|
||||
return self.lcd.configure(
|
||||
self.snmpEngine, authData, transportTarget, notifyType
|
||||
)
|
||||
|
||||
def uncfgNtfOrg(self, authData=None):
|
||||
return self.lcd.unconfigure(self.snmpEngine, authData)
|
||||
|
||||
def makeVarBinds(self, varBinds):
|
||||
return self.vbProcessor.makeVarBinds(
|
||||
self.snmpEngine, varBinds
|
||||
)
|
||||
|
||||
def unmakeVarBinds(self, varBinds, lookupNames, lookupValues):
|
||||
return self.vbProcessor.unmakeVarBinds(
|
||||
self.snmpEngine, varBinds, lookupNames or lookupValues
|
||||
)
|
||||
|
||||
def sendNotification(self, authData, transportTarget,
|
||||
notifyType, notificationType,
|
||||
varBinds=(), # legacy, use NotificationType instead
|
||||
cbInfo=(None, None),
|
||||
lookupNames=False, lookupValues=False,
|
||||
contextEngineId=None, # XXX ordering incompatibility
|
||||
contextName=null):
|
||||
|
||||
def __cbFun(snmpEngine, sendRequestHandle, errorIndication,
|
||||
errorStatus, errorIndex, varBinds, cbCtx):
|
||||
cbFun, cbCtx = cbCtx
|
||||
try:
|
||||
# we need to pass response PDU information to user for INFORMs
|
||||
return cbFun and cbFun(
|
||||
sendRequestHandle,
|
||||
errorIndication,
|
||||
errorStatus, errorIndex,
|
||||
varBinds,
|
||||
cbCtx
|
||||
)
|
||||
except TypeError:
|
||||
# a backward compatible way of calling user function
|
||||
return cbFun(
|
||||
sendRequestHandle,
|
||||
errorIndication,
|
||||
cbCtx
|
||||
)
|
||||
|
||||
# for backward compatibility
|
||||
if contextName is null and authData.contextName:
|
||||
contextName = authData.contextName
|
||||
|
||||
if not isinstance(notificationType,
|
||||
(ObjectIdentity, ObjectType, NotificationType)):
|
||||
if isinstance(notificationType[0], tuple):
|
||||
# legacy
|
||||
notificationType = ObjectIdentity(notificationType[0][0], notificationType[0][1], *notificationType[1:])
|
||||
else:
|
||||
notificationType = ObjectIdentity(notificationType)
|
||||
|
||||
if not isinstance(notificationType, NotificationType):
|
||||
notificationType = NotificationType(notificationType)
|
||||
|
||||
return sendNotification(
|
||||
self.snmpEngine,
|
||||
authData, transportTarget,
|
||||
ContextData(contextEngineId or self.snmpContext.contextEngineId,
|
||||
contextName),
|
||||
notifyType, notificationType.addVarBinds(*varBinds),
|
||||
__cbFun,
|
||||
cbInfo,
|
||||
lookupNames or lookupValues
|
||||
)
|
||||
|
||||
asyncSendNotification = sendNotification
|
||||
|
||||
|
||||
class NotificationOriginator(object):
|
||||
vbProcessor = NotificationOriginatorVarBinds()
|
||||
|
||||
def __init__(self, snmpEngine=None, snmpContext=None, asynNtfOrg=None):
|
||||
# compatibility attributes
|
||||
self.snmpEngine = snmpEngine or SnmpEngine()
|
||||
self.mibViewController = self.vbProcessor.getMibViewController(self.snmpEngine)
|
||||
|
||||
# the varBinds parameter is legacy, use NotificationType instead
|
||||
|
||||
def sendNotification(self, authData, transportTarget, notifyType,
|
||||
notificationType, *varBinds, **kwargs):
|
||||
if 'lookupNames' not in kwargs:
|
||||
kwargs['lookupNames'] = False
|
||||
if 'lookupValues' not in kwargs:
|
||||
kwargs['lookupValues'] = False
|
||||
if not isinstance(notificationType,
|
||||
(ObjectIdentity, ObjectType, NotificationType)):
|
||||
if isinstance(notificationType[0], tuple):
|
||||
# legacy
|
||||
notificationType = ObjectIdentity(notificationType[0][0], notificationType[0][1], *notificationType[1:])
|
||||
else:
|
||||
notificationType = ObjectIdentity(notificationType)
|
||||
|
||||
if not isinstance(notificationType, NotificationType):
|
||||
notificationType = NotificationType(notificationType)
|
||||
|
||||
for (errorIndication,
|
||||
errorStatus,
|
||||
errorIndex,
|
||||
rspVarBinds) in sync.sendNotification(self.snmpEngine, authData,
|
||||
transportTarget,
|
||||
ContextData(kwargs.get('contextEngineId'),
|
||||
kwargs.get('contextName', null)),
|
||||
notifyType,
|
||||
notificationType.addVarBinds(*varBinds),
|
||||
**kwargs):
|
||||
if notifyType == 'inform':
|
||||
return errorIndication, errorStatus, errorIndex, rspVarBinds
|
||||
else:
|
||||
break
|
|
@ -6,11 +6,11 @@
|
|||
#
|
||||
import socket
|
||||
import sys
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6
|
||||
from pysnmp.hlapi.transport import AbstractTransportTarget
|
||||
from pysnmp import error
|
||||
|
||||
__all__ = ['UnixTransportTarget', 'Udp6TransportTarget', 'UdpTransportTarget']
|
||||
__all__ = ['Udp6TransportTarget', 'UdpTransportTarget']
|
||||
|
||||
|
||||
class UdpTransportTarget(AbstractTransportTarget):
|
||||
|
@ -119,8 +119,3 @@ class Udp6TransportTarget(AbstractTransportTarget):
|
|||
except socket.gaierror:
|
||||
raise error.PySnmpError('Bad IPv6/UDP transport address %s: %s' % (
|
||||
'@'.join([str(x) for x in transportAddr]), sys.exc_info()[1]))
|
||||
|
||||
|
||||
class UnixTransportTarget(AbstractTransportTarget):
|
||||
transportDomain = unix.domainName
|
||||
protoTransport = unix.UnixSocketTransport
|
||||
|
|
|
@ -233,9 +233,11 @@ class NotificationOriginatorLcdConfigurator(AbstractLcdConfigurator):
|
|||
cache['auth'][authDataKey] = authDataX, subTree, useCount + 1
|
||||
else:
|
||||
subTree = (1, 3, 6)
|
||||
config.addTrapUser(snmpEngine, authData.securityModel,
|
||||
authData.securityName, authData.securityLevel,
|
||||
subTree)
|
||||
config.addVacmUser(snmpEngine,
|
||||
authData.securityModel,
|
||||
authData.securityName,
|
||||
authData.securityLevel,
|
||||
(), (), subTree)
|
||||
cache['auth'][authDataKey] = authData, subTree, 1
|
||||
|
||||
return notifyName
|
||||
|
|
|
@ -199,9 +199,6 @@ unsupportedSecurityModel = UnsupportedSecurityModel('Unsupported SNMP security m
|
|||
class UnsupportedSecurityLevel(ErrorIndication):
|
||||
pass
|
||||
|
||||
# backward compatibility plug
|
||||
UnsupportedSecLevel = UnsupportedSecurityLevel
|
||||
|
||||
unsupportedSecurityLevel = UnsupportedSecurityLevel('Unsupported SNMP security level')
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import sys
|
|||
from pyasn1.codec.ber import encoder
|
||||
from pyasn1.error import PyAsn1Error
|
||||
from pysnmp.proto.secmod import base
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6, unix
|
||||
from pysnmp.carrier.asyncore.dgram import udp, udp6
|
||||
from pysnmp.smi.error import NoSuchInstanceError
|
||||
from pysnmp.proto import errind, error
|
||||
from pysnmp import debug
|
||||
|
@ -142,8 +142,6 @@ class SnmpV1SecurityModel(base.AbstractSecurityModel):
|
|||
TransportAddressIPv6, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols(
|
||||
'TRANSPORT-ADDRESS-MIB', 'TransportAddressIPv6')
|
||||
targetAddrTAddress = tuple(TransportAddressIPv6(targetAddrTAddress))
|
||||
elif targetAddrTDomain[:len(unix.snmpLocalDomain)] == unix.snmpLocalDomain:
|
||||
targetAddrTAddress = str(targetAddrTAddress)
|
||||
targetAddr = targetAddrTDomain, targetAddrTAddress
|
||||
targetAddrTagList = snmpTargetAddrTagList.getNode(snmpTargetAddrTagList.name + instId).syntax
|
||||
if targetAddr not in self.__transportToTagMap:
|
||||
|
|
|
@ -16,7 +16,7 @@ try:
|
|||
from errno import ENOENT
|
||||
except ImportError:
|
||||
ENOENT = -1
|
||||
from pysnmp import version as pysnmp_version
|
||||
from pysnmp import __version__ as pysnmp_version
|
||||
from pysnmp.smi import error
|
||||
from pysnmp import debug
|
||||
|
||||
|
@ -290,21 +290,6 @@ class MibBuilder(object):
|
|||
def getMibSources(self):
|
||||
return tuple(self.__mibSources)
|
||||
|
||||
# Legacy/compatibility methods (won't work for .eggs)
|
||||
def setMibPath(self, *mibPaths):
|
||||
self.setMibSources(*[DirMibSource(x) for x in mibPaths])
|
||||
|
||||
def getMibPath(self):
|
||||
paths = ()
|
||||
for mibSource in self.getMibSources():
|
||||
if isinstance(mibSource, DirMibSource):
|
||||
paths += (mibSource.fullPath(),)
|
||||
else:
|
||||
raise error.MibLoadError(
|
||||
'MIB source is not a plain directory: %s' % (mibSource,)
|
||||
)
|
||||
return paths
|
||||
|
||||
def loadModule(self, modName, **userCtx):
|
||||
for mibSource in self.__mibSources:
|
||||
debug.logger & debug.flagBld and debug.logger('loadModule: trying %s at %s' % (modName, mibSource))
|
||||
|
|
|
@ -189,8 +189,6 @@ class NotificationType(MibNode):
|
|||
status = 'current'
|
||||
description = ''
|
||||
reference = ''
|
||||
# retained for compatibility
|
||||
revisions = ()
|
||||
|
||||
def getObjects(self):
|
||||
return self.objects
|
||||
|
@ -223,15 +221,6 @@ class NotificationType(MibNode):
|
|||
self.reference = v
|
||||
return self
|
||||
|
||||
# This should not be here. Retained for compatibility.
|
||||
|
||||
def getRevisions(self):
|
||||
return self.revisions
|
||||
|
||||
def setRevisions(self, v):
|
||||
self.revisions = v
|
||||
return self
|
||||
|
||||
def asn1Print(self):
|
||||
return """\
|
||||
NOTIFICATION-TYPE
|
||||
|
|
|
@ -893,9 +893,8 @@ class NotificationType(object):
|
|||
Instances of :py:class:`~pysnmp.smi.rfc1902.NotificationType` class are
|
||||
containers incorporating :py:class:`~pysnmp.smi.rfc1902.ObjectIdentity`
|
||||
class instance (identifying particular notification) and a collection
|
||||
of MIB variables IDs that
|
||||
:py:class:`~pysnmp.entity.rfc3413.oneliner.cmdgen.NotificationOriginator`
|
||||
should gather and put into notification message.
|
||||
of MIB variables IDs that *NotificationOriginator* should gather
|
||||
and put into notification message.
|
||||
|
||||
Typical notification is defined like this (from *IF-MIB.txt*):
|
||||
|
||||
|
|
Loading…
Reference in New Issue