summaryrefslogtreecommitdiff
path: root/pysnmp/entity
diff options
context:
space:
mode:
Diffstat (limited to 'pysnmp/entity')
-rw-r--r--pysnmp/entity/config.py1
-rw-r--r--pysnmp/entity/rfc3413/asyncio/__init__.py1
-rw-r--r--pysnmp/entity/rfc3413/asyncio/cmdgen.py91
-rw-r--r--pysnmp/entity/rfc3413/asyncio/ntforg.py68
-rw-r--r--pysnmp/entity/rfc3413/twisted/__init__.py1
-rw-r--r--pysnmp/entity/rfc3413/twisted/cmdgen.py136
-rw-r--r--pysnmp/entity/rfc3413/twisted/ntforg.py75
7 files changed, 1 insertions, 372 deletions
diff --git a/pysnmp/entity/config.py b/pysnmp/entity/config.py
index 5c1bd83..05941b8 100644
--- a/pysnmp/entity/config.py
+++ b/pysnmp/entity/config.py
@@ -326,6 +326,7 @@ def addTransport(snmpEngine, transportDomain, transport):
)
# here we note that we have created transportDispatcher automatically
snmpEngine.setUserContext(automaticTransportDispatcher=0)
+
snmpEngine.transportDispatcher.registerTransport(
transportDomain, transport
)
diff --git a/pysnmp/entity/rfc3413/asyncio/__init__.py b/pysnmp/entity/rfc3413/asyncio/__init__.py
deleted file mode 100644
index ac0b2c0..0000000
--- a/pysnmp/entity/rfc3413/asyncio/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# This file is necessary to make this directory a package.
diff --git a/pysnmp/entity/rfc3413/asyncio/cmdgen.py b/pysnmp/entity/rfc3413/asyncio/cmdgen.py
deleted file mode 100644
index 9e8d603..0000000
--- a/pysnmp/entity/rfc3413/asyncio/cmdgen.py
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# Copyright (C) 2014, Zebra Technologies
-# Authors: Matt Hooks <me@matthooks.com>
-# Zachary Lorusso <zlorusso@gmail.com>
-# Modified by Ilya Etingof <ilya@snmplabs.com>
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-# THE POSSIBILITY OF SUCH DAMAGE.
-#
-from pysnmp.entity.rfc3413 import cmdgen
-from pyasn1.compat.octets import null
-from pysnmp.proto.api import v2c
-try:
- import asyncio
-except ImportError:
- import trollius as asyncio
-
-getNextVarBinds = cmdgen.getNextVarBinds
-
-class AbstractCommandGenerator:
- commandGenerator = None
-
- def _cbFunWithFuture(self, snmpEngine, sendRequestHandle, errorIndication,
- errorStatus, errorIndex, varBinds, future):
- if future.cancelled():
- return
- future.set_result(
- (snmpEngine, errorIndication, errorStatus, errorIndex, varBinds)
- )
-
- def sendVarBinds(self, snmpEngine, targetName,
- contextEngineId, contextName, varBinds):
- future = asyncio.Future()
- self.commandGenerator.sendVarBinds(
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- varBinds,
- self._cbFunWithFuture,
- future
- )
- return future
-
-class GetCommandGenerator(AbstractCommandGenerator):
- commandGenerator = cmdgen.GetCommandGenerator()
-
-class SetCommandGenerator(AbstractCommandGenerator):
- commandGenerator = cmdgen.SetCommandGenerator()
-
-class NextCommandGenerator(AbstractCommandGenerator):
- commandGenerator = cmdgen.NextCommandGenerator()
-
-class BulkCommandGenerator(AbstractCommandGenerator):
- commandGenerator = cmdgen.BulkCommandGenerator()
-
- def sendVarBinds(self, snmpEngine, targetName,
- contextEngineId, contextName,
- nonRepeaters, maxRepetitions, varBinds):
- future = asyncio.Future()
- self.commandGenerator.sendVarBinds(
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- nonRepeaters,
- maxRepetitions,
- varBinds,
- self._cbFunWithFuture,
- future
- )
- return future
diff --git a/pysnmp/entity/rfc3413/asyncio/ntforg.py b/pysnmp/entity/rfc3413/asyncio/ntforg.py
deleted file mode 100644
index 03e927d..0000000
--- a/pysnmp/entity/rfc3413/asyncio/ntforg.py
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Copyright (C) 2014, Zebra Technologies
-# Authors: Matt Hooks <me@matthooks.com>
-# Zachary Lorusso <zlorusso@gmail.com>
-# Modified by Ilya Etingof <ilya@snmplabs.com>
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# * Redistributions of source code must retain the above copyright notice,
-# this list of conditions and the following disclaimer.
-#
-# * Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in the
-# documentation and/or other materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
-# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-# THE POSSIBILITY OF SUCH DAMAGE.
-#
-from pysnmp.entity.rfc3413 import ntforg
-from pyasn1.compat.octets import null
-try:
- import asyncio
-except ImportError:
- import trollius as asyncio
-
-def _cbFunWithFuture(snmpEngine, sendRequestHandle, errorIndication,
- errorStatus, errorIndex, varBinds, future):
- if future.cancelled():
- return
- future.set_result(
- (snmpEngine, errorIndication, errorStatus, errorIndex, varBinds)
- )
-
-class NotificationOriginator:
- def __init__(self):
- self.notificationOriginator = ntforg.NotificationOriginator()
-
- def sendVarBinds(self,
- snmpEngine,
- notificationTarget,
- snmpContext,
- contextName,
- notificationName,
- instanceIndex,
- additionalVarBinds=()):
- future = asyncio.Future()
- self.notificationOriginator.sendVarBinds(
- snmpEngine,
- notificationTarget,
- snmpContext,
- contextName,
- notificationName,
- instanceIndex,
- additionalVarBinds,
- _cbFunWithFuture,
- future
- )
- return future
diff --git a/pysnmp/entity/rfc3413/twisted/__init__.py b/pysnmp/entity/rfc3413/twisted/__init__.py
deleted file mode 100644
index 8c3066b..0000000
--- a/pysnmp/entity/rfc3413/twisted/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# This file is necessary to make this directory a package.
diff --git a/pysnmp/entity/rfc3413/twisted/cmdgen.py b/pysnmp/entity/rfc3413/twisted/cmdgen.py
deleted file mode 100644
index 40f5464..0000000
--- a/pysnmp/entity/rfc3413/twisted/cmdgen.py
+++ /dev/null
@@ -1,136 +0,0 @@
-from twisted.internet import defer
-from pysnmp.entity.rfc3413 import cmdgen
-
-def _cbFun(snmpEngine, sendRequestHandle, errorIndication,
- errorStatus, errorIndex, varBinds, cbCtx):
- df = cbCtx['df']
- df.callback(
- (snmpEngine, errorIndication, errorStatus, errorIndex, varBinds)
- )
- # Callback function may return another deferred to indicate
- # it wishes to continue MIB walk.
- if isinstance(df.result, defer.Deferred):
- cbCtx['df'] = df.result
- return 1 # continue walking
-
-class AbstractCommandGenerator:
- commandGenerator = None
-
- def sendVarBinds(self, snmpEngine, targetName,
- contextEngineId, contextName, varBinds):
- df = defer.Deferred()
- self.commandGenerator.sendVarBinds(
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- varBinds,
- _cbFun,
- { 'df': df } # anonymous dictionary used for cbCtx
- )
- return df
-
-class GetCommandGenerator(AbstractCommandGenerator):
- commandGenerator = cmdgen.GetCommandGenerator()
-
-class SetCommandGenerator(AbstractCommandGenerator):
- commandGenerator = cmdgen.SetCommandGenerator()
-
-class NextCommandGeneratorSingleRun(AbstractCommandGenerator):
- commandGenerator = cmdgen.NextCommandGeneratorSingleRun()
-
-class NextCommandGenerator(AbstractCommandGenerator):
- commandGenerator = cmdgen.NextCommandGenerator()
-
-class AbstractBulkCommandGenerator:
- commandGenerator = None
-
- def sendVarBinds(
- self,
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- nonRepeaters,
- maxRepetitions,
- varBinds
- ):
- df = defer.Deferred()
- self.commandGenerator.sendVarBinds(
- snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- nonRepeaters,
- maxRepetitions,
- varBinds,
- _cbFun,
- { 'df': df } # anonymous dictionary used for cbCtx
- )
- return df
-
-class BulkCommandGeneratorSingleRun(AbstractBulkCommandGenerator):
- commandGenerator = cmdgen.BulkCommandGeneratorSingleRun()
-
-class BulkCommandGenerator(AbstractBulkCommandGenerator):
- commandGenerator = cmdgen.BulkCommandGenerator()
-
-#
-# Obsolete, compatibility interfaces.
-#
-
-def __sendReqCbFun(response, outerDf):
- ( snmpEngine,
- errorIndication,
- errorStatus,
- errorIndex,
- varBinds) = response
- outerDf.callback((errorIndication, errorStatus, errorIndex, varBinds))
- # Callback function may return another deferred to indicate
- # it wishes to continue MIB walk.
- if isinstance(outerDf.result, defer.Deferred):
- innerDf = defer.Deferred()
- innerDf.addCallback(__sendReqCbFun, outerDf.result)
- return innerDf
-
-def _sendReq(self,
- snmpEngine,
- targetName,
- varBinds,
- contextEngineId=None,
- contextName=''):
- innerDf = self.sendVarBinds(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- varBinds)
- outerDf = defer.Deferred()
- innerDf.addCallback(__sendReqCbFun, outerDf)
- return outerDf
-
-def _sendBulkReq(self,
- snmpEngine,
- targetName,
- nonRepeaters,
- maxRepetitions,
- varBinds,
- contextEngineId=None,
- contextName=''):
- innerDf = self.sendVarBinds(snmpEngine,
- targetName,
- contextEngineId,
- contextName,
- nonRepeaters,
- maxRepetitions,
- varBinds)
- outerDf = defer.Deferred()
- innerDf.addCallback(__sendReqCbFun, outerDf)
- return outerDf
-
-# install compatibility wrappers
-GetCommandGenerator.sendReq = _sendReq
-SetCommandGenerator.sendReq = _sendReq
-NextCommandGenerator.sendReq = _sendReq
-NextCommandGeneratorSingleRun.sendReq = _sendReq
-BulkCommandGenerator.sendReq = _sendBulkReq
-BulkCommandGeneratorSingleRun.sendReq = _sendBulkReq
diff --git a/pysnmp/entity/rfc3413/twisted/ntforg.py b/pysnmp/entity/rfc3413/twisted/ntforg.py
deleted file mode 100644
index cc796b6..0000000
--- a/pysnmp/entity/rfc3413/twisted/ntforg.py
+++ /dev/null
@@ -1,75 +0,0 @@
-from twisted.internet import defer
-from pysnmp.entity.rfc3413 import ntforg
-from pyasn1.compat.octets import null
-
-def __cbFun(snmpEngine, sendRequestHandle, errorIndication,
- errorStatus, errorIndex, varBinds, cbCtx):
- cbCtx.callback(
- (snmpEngine, errorIndication, errorStatus, errorIndex, varBinds)
- )
-
-class NotificationOriginator:
- def __init__(self, snmpContext=None):
- self.snmpContext = snmpContext # this is deprecated
- self.notificationOriginator = ntforg.NotificationOriginator()
-
- def sendVarBinds(self,
- snmpEngine,
- notificationTarget,
- snmpContext,
- contextName,
- notificationName,
- instanceIndex,
- additionalVarBinds=()):
- df = defer.Deferred()
- self.notificationOriginator.sendVarBinds(
- snmpEngine,
- notificationTarget,
- snmpContext,
- contextName,
- notificationName,
- instanceIndex,
- additionalVarBinds,
- __cbFun,
- df
- )
- return df
-
-#
-# Obsolete, compatibility interfaces.
-#
-
-def __sendReqCbFun(response, outerDf):
- ( snmpEngine,
- errorIndication,
- errorStatus,
- errorIndex,
- varBinds) = response
- outerDf.callback((errorIndication, errorStatus, errorIndex, varBinds))
- # Callback function may return another deferred to indicate
- # it wishes to continue MIB walk.
- if isinstance(outerDf.result, defer.Deferred):
- innerDf = defer.Deferred()
- innerDf.addCallback(__sendReqCbFun, outerDf.result)
- return innerDf
-
-def _sendNotification(self,
- snmpEngine,
- notificationTarget,
- notificationName,
- additionalVarBinds=None,
- contextName=null):
-
- innerDf = self.sendVarBinds(snmpEngine,
- notificationTarget,
- self.snmpContext,
- contextName,
- notificationName,
- None,
- additionalVarBinds)
- outerDf = defer.Deferred()
- innerDf.addCallback(__sendReqCbFun, outerDf)
- return outerDf
-
-# install compatibility wrappers
-NotificationOriginator.sendNotification = _sendNotification