diff options
author | elie <elie> | 2015-10-17 09:54:53 +0000 |
---|---|---|
committer | elie <elie> | 2015-10-17 09:54:53 +0000 |
commit | 71dd5565a4b2948237a87319b57c565e18605761 (patch) | |
tree | 8bec49290752914dba279407b20a4bab26e61af3 /pysnmp/entity | |
parent | cd527959f8b5a98c577c9a431415e4fb67b4df95 (diff) | |
download | pysnmp-git-71dd5565a4b2948237a87319b57c565e18605761.tar.gz |
linted for trailing whitespaces
Diffstat (limited to 'pysnmp/entity')
-rw-r--r-- | pysnmp/entity/config.py | 54 | ||||
-rw-r--r-- | pysnmp/entity/engine.py | 16 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/cmdgen.py | 42 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/cmdrsp.py | 36 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/config.py | 8 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/context.py | 4 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/mibvar.py | 2 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/ntforg.py | 26 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/ntfrcv.py | 8 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/oneliner/cmdgen.py | 9 | ||||
-rw-r--r-- | pysnmp/entity/rfc3413/oneliner/ntforg.py | 6 |
11 files changed, 103 insertions, 108 deletions
diff --git a/pysnmp/entity/config.py b/pysnmp/entity/config.py index f0858846..7b4d1ccf 100644 --- a/pysnmp/entity/config.py +++ b/pysnmp/entity/config.py @@ -30,29 +30,25 @@ usmAesCfb256Protocol = aes256.Aes256.serviceID usmNoPrivProtocol = nopriv.NoPriv.serviceID # Auth services -authServices = { - hmacmd5.HmacMd5.serviceID: hmacmd5.HmacMd5(), - hmacsha.HmacSha.serviceID: hmacsha.HmacSha(), - noauth.NoAuth.serviceID: noauth.NoAuth() - } +authServices = {hmacmd5.HmacMd5.serviceID: hmacmd5.HmacMd5(), + hmacsha.HmacSha.serviceID: hmacsha.HmacSha(), + noauth.NoAuth.serviceID: noauth.NoAuth()} # Privacy services -privServices = { - des.Des.serviceID: des.Des(), - des3.Des3.serviceID: des3.Des3(), - aes.Aes.serviceID: aes.Aes(), - aes192.Aes192.serviceID: aes192.Aes192(), - aes256.Aes256.serviceID: aes256.Aes256(), - nopriv.NoPriv.serviceID: nopriv.NoPriv() - } - +privServices = {des.Des.serviceID: des.Des(), + des3.Des3.serviceID: des3.Des3(), + aes.Aes.serviceID: aes.Aes(), + aes192.Aes192.serviceID: aes192.Aes192(), + aes256.Aes256.serviceID: aes256.Aes256(), + nopriv.NoPriv.serviceID: nopriv.NoPriv()} + def __cookV1SystemInfo(snmpEngine, communityIndex): snmpEngineID, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') snmpCommunityEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-COMMUNITY-MIB', 'snmpCommunityEntry') tblIdx = snmpCommunityEntry.getInstIdFromIndices(communityIndex) return snmpCommunityEntry, tblIdx, snmpEngineID - + def addV1System(snmpEngine, communityIndex, communityName, contextEngineId=None, contextName=None, transportTag=None, securityName=None): @@ -223,7 +219,7 @@ def __cookTargetParamsInfo(snmpEngine, name): snmpTargetParamsEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-TARGET-MIB', 'snmpTargetParamsEntry') tblIdx = snmpTargetParamsEntry.getInstIdFromIndices(name) return snmpTargetParamsEntry, tblIdx - + def addTargetParams( snmpEngine, name, @@ -241,7 +237,7 @@ def addTargetParams( raise error.PySnmpError('Unknown MP model %s' % mpModel) snmpTargetParamsEntry, tblIdx = __cookTargetParamsInfo(snmpEngine, name) - + snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((snmpTargetParamsEntry.name + (7,) + tblIdx, 'destroy'),) ) @@ -271,7 +267,7 @@ def __cookTargetAddrInfo(snmpEngine, addrName): def addTargetAddr( snmpEngine, addrName, - transportDomain, + transportDomain, transportAddress, params, timeout=None, @@ -282,7 +278,7 @@ def addTargetAddr( snmpTargetAddrEntry, snmpSourceAddrEntry, tblIdx = __cookTargetAddrInfo( snmpEngine, addrName ) - + if transportDomain[:len(snmpUDPDomain)] == snmpUDPDomain: SnmpUDPAddress, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMPv2-TM', 'SnmpUDPAddress') transportAddress = SnmpUDPAddress(transportAddress) @@ -321,7 +317,7 @@ def delTargetAddr(snmpEngine, addrName): def addTransport(snmpEngine, transportDomain, transport): if snmpEngine.transportDispatcher: - if not transport.isCompatibleWithDispatcher(snmpEngine.transportDispatcher): + if not transport.isCompatibleWithDispatcher(snmpEngine.transportDispatcher): raise error.PySnmpError('Transport %r is not compatible with dispatcher %r' % (transport, snmpEngine.transportDispatcher)) else: snmpEngine.registerTransportDispatcher( @@ -348,7 +344,7 @@ def getTransport(snmpEngine, transportDomain): return snmpEngine.transportDispatcher.getTransport(transportDomain) except error.PySnmpError: return - + def delTransport(snmpEngine, transportDomain): if not snmpEngine.transportDispatcher: return @@ -431,7 +427,7 @@ def addVacmAccess(snmpEngine, groupName, contextName, securityModel, ) addContext(snmpEngine, contextName) # this is leaky - + snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((vacmAccessEntry.name + (9,) + tblIdx, 'destroy'),) ) @@ -450,7 +446,7 @@ def delVacmAccess(snmpEngine, groupName, contextName, securityModel, securityLevel): vacmAccessEntry, tblIdx = __cookVacmAccessInfo( snmpEngine, groupName, contextName, securityModel, securityLevel - ) + ) snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((vacmAccessEntry.name + (9,) + tblIdx, 'destroy'),) ) @@ -599,7 +595,7 @@ def __cookNotificationTargetInfo(snmpEngine, notificationName, paramsName, ) profileName = '%s-filter' % hash(notificationName) - + if filterSubtree: snmpNotifyFilterEntry, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-NOTIFICATION-MIB', 'snmpNotifyFilterEntry') tblIdx3 = snmpNotifyFilterEntry.getInstIdFromIndices( @@ -620,7 +616,7 @@ def addNotificationTarget(snmpEngine, notificationName, paramsName, snmpNotifyFilterEntry, tblIdx3 ) = __cookNotificationTargetInfo( snmpEngine, notificationName, paramsName, filterSubtree ) - + snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((snmpNotifyEntry.name + (5,) + tblIdx1, 'destroy'),) ) @@ -643,7 +639,7 @@ def addNotificationTarget(snmpEngine, notificationName, paramsName, snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((snmpNotifyFilterEntry.name + (5,) + tblIdx3, 'destroy'),) - ) + ) snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((snmpNotifyFilterEntry.name + (5,) + tblIdx3, 'createAndGo'), (snmpNotifyFilterEntry.name + (1,) + tblIdx3, filterSubtree), @@ -672,12 +668,12 @@ def delNotificationTarget(snmpEngine, notificationName, paramsName, snmpEngine.msgAndPduDsp.mibInstrumController.writeVars( ((snmpNotifyFilterEntry.name + (5,) + tblIdx3, 'destroy'),) - ) - + ) + # rfc3415: A.1 def setInitialVacmParameters(snmpEngine): # rfc3415: A.1.1 --> initial-semi-security-configuration - + # rfc3415: A.1.2 addContext(snmpEngine, "") diff --git a/pysnmp/entity/engine.py b/pysnmp/entity/engine.py index 6a454743..e966b360 100644 --- a/pysnmp/entity/engine.py +++ b/pysnmp/entity/engine.py @@ -18,7 +18,7 @@ __all__ = ['SnmpEngine'] class SnmpEngine: """Creates SNMP engine object. - + SNMP engine object is central in SNMP v3 architecture. It is an umbrella object that coordinates interactions between all parts of SNMP v3 system. See :RFC:`3412#section-2.1` (where it is termed *The Dispatcher*). @@ -27,7 +27,7 @@ class SnmpEngine: v3 operations require an instance of SNMP engine. Users do not normally request services directly from `SnmpEngine`, but pass it around to other PySNMP interfaces. - + It is possible to run multiple instances of `SnmpEngine` in the application. In a multithreaded environment, each thread that works with SNMP must have its own `SnmpEngine` instance. @@ -35,7 +35,7 @@ class SnmpEngine: Parameters ---------- snmpEngineID : :py:class:`~pysnmp.proto.rfc1902.OctetString` - Unique and unambiguous identifier of an SNMP engine. + Unique and unambiguous identifier of an SNMP engine. If not given, `snmpEngineID` is autogenerated and stored on the filesystem. See :RFC:`3411#section-3.1.1` for details. @@ -49,7 +49,7 @@ class SnmpEngine: def __init__(self, snmpEngineID=None, maxMessageSize=65507, msgAndPduDsp=None): self.cache = {} - + self.observer = observer.MetaObserver() if msgAndPduDsp is None: @@ -73,9 +73,9 @@ class SnmpEngine: void.Vacm.accessModelID: void.Vacm(), rfc3415.Vacm.accessModelID: rfc3415.Vacm() } - + self.transportDispatcher = None - + if self.msgAndPduDsp.mibInstrumController is None: raise error.PySnmpError( 'MIB instrumentation does not yet exist' @@ -83,7 +83,7 @@ class SnmpEngine: snmpEngineMaxMessageSize, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineMaxMessageSize') snmpEngineMaxMessageSize.syntax = snmpEngineMaxMessageSize.syntax.clone(maxMessageSize) snmpEngineBoots, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineBoots') - snmpEngineBoots.syntax = snmpEngineBoots.syntax + 1 + snmpEngineBoots.syntax += 1 origSnmpEngineID, = self.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('__SNMP-FRAMEWORK-MIB', 'snmpEngineID') if snmpEngineID is None: @@ -133,7 +133,7 @@ class SnmpEngine: (self.__class__.__name__, self.snmpEngineID) # Transport dispatcher bindings - + def __receiveMessageCbFun( self, transportDispatcher, diff --git a/pysnmp/entity/rfc3413/cmdgen.py b/pysnmp/entity/rfc3413/cmdgen.py index 362dc368..6f61dedb 100644 --- a/pysnmp/entity/rfc3413/cmdgen.py +++ b/pysnmp/entity/rfc3413/cmdgen.py @@ -8,9 +8,9 @@ from pysnmp.proto.error import StatusInformation from pyasn1.type import univ getNextHandle = nextid.Integer(0x7fffffff) - + __null = univ.Null('') - + def getNextVarBinds(varBinds, origVarBinds=None): errorIndication = None idx = nonNulls = len(varBinds) @@ -24,7 +24,7 @@ def getNextVarBinds(varBinds, origVarBinds=None): elif origVarBinds is not None: if v2c.ObjectIdentifier(origVarBinds[idx][0]).asTuple() >= varBinds[idx][0].asTuple(): errorIndication = errind.oidNotIncreasing - + rspVarBinds.insert(0, (varBinds[idx][0], __null)) if not nonNulls: @@ -36,7 +36,7 @@ class CommandGenerator: _null = univ.Null('') def __init__(self): self.__pendingReqs = {} - + def processResponsePdu(self, snmpEngine, messageProcessingModel, @@ -69,7 +69,7 @@ class CommandGenerator: origTimeout, origRetryCount, origRetries ) = self.__pendingReqs.pop(sendPduHandle) - + snmpEngine.transportDispatcher.jobFinished(id(self)) # 3.1.3 @@ -127,7 +127,7 @@ class CommandGenerator: origRetries + 1 ) return - + except StatusInformation: statusInformation = sys.exc_info()[1] debug.logger & debug.flagApp and debug.logger('processResponsePdu: origSendRequestHandle %s, _sendPdu() failed with %r' % (sendPduHandle, statusInformation)) @@ -156,7 +156,7 @@ class CommandGenerator: # User-side API assumes SMIv2 if messageProcessingModel == 0: PDU = rfc2576.v1ToV2(PDU, origPdu) - + # 3.1.2 if v2c.apiPDU.getRequestID(PDU) != v2c.apiPDU.getRequestID(origPdu): debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendPduHandle %s, request-id/response-id mismatch' % sendPduHandle) @@ -210,7 +210,7 @@ class CommandGenerator: pduVersion = 1 sendRequestHandle = getNextHandle() - + # 3.1 sendPduHandle = snmpEngine.msgAndPduDsp.sendPdu( snmpEngine, @@ -247,7 +247,7 @@ class CommandGenerator: retryCount, 0 ) - + debug.logger & debug.flagApp and debug.logger('sendPdu: sendPduHandle %s, timeout %d*10 ms/%d ticks, retry 0 of %d' % (sendPduHandle, timeout, timeoutInTicks, retryCount)) return sendRequestHandle @@ -282,7 +282,7 @@ class GetCommandGenerator(CommandGenerator): cbCtx=None): reqPDU = v2c.GetRequestPDU() v2c.apiPDU.setDefaults(reqPDU) - + v2c.apiPDU.setVarBinds(reqPDU, varBinds) return self.sendPdu(snmpEngine, @@ -320,7 +320,7 @@ class SetCommandGenerator(CommandGenerator): cbCtx=None): reqPDU = v2c.SetRequestPDU() v2c.apiPDU.setDefaults(reqPDU) - + v2c.apiPDU.setVarBinds(reqPDU, varBinds) return self.sendPdu(snmpEngine, @@ -347,7 +347,7 @@ class NextCommandGeneratorSingleRun(CommandGenerator): PDU and v2c.apiPDU.getErrorIndex(PDU, muteErrors=True) or 0, PDU and v2c.apiPDU.getVarBinds(PDU) or (), cbCtx) - + def sendVarBinds(self, snmpEngine, targetName, @@ -367,7 +367,7 @@ class NextCommandGeneratorSingleRun(CommandGenerator): contextName, reqPDU, self.processResponseVarBinds, - (targetName, contextEngineId, contextName, + (targetName, contextEngineId, contextName, reqPDU, cbFun, cbCtx)) class NextCommandGenerator(NextCommandGeneratorSingleRun): @@ -386,7 +386,7 @@ class NextCommandGenerator(NextCommandGeneratorSingleRun): 0, 0, (), cbCtx) return - + varBindTable = v2c.apiPDU.getVarBindTable(reqPDU, PDU) if v2c.apiPDU.getErrorStatus(PDU): @@ -397,13 +397,13 @@ class NextCommandGenerator(NextCommandGeneratorSingleRun): errorIndication, varBinds = getNextVarBinds( varBindTable[-1], v2c.apiPDU.getVarBinds(reqPDU) ) - + if not cbFun(snmpEngine, sendRequestHandle, errorIndication, v2c.apiPDU.getErrorStatus(PDU), v2c.apiPDU.getErrorIndex(PDU, muteErrors=True), - varBindTable, + varBindTable, cbCtx): debug.logger & debug.flagApp and debug.logger('processResponseVarBinds: sendRequestHandle %s, app says to stop walking' % sendRequestHandle) return # app says enough @@ -423,7 +423,7 @@ class NextCommandGenerator(NextCommandGeneratorSingleRun): self.processResponseVarBinds, (targetName, contextEngineId, contextName, reqPDU, cbFun, cbCtx)) - + except StatusInformation: statusInformation = sys.exc_info()[1] debug.logger & debug.flagApp and debug.logger('sendVarBinds: sendPduHandle %s: sendPdu() failed with %r' % (sendRequestHandle, statusInformation)) @@ -462,7 +462,7 @@ class BulkCommandGeneratorSingleRun(CommandGenerator): cbCtx=None): reqPDU = v2c.GetBulkRequestPDU() v2c.apiBulkPDU.setDefaults(reqPDU) - + v2c.apiBulkPDU.setNonRepeaters(reqPDU, nonRepeaters) v2c.apiBulkPDU.setMaxRepetitions(reqPDU, maxRepetitions) @@ -495,7 +495,7 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun): 0, 0, (), cbCtx) return - + varBindTable = v2c.apiBulkPDU.getVarBindTable(reqPDU, PDU) if v2c.apiBulkPDU.getErrorStatus(PDU): @@ -506,7 +506,7 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun): errorIndication, varBinds = getNextVarBinds( varBindTable[-1], v2c.apiPDU.getVarBinds(reqPDU) ) - nonRepeaters = v2c.apiBulkPDU.getNonRepeaters(reqPDU) + nonRepeaters = v2c.apiBulkPDU.getNonRepeaters(reqPDU) if nonRepeaters: varBinds = v2c.apiBulkPDU.getVarBinds(reqPDU)[:int(nonRepeaters)] + varBinds[int(nonRepeaters):] @@ -521,7 +521,7 @@ class BulkCommandGenerator(BulkCommandGeneratorSingleRun): if not varBinds: return # no more objects available - + v2c.apiBulkPDU.setRequestID(reqPDU, v2c.getNextRequestID()) v2c.apiBulkPDU.setVarBinds(reqPDU, varBinds) diff --git a/pysnmp/entity/rfc3413/cmdrsp.py b/pysnmp/entity/rfc3413/cmdrsp.py index 055b36bf..91a8dfbb 100644 --- a/pysnmp/entity/rfc3413/cmdrsp.py +++ b/pysnmp/entity/rfc3413/cmdrsp.py @@ -20,13 +20,13 @@ class CommandResponderBase: def handleMgmtOperation( self, snmpEngine, stateReference, contextName, PDU, acInfo ): pass - + def close(self, snmpEngine): snmpEngine.msgAndPduDsp.unregisterContextEngineId( self.snmpContext.contextEngineId, self.pduTypes ) self.snmpContext = self.__pendingReqs = None - + def sendVarBinds(self, snmpEngine, stateReference, errorStatus, errorIndex, varBinds): ( messageProcessingModel, @@ -46,7 +46,7 @@ class CommandResponderBase: v2c.apiPDU.setVarBinds(PDU, varBinds) debug.logger & debug.flagApp and debug.logger('sendVarBinds: stateReference %s, errorStatus %s, errorIndex %s, varBinds %s' % (stateReference, errorStatus, errorIndex, varBinds)) - + self.sendPdu(snmpEngine, stateReference, PDU) # backward compatibility @@ -68,7 +68,7 @@ class CommandResponderBase: # Agent-side API complies with SMIv2 if messageProcessingModel == 0: PDU = rfc2576.v2ToV1(PDU, origPdu) - + # 3.2.6 try: snmpEngine.msgAndPduDsp.returnResponsePdu( @@ -98,7 +98,7 @@ class CommandResponderBase: def releaseStateInformation(self, stateReference): if stateReference in self.__pendingReqs: del self.__pendingReqs[stateReference] - + def processPdu( self, snmpEngine, @@ -120,19 +120,19 @@ class CommandResponderBase: PDU = rfc2576.v1ToV2(PDU) else: origPdu = None - + # 3.2.1 if PDU.tagSet not in rfc3411.readClassPDUs and \ PDU.tagSet not in rfc3411.writeClassPDUs: raise error.ProtocolError('Unexpected PDU class %s' % PDU.tagSet) - + # 3.2.2 --> no-op # 3.2.4 rspPDU = v2c.apiPDU.getResponse(PDU) - + statusInformation = {} - + self.__pendingReqs[stateReference] = ( messageProcessingModel, securityModel, @@ -152,7 +152,7 @@ class CommandResponderBase: errorStatus, errorIndex = 'noError', 0 debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, varBinds %s' % (stateReference, varBinds)) - + try: self.handleMgmtOperation( snmpEngine, stateReference, @@ -164,7 +164,7 @@ class CommandResponderBase: debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, errorIndication %s' % (stateReference, errorIndication)) if 'oid' in errorIndication: # Request REPORT generation - statusInformation['oid'] = errorIndication['oid'] + statusInformation['oid'] = errorIndication['oid'] statusInformation['val'] = errorIndication['val'] # PDU-level SMI errors @@ -201,13 +201,13 @@ class CommandResponderBase: return else: # successful request processor must release state info return - + self.sendVarBinds( snmpEngine, stateReference, errorStatus, errorIndex, varBinds ) self.releaseStateInformation(stateReference) - + def __verifyAccess(self, name, syntax, idx, viewType, acCtx): snmpEngine = acCtx execCtx = snmpEngine.observer.getExecutionContext( @@ -264,7 +264,7 @@ class CommandResponderBase: self._getNextRequestType == pduType: # This will cause MibTree to skip this OID-value raise pysnmp.smi.error.NoAccessError(name=name, idx=idx) - + class GetCommandResponder(CommandResponderBase): pduTypes = ( rfc1905.GetRequestPDU.tagSet, ) @@ -281,7 +281,7 @@ class GetCommandResponder(CommandResponderBase): ) ) self.releaseStateInformation(stateReference) - + class NextCommandResponder(CommandResponderBase): pduTypes = ( rfc1905.GetNextRequestPDU.tagSet, ) @@ -305,11 +305,11 @@ class NextCommandResponder(CommandResponderBase): else: break self.releaseStateInformation(stateReference) - + class BulkCommandResponder(CommandResponderBase): pduTypes = ( rfc1905.GetBulkRequestPDU.tagSet, ) maxVarBinds = 64 - + # rfc1905: 4.2.3 def handleMgmtOperation( self, snmpEngine, stateReference, contextName, PDU, acInfo @@ -333,7 +333,7 @@ class BulkCommandResponder(CommandResponderBase): debug.logger & debug.flagApp and debug.logger('handleMgmtOperation: N %d, M %d, R %d' % (N, M, R)) mgmtFun = self.snmpContext.getMibInstrum(contextName).readNextVars - + if N: rspVarBinds = mgmtFun(reqVarBinds[:N], (acFun, acCtx)) else: diff --git a/pysnmp/entity/rfc3413/config.py b/pysnmp/entity/rfc3413/config.py index 68218eb6..61a0580c 100644 --- a/pysnmp/entity/rfc3413/config.py +++ b/pysnmp/entity/rfc3413/config.py @@ -25,7 +25,7 @@ def getTargetAddr(snmpEngine, snmpTargetAddrName): snmpTargetAddrTimeout, snmpTargetAddrRetryCount, snmpTargetAddrParams ) = mibBuilder.importSymbols( - 'SNMP-TARGET-MIB', + 'SNMP-TARGET-MIB', 'snmpTargetAddrTDomain', 'snmpTargetAddrTAddress', 'snmpTargetAddrTimeout', @@ -33,7 +33,7 @@ def getTargetAddr(snmpEngine, snmpTargetAddrName): 'snmpTargetAddrParams' ) ( snmpSourceAddrTAddress, ) = mibBuilder.importSymbols( - 'PYSNMP-SOURCE-MIB', + 'PYSNMP-SOURCE-MIB', 'snmpSourceAddrTAddress' ) @@ -113,7 +113,7 @@ def getTargetParams(snmpEngine, paramsName): snmpTargetParamsSecurityModel, snmpTargetParamsSecurityName, snmpTargetParamsSecurityLevel ) = mibBuilder.importSymbols( - 'SNMP-TARGET-MIB', + 'SNMP-TARGET-MIB', 'snmpTargetParamsMPModel', 'snmpTargetParamsSecurityModel', 'snmpTargetParamsSecurityName', @@ -191,7 +191,7 @@ def getNotificationInfo(snmpEngine, notificationTarget): if notificationTarget not in targetToNotifyMap: ( snmpNotifyTag, snmpNotifyType ) = mibBuilder.importSymbols( - 'SNMP-NOTIFICATION-MIB', + 'SNMP-NOTIFICATION-MIB', 'snmpNotifyTag', 'snmpNotifyType' ) diff --git a/pysnmp/entity/rfc3413/context.py b/pysnmp/entity/rfc3413/context.py index d3b8ab10..9a2f12fd 100644 --- a/pysnmp/entity/rfc3413/context.py +++ b/pysnmp/entity/rfc3413/context.py @@ -15,7 +15,7 @@ class SnmpContext: debug.logger & debug.flagIns and debug.logger('SnmpContext: contextEngineId \"%r\"' % (self.contextEngineId,)) self.contextNames = { null: snmpEngine.msgAndPduDsp.mibInstrumController # Default name - } + } def registerContextName(self, contextName, mibInstrum=None): contextName = univ.OctetString(contextName).asOctets() @@ -28,7 +28,7 @@ class SnmpContext: self.contextNames[contextName] = self.contextNames[null] else: self.contextNames[contextName] = mibInstrum - + def unregisterContextName(self, contextName): contextName = univ.OctetString(contextName).asOctets() if contextName in self.contextNames: diff --git a/pysnmp/entity/rfc3413/mibvar.py b/pysnmp/entity/rfc3413/mibvar.py index 4c8132da..969d7ab7 100644 --- a/pysnmp/entity/rfc3413/mibvar.py +++ b/pysnmp/entity/rfc3413/mibvar.py @@ -33,7 +33,7 @@ def mibNameToOid(mibView, name): return oid, suffix elif not isinstance(name, tuple): name = tuple(univ.ObjectIdentifier(name)) - + oid, label, suffix = mibView.getNodeNameByOid(name) return oid, suffix diff --git a/pysnmp/entity/rfc3413/ntforg.py b/pysnmp/entity/rfc3413/ntforg.py index 2426b630..998c62df 100644 --- a/pysnmp/entity/rfc3413/ntforg.py +++ b/pysnmp/entity/rfc3413/ntforg.py @@ -73,7 +73,7 @@ class NotificationOriginator: else: reqPDU = origPdu pduVersion = 1 - + # 3.3.6a try: sendPduHandle = snmpEngine.msgAndPduDsp.sendPdu( @@ -106,7 +106,7 @@ class NotificationOriginator: snmpEngine.transportDispatcher.jobStarted(id(self)) debug.logger & debug.flagApp and debug.logger('processResponsePdu: sendRequestHandle %s, sendPduHandle %s, timeout %d, retry %d of %d' % (sendRequestHandle, sendPduHandle, origTimeout, origRetries, origRetryCount)) - + # 3.3.6b self.__pendingReqs[sendPduHandle] = ( origTransportDomain, @@ -144,7 +144,7 @@ class NotificationOriginator: timeout, retryCount, params ) = config.getTargetAddr(snmpEngine, targetName) - + ( messageProcessingModel, securityModel, securityName, @@ -202,7 +202,7 @@ class NotificationOriginator: retryCount, 1 ) - snmpEngine.transportDispatcher.jobStarted(id(self)) + snmpEngine.transportDispatcher.jobStarted(id(self)) else: snmpEngine.msgAndPduDsp.sendPdu(snmpEngine, transportDomain, @@ -249,7 +249,7 @@ class NotificationOriginator: # # Higher-level API to Notification Originator. Supports multiple # targets, automatic var-binding formation and is fully LCD-driven. - # + # def sendVarBinds(self, snmpEngine, notificationTarget, @@ -263,7 +263,7 @@ class NotificationOriginator: if contextName: __SnmpAdminString, = snmpEngine.msgAndPduDsp.mibInstrumController.mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString') contextName = __SnmpAdminString(contextName) - + # 3.3 ( notifyTag, notifyType ) = config.getNotificationInfo( @@ -340,7 +340,7 @@ class NotificationOriginator: pdu = v2c.InformRequestPDU() else: raise error.ProtocolError('Unknown notify-type %r', notifyType) - + v2c.apiPDU.setDefaults(pdu) v2c.apiPDU.setVarBinds(pdu, varBinds) @@ -352,9 +352,9 @@ class NotificationOriginator: contextName, pdu, self.processResponseVarBinds, - (notificationHandle, + (notificationHandle, cbFun, cbCtx)) - + except error.StatusInformation: statusInformation = sys.exc_info()[1] debug.logger & debug.flagApp and debug.logger('sendVarBinds: sendRequestHandle %s: sendPdu() failed with %r' % (sendRequestHandle, statusInformation)) @@ -391,10 +391,10 @@ def _sendNotificationCbFun(snmpEngine, varBinds, cbCtx): cbFun, cbCtx = cbCtx - + try: # we need to pass response PDU information to user for INFORMs - cbFun(sendRequestHandle, errorIndication, + cbFun(sendRequestHandle, errorIndication, errorStatus, errorIndex, varBinds, cbCtx) except TypeError: # a backward compatible way of calling user function @@ -411,7 +411,7 @@ def _sendNotification(self, 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 @@ -450,7 +450,7 @@ def _sendNotification(self, # install compatibility wrapper NotificationOriginator.sendNotification = _sendNotification - + # XXX # move/group/implement config setting/retrieval at a stand-alone module diff --git a/pysnmp/entity/rfc3413/ntfrcv.py b/pysnmp/entity/rfc3413/ntfrcv.py index a7f38a2e..44065c9b 100644 --- a/pysnmp/entity/rfc3413/ntfrcv.py +++ b/pysnmp/entity/rfc3413/ntfrcv.py @@ -8,7 +8,7 @@ from pysnmp import debug # 3.4 class NotificationReceiver: pduTypes = ( - v1.TrapPDU.tagSet, + v1.TrapPDU.tagSet, v2c.SNMPv2TrapPDU.tagSet, v2c.InformRequestPDU.tagSet ) @@ -53,13 +53,13 @@ class NotificationReceiver: varBinds = v2c.apiPDU.getVarBinds(PDU) debug.logger & debug.flagApp and debug.logger('processPdu: stateReference %s, varBinds %s' % (stateReference, varBinds)) - + # 3.4 if PDU.tagSet in rfc3411.confirmedClassPDUs: # 3.4.1 --> no-op - + rspPDU = v2c.apiPDU.getResponse(PDU) - + # 3.4.2 v2c.apiPDU.setErrorStatus(rspPDU, errorStatus) v2c.apiPDU.setErrorIndex(rspPDU, errorIndex) diff --git a/pysnmp/entity/rfc3413/oneliner/cmdgen.py b/pysnmp/entity/rfc3413/oneliner/cmdgen.py index 9254cf53..63ea6976 100644 --- a/pysnmp/entity/rfc3413/oneliner/cmdgen.py +++ b/pysnmp/entity/rfc3413/oneliner/cmdgen.py @@ -7,7 +7,6 @@ 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 pyasn1.type import univ __all__ = ['AsynCommandGenerator', 'CommandGenerator', 'MibVariable'] @@ -74,7 +73,7 @@ class AsynCommandGenerator: contextName = authData.contextName return getCmd( - self.snmpEngine, + self.snmpEngine, authData, transportTarget, ContextData(contextEngineId, contextName), *[(x, self._null) for x in varNames], @@ -100,12 +99,12 @@ class AsynCommandGenerator: if contextName is null and authData.contextName: contextName = authData.contextName - + return setCmd( self.snmpEngine, authData, transportTarget, ContextData(contextEngineId, contextName), - *varBinds, + *varBinds, **dict(cbFun=__cbFun, cbCtx=cbInfo, lookupMib=lookupNames or lookupValues) ) @@ -157,7 +156,7 @@ class AsynCommandGenerator: contextName = authData.contextName return bulkCmd( - self.snmpEngine, + self.snmpEngine, authData, transportTarget, ContextData(contextEngineId, contextName), nonRepeaters, maxRepetitions, diff --git a/pysnmp/entity/rfc3413/oneliner/ntforg.py b/pysnmp/entity/rfc3413/oneliner/ntforg.py index d2462bd2..675686b6 100644 --- a/pysnmp/entity/rfc3413/oneliner/ntforg.py +++ b/pysnmp/entity/rfc3413/oneliner/ntforg.py @@ -50,7 +50,7 @@ class AsynNotificationOriginator: def uncfgNtfOrg(self, authData=None): return self.lcd.unconfigure(self.snmpEngine, authData) - + def makeVarBinds(self, varBinds): return self.vbProcessor.makeVarBinds( self.snmpEngine, varBinds @@ -61,7 +61,7 @@ class AsynNotificationOriginator: self.snmpEngine, varBinds, lookupNames or lookupValues ) - def sendNotification(self, authData, transportTarget, + def sendNotification(self, authData, transportTarget, notifyType, notificationType, varBinds=(), # legacy, use NotificationType instead cbInfo=(None, None), @@ -106,7 +106,7 @@ class AsynNotificationOriginator: return sendNotification( self.snmpEngine, - authData, transportTarget, + authData, transportTarget, ContextData(contextEngineId or self.snmpContext.contextEngineId, contextName), notifyType, notificationType.addVarBinds(*varBinds), |