| |
- object
-
- Agent
- TrapHandler
class Agent(object) |
|
Implementation of SNMP Logic for Agent-side implementations
This base-class is intended to interact with objects providing
an OID-store interface. It's primary purpose is to implement
the iteration control mechanisms for querying that store. |
|
Methods defined here:
- __init__(self, dataStore, protocol=None)
- Initialise the MockAgent with OID list
- deregisterTrap(self, managerIP, genericType=None, specificType=None)
- Deregister given managerIP from given traps
genericType -- if None, deregister from all generic types
specificType -- if None, deregister from all specific types
- findTrapHandlers(self, genericType=None, specificType=None)
- Yield set of paths to handlers for given types
- get(self, request, address, implementation)
- Get OID(s) for the request and return response
request -- parsed (i.e. object-form) GET request
address -- (ip,port) Internet address from which the
request was received.
implementation -- implementation module for the request,
i.e. the v2c or v1 module
sends response to the client as a side effect
returns the sent response
- getNext(self, request, address, implementation)
- Respond to an iterative get-next request
request -- parsed (i.e. object-form) GETNEXT request
address -- (ip,port) Internet address from which the
request was received.
implementation -- implementation module for the request,
i.e. the v2c or v1 module
sends response to the client as a side effect
returns the sent response
XXX Doesn't currently check for message too long error
condition
(1) If, for any object name in the variable-bindings field,
that name does not lexicographically precede the name of
some object available for get operations in the relevant
MIB view, then the receiving entity sends to the
originator of the received message the GetResponse-PDU of
identical form, except that the value of the error-status
field is noSuchName, and the value of the error-index
field is the index of said object name component in the
received message.
(2) If the size of the GetResponse-PDU generated as described
below would exceed a local limitation, then the receiving
entity sends to the originator of the received message
the GetResponse-PDU of identical form, except that the
value of the error-status field is tooBig, and the value
of the error-index field is zero.
(3) If, for any object named in the variable-bindings field,
the value of the lexicographical successor to the named
object cannot be retrieved for reasons not covered by any
of the foregoing rules, then the receiving entity sends
to the originator of the received message the
GetResponse-PDU of identical form, except that the value
of the error-status field is genErr and the value of the
error-index field is the index of said object name
component in the received message.
If none of the foregoing rules apply, then the receiving protocol
entity sends to the originator of the received message the
GetResponse-PDU such that, for each name in the variable-bindings
field of the received message, the corresponding component of the
GetResponse-PDU represents the name and value of that object whose
name is, in the lexicographical ordering of the names of all objects
available for get operations in the relevant MIB view, together with
the value of the name field of the given component, the immediate
successor to that value. The value of the error-status field of the
GetResponse-PDU is noError and the value of the errorindex field is
zero. The value of the request-id field of the GetResponse-PDU is
that of the received message.
http://www.faqs.org/rfcs/rfc1157.html
Section: 4.1.3, GetNextRequest
- getNextOIDs(self, oids)
- Get the given set of OIDs' next items
oids -- sequence of OIDs from which to retrieve next OIDs
return list of oid,value pairs
- getOIDs(self, oids)
- Get the given set of OIDs
oids -- sequence of OIDs to retrieve
return list of oid,value pairs
- getSysObjectId(self)
- Get our system object identifier for traps
- getTable(self, request, address, implementation)
- Respond to an all-at-once (v2) get request
request -- parsed (i.e. object-form) GETBULK request
address -- (ip,port) Internet address from which the
request was received.
implementation -- implementation module for the request,
i.e. the v2c or v1 module
sends response to the client as a side effect
returns the sent response
The get-bulk request has two elements, a set of non-repeating
get-next OIDs (normally 0), and a set of repeating get-bulk
OIDs. Up to a specified number of ordered elements starting
at the specified OIDs are returned for each of the bulk elements,
with truncation of the entire set occuring if all tables are
exhausted (reach the end of the OID tables), otherwise will
include subsequent table values sufficient to fill in the
message-size.
http://www.faqs.org/rfcs/rfc1448.html
Section 4.2.3, The GetBulkRequest-PDU
- getTableOIDs(self, nonRepeating=(), repeating=(), maxRepetitions=255)
- Get non-repeating and repeating OID values
nonRepeating -- sequence of OIDs for non-repeating retrieval
repeating -- sequence of OIDs for repeating retrieval
maxRepetitions -- maximum number of repetitions
Note:
The interpretation here is that the set of repeating values
must remain of equal size, that is, our result set must be
N + (M*r) (where M is the repeating count and r the number of
iterations) items. This is new with version 0.3.9, previous
versions assumed that we would trim the size of the window
as each starting-oid reached end-of-mib-view, which would result
in values no longer being indexed to their source OID.
return list of oid,value pairs
- registerTrap(self, trapHandler)
- Register the given manager to watch the given trap
The key (genericType,specificType) will be used to dispatch trap
messages to those managers which are registered here
Note: there is not automated clearing of managers from this table,
if you need to remove a manager you must call deregisterTrap( )
- sendTrap(self, genericType=6, specificType=0, pdus=None)
- Send given trap to all registered watchers
- set(self, request, address, implementation)
- Set OIDs as given by request
request -- parsed (i.e. object-form) SET request
address -- (ip,port) Internet address from which the
request was received.
implementation -- implementation module for the request,
i.e. the v2c or v1 module
XXX Spec requires a two-stage (or more) commit sequence with
undo on failure even including the commit itself. Not
implemented.
- setOIDs(self, variables)
- Set the OID:value variables in our dataStore
- setProtocol(self, protocol)
- Set the protocol for the agent object
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'Agent' objects>
- list of weak references to the object (if defined)
|
class TrapHandler(object) |
|
Registration for a given Trap for a given manager |
|
Methods defined here:
- __init__(self, managerIP, community='public', version='v2c', genericType=None, specificType=None)
- Initialise the registration for the given parameters
managerIP -- (IP,port) address to which to send messages
community -- community string to use for the messages we send
genericType -- the major type spec for matching messages
specificType -- the minor type spec for matching messages
- send(self, agent, genericType=6, specificType=0, pdus=None)
- Given agent, send our message to the management stations
Data and other attributes defined here:
- __dict__ = <dictproxy object>
- dictionary for instance variables (if defined)
- __weakref__ = <attribute '__weakref__' of 'TrapHandler' objects>
- list of weak references to the object (if defined)
| |