SNMP Component Mananger

This module implements a component manager for snmp devices.

class SNMPComponentManager(host, port, authority, max_objects_per_pdu, logger, communication_state_callback, component_state_callback, attributes, poll_rate, traps, trap_host, trap_port)

An implementation of the snmp component manager.

__init__(host, port, authority, max_objects_per_pdu, logger, communication_state_callback, component_state_callback, attributes, poll_rate, traps, trap_host, trap_port)

Initialise the component manager.

param host: SNMP host param port: SNMP port (usually 161) param authority: Either V1, V2c or V3 access param max_objects_per_pdu: Maximum number of OIDs to grab at one time param logger: looging param communication_state_callback: callback for communication changes param component_state_callback: callback for component changes param attributes: tango attributes param poll_rate: polling frequency param traps: trap notifications are available = True (default is False) param trap_host: trap host, usually = host, but maybe changed for testing param trap_port: trap port, usaully = 162, but can be changed for testing

cbk_func(transport_domain, transport_address, whole_msg)

Call this callback function when trap_port receives a notification.

Parameters:
  • transport_domain (tuple) – domain

  • transport_address (tuple) – address

  • whole_msg (bytes) – notification

  • attr_name – the attribute name

Return type:

tuple[int, Any, str, str] | None

Returns:

(timeticks,attr value, oid, attr_name)

from_python(attr_name, val)

Convert from raw Python type to a hardware-compatible type.

This is called in enqueue_write() so that any conversion error happens early, when an attribute is set, rather than in the polling thread.

Parameters:
  • attr_name (str) – the name of the attribute to be written

  • val (Any) – the attribute value to write in snmp type

Return type:

Any

Returns:

the value as an snmp data type

poll(poll_request)

Group by writes and reads, chunk, and run the appropriate SNMP command.

Aggregate any returned ObjectTypes from GET commands as the poll response.

Parameters:

poll_request (AttrPollRequest) – a list of attributes to poll

Return type:

dict[str, Any]

Returns:

the snmp response