This document describes the Finite State Machine (FSM) for Power Shelves in NICo: lifecycle from creation through initialization, ready, the OnDemand maintenance operations (PowerOn / PowerOff), and deletion. It also covers the operator-facing interfaces (CLI / gRPC) used to drive the OnDemand operations.
The main flow shows the primary states and transitions:
The Maintenance state is entered on demand by an operator (or any other
service) to drive a power-control operation on the shelf. Two operations are
currently supported:
The power-shelf maintenance subcommand (alias fix) drives one or more
shelves into Maintenance. All listed shelves receive the same operation in
a single atomic request — if any shelf is unknown or marked for
deletion the entire request is rejected and no shelves are mutated.
The CLI is a thin wrapper over the NICo.SetPowerShelfMaintenance gRPC
method:
Validation rules enforced by the API handler:
power_shelf_ids must contain at least one ID and at most
runtime_config.max_find_by_ids IDs.operation must be POWER_ON or POWER_OFF; UNSPECIFIED is rejected
with InvalidArgument.The handler runs all updates in a single database transaction, so a caller observes the new maintenance request on every listed shelf simultaneously (or not at all).
The DB column power_shelf_maintenance_requested stores who/why requested
the operation. The API composes it from two sources:
The power_shelves.power_shelf_maintenance_requested column is a nullable
JSONB; the API sets it on SetPowerShelfMaintenance and the state
controller clears it when the operation finishes
Maintenance handler is still a
TODO: today the handler clears the maintenance request and returns to
Ready without driving the hardware. Plugging in the real PowerOn /
PowerOff BMC action is a focused follow-up that does not change the public
CLI / gRPC surface.