| |
- dispatcher
-
- async_session(dispatcher, session)
- session(message)
-
- async_session(dispatcher, session)
class async_session(dispatcher, session) |
|
An asynchronous SNMP engine based on the asyncore.py classes.
Send SNMP requests and receive a responses asynchronously. |
|
- Method resolution order:
- async_session
- dispatcher
- session
- message
- ber
- Base
Methods defined here:
- __init__(self, agent, community, caller_fun, caller_data=None)
- handle_connect(self)
- Objects of this class never expect connect events
- handle_read(self)
- Read SNMP reply from socket.
This does NOT time out so one needs to implement a mean of
handling timed out requests (perhaps it's worth looking at
medusa/event_loop.py for an interesting approach).
- open(self)
- open()
Create a socket and pass it to asyncore dispatcher.
- send_request(self, encoded_oids, encoded_vals, type='GETREQUEST')
- send_request(encoded_oids, encoded_vals[, type])
Build and send SNMP message to remote SNMP process (as specified
on async_session object creation) composed from encoded
Object IDs along with their associated values.
A callback function (as specified on async_session object creation)
will be invoked on response arrival or request timeout.
- writable(self)
- Objects of this class never expect write events
Methods inherited from dispatcher:
- __getattr__(self, attr)
- # cheap inheritance, used to pass all other attribute
# references to the underlying socket object.
- __repr__(self)
- accept(self)
- add_channel(self, map=None)
- bind(self, addr)
- close(self)
- connect(self, address)
- create_socket(self, family, type)
- del_channel(self, map=None)
- handle_accept(self)
- handle_close(self)
- handle_error(self)
- handle_expt(self)
- handle_expt_event(self)
- handle_read_event(self)
- handle_write(self)
- handle_write_event(self)
- listen(self, num)
- log(self, message)
- log_info(self, message, type='info')
- readable(self)
- recv(self, buffer_size)
- send(self, data)
- set_reuse_addr(self)
- set_socket(self, sock, map=None)
Data and other attributes inherited from dispatcher:
- accepting = False
- addr = None
- closing = False
- connected = False
- debug = False
Methods inherited from session:
- get_socket(self)
- get_socket() -> socket
Return socket object previously created with open() method.
- read(self)
- read() -> message
Read data from the socket (assuming there's some data ready
for reading), return SNMP message (as string).
- receive(self)
- receive() -> message
Receive SNMP message from remote SNMP process or timeout
(and return None).
- send_and_receive(self, message)
- send_and_receive(message) -> message
Send SNMP message to remote SNMP process (as specified on
session object creation) and receive a response message
or timeout (and raise NoResponse exception).
- store(self, request)
- store(message)
Store SNMP message for later transmission.
Methods inherited from message:
- decode_bindings(self, octetString)
- Compatibility method: BER decode bindings up to oids & values
- decode_response(self, message, mtype='GETRESPONSE')
- decode_response(message[, type]) -> (encoded_oids, encoded_values)
Decode SNMP message (string) of specified type (default is
'GETRESPONSE'), return lists of encoded Object IDs and their
values (lists of strings).
- decode_response_sequence(self, octetStream)
- Compatibility method: BER decode SNMP response sequence
- decode_snmp_pdu(self, octetString)
- Compatibility method: BER decode SNMP PDU
- decode_snmp_trap_pdu(self, octetString)
- Compatibility method: BER decode SNMP TRAP PDU
- decode_trap(self, octetStream)
- decode_trap(message) -> (enterprise, address, generic,
specific, timeticks, encoded_oids,
encoded_vals)
Decode SNMP TRAP message (string).
- encode_bindings(self, encoded_oids, encoded_vals)
- Compatibility method: BER encode oids & values
- encode_request(self, pduType, encoded_oids, encoded_values)
- encode_request(type, encoded_oids, encoded_values) -> SNMP message
Encode Object IDs and values (lists of strings) into variables
bindings, then encode bindings into SNMP PDU (of specified type
(string)), then encode SNMP PDU into SNMP message.
- encode_request_sequence(self, pdu)
- Compatibility method: BER encode SNMP request sequence
- encode_snmp_pdu(self, pduType, bindings)
- Compatibility method: BER encode SNMP PDU
- encode_snmp_trap_pdu(self, enterprise, address, generic, specific, timeticks, bindings)
- Compatibility method: BER encode SNMP TRAP PDU
- encode_trap(self, enterprise, address, generic, specific, timeticks, encoded_oids=[], encoded_vals=[])
- encode_trap(type, encoded_oids, encoded_values) -> SNMP message
Encode Object IDs and values (lists of strings) into variables
bindings, then encode bindings into SNMP PDU (of specified type
(string)), then encode SNMP PDU into SNMP message.
Methods inherited from ber:
- decode_integer(self, octetStream)
- decode_integer(stream) -> integer
Decode octet stream into signed ASN.1 integer.
- decode_ipaddr(self, octetStream)
- decode_ipaddr(stream) -> IP address
Decode octet stream into ASN.1 IP address (in dotted notation)
- decode_null(self, octetStream)
- decode_null(stream) -> Null
Decode octet stream into ASN.1 Null
- decode_oid(self, octetStream)
- decode_oid(stream) -> object id
Decode octet stream into ASN.1 Object ID (returned as a list of
integer subIDs).
- decode_string(self, octetStream)
- decode_string(stream) -> string
Decode octet stream into signed ASN.1 string.
- decode_timeticks(self, octetStream)
- decode_timeticks(stream) -> timeticks
Decode octet stream into ASN.1 timeticks
- decode_uptime = decode_timeticks(self, octetStream)
- decode_timeticks(stream) -> timeticks
Decode octet stream into ASN.1 timeticks
- decode_value(self, octetStream)
- decode_value(stream) -> value
Decode octet stream into ASN.1 value (its ASN.1 type is
determined from included BER tag). The type of returned
value is context dependent.
- encode_integer(self, integer)
- encode_integer(integer) -> octet stream
Encode ASN.1 integer into octet stream.
- encode_ipaddr(self, addr)
- encode_addr(addr) -> octet stream
Encode ASN.1 IP address (in dotted notation) into octet stream.
- encode_null(self)
- encode_null() -> octet stream
Encode ASN.1 Null into octet stream.
- encode_oid(self, noids)
- encode_oid(oids) -> octet stream
Encode ASN.1 Object ID (specified as a list of integer subIDs)
into octet stream.
- encode_string(self, string)
- encode_string(string) -> octet stream
Encode ASN.1 string into octet stream.
- encode_timeticks(self, timeticks)
- encode_timeticks(timeticks) -> octet stream
Encode ASN.1 timeticks into octet stream.
- nums2str(self, objid_n, aliases=None)
- nums2str(obj_id) -> object id
Convert Object ID (given as a list of integer sub Object IDs) into
string representation.
- oid_prefix_check(self, enc_oid_1, enc_oid_2)
- oid_prefix_check(encoded_oid_1, encoded_oid_2) -> boolean
Compare encoded OIDs (given as lists), return non-None if
OID1 is a prefix of OID2.
This is intended to be used for MIB tables retrieval.
- str2nums(self, txt, aliases=None)
- str2nums(obj_id) -> object id
Convert Object ID (given as string) into a list of integer
sub IDs.
| |