Skip to content

Refactor PDU library to better support SNMP devices

Charlie Turner requested to merge cturner/igalia-pdu into master

The goal of this MR was to add support for the PDU15SWHVIEC12ATNET PDU, installed at the Igalia farm. This PDU differs from what I've seen before with regards to changing outlet statuses. The existing PDUs used the same OID tree for retrieving port states and for setting port states. In other words, RW trees.

The PDU15SWHVIEC12ATNET, however, uses a RO tree for getting port states, and a separate RW tree for setting port states. It also encodes outlet states in different ways for writing and reading, a fun additional requirement.

This MR moves the library to a more data-orientated approach. The goal is to make it a simple data entry job to add new PDUs in the source, with the base class doing all the behavioural work, the subclasses are basically just table entries.

The alternative method of being able to specify all interesting details of the SNMP device in a JSON payload from the HTTP API has been extended and hence kept. Now you can dynamically create SnmpPDUs, in addition to statically specifying them in the source code, adding a level of flexibility that should future-proof us nicely.

I haven't adjusted the documentation, we can revisit that when the dust settles, and when our interfaces have been more thoroughly battle-tested, otherwise the churn there would be unhelpful overhead.

The second and third patch could be squashed, but I kept the intermediate step of adding another PDU just to show the awkwardness the interface was producing, and to better demonstrate what the refactoring in the last patch does. I feel it helps following the changes better to include this step. The second patch of course doesn't work, because the action mappings are not handled properly.

/cc @mupuf

Merge request reports