Create a PDU Gateway service
We are currently using a python module to abstract communicating with the PDUs.
This solves most issues, but comes with the following drawbacks:
- Hard to keep track of state changes (I would like to know how long a port has been OFF for)
- Periodic polling would lead to duplicated queries
- Make it hard to auto-detect PDUs through MDNS/Bonjour/avahi/...
Here is the proposed sequence diagram:
sequenceDiagram
participant client as Client
participant pdu_gateway as PDU<br/>Gateway
participant pdu as APC PDU<br/>10.42.0.42
autonumber
note over client: Register a new PDU
client->>+pdu_gateway: POST /v1/pdu/<br/>{ name: apc, driver: apc_masterswitch, config: { host: 10.42.0.42 }}
pdu_gateway->>pdu: Query the list of ports, their states and statuses
pdu_gateway->>-client: 201 Created
note over client: List PDUs
client->>+pdu_gateway: GET /v1/pdu/
pdu_gateway->>-client: 200 Success<br/>[{name: apc, driver: apc_masterswitch, ports: [{label: Port 1, state=ON}, ...]]
note over client: Periodic PDU polling
pdu_gateway->>pdu: Query the list of ports, their states and statuses
note over client: Check the state of a single port
client->>+pdu_gateway: GET /v1/pdu/apc/ports/1/state
pdu_gateway->>-client: 200 Success<br/>ON
note over client: Set the state of a PDU port
client->>+pdu_gateway: POST /v1/pdu/apc/ports/1/state<br/>OFF
pdu_gateway->>-client: 200 Success<br/>OFF