host.power¶
Pluggable power control strategy for hosts.
Powering a host on or off cannot run on the host — it’s off. A
PowerController embodies where control happens: it runs commands on a
designated controller host (a hypervisor, a jump host with ipmitool, a PDU
controller) resolved via the target’s lab back-reference, or talks to an
external API. otto ships CommandPowerController (the generic
command-based backend); projects register richer ones (IPMI/redfish/libvirt/
cloud/PDU) via register_power_controller(), the same extension hook
otto.host.binary_loader.register_binary_loader() uses.
- class otto.host.power.PowerState(value)¶
Bases:
EnumA host’s power state as reported by a controller.
-
ON =
'on'¶
-
OFF =
'off'¶
-
ON =
- class otto.host.power.PowerController¶
Bases:
ABCHow to power a host on/off from somewhere the host can be reached.
- async cycle(host: Host) tuple[Status, str]¶
Power-cycle host: off, then on. Override for a native reset.
- async status(host: Host) PowerState | None¶
Return the current power state, or
Nonewhen this controller can’t report it.
-
class otto.host.power.CommandPowerController(on_cmd: str, off_cmd: str, status_cmd: str | None =
None, status_on: str ='', controller: str | None =None)¶ Bases:
PowerControllerGeneric controller that runs configured commands on a controller host.
Commands are
str.format-templated with the target host’sname/ip/id.controllernames the lab host the commands run on (via itsoneshot);Noneruns them on the local otto machine.- async status(host: Host) PowerState | None¶
Return the current power state, or
Nonewhen this controller can’t report it.
- otto.host.power.register_power_controller(type_name: str, cls: type[PowerController]) None¶
Register a
PowerControllersubclass for lab-data selection.
- otto.host.power.build_power_controller(type_name: str) type[PowerController]¶
Return the
PowerControllerclass registered under type_name.
- otto.host.power.power_control_from_spec(value: Any) PowerController | None¶
Coerce a lab-data value into a
PowerControllerinstance.Accepts
None/ an existing instance (pass-through), astr(a config-free controller type name), or adictwith atypekey plus the controller’s constructor kwargs.