Skip to content

Core Framework: Power Control

Ulrond edited this page Nov 6, 2024 · 1 revision

Power Control

This section details the powerControlClass, a Python class within the framework that provides a standardized way to manage the power state of devices connected to your testing rack. This class abstracts the complexities of different power switch hardware, offering a simple interface for controlling power on, power off, and reboot operations.

1. Supported Power Switch Types

The powerControlClass supports a variety of power switches commonly used in testing environments:

  • orvbioS20: A network-controlled relay board.
  • kasa: TP-Link Kasa smart plugs and power strips.
  • hs100: TP-Link HS100 smart plugs (also supported by Kasa).
  • apc: APC network-managed power distribution units (PDUs).
  • olimex: Olimex relay boards.
  • SLP: Sentry Power Manager (SPM) with Serial-over-LAN (SLP) interface.
  • none: For testing or simulating power control without actual hardware.

2. Configuration

The power control configuration is defined within your rack configuration file (e.g., example_rack_config.yml). Each device slot in your rack can be associated with a specific power switch and its settings.

Example Configuration (from example_rack_config.yml):

  slot1:
    device: "broadcom-stb"
    powerSwitch:      # Specific power switch for each slot
      type: "HS100"
      ip: "192.168.1.7"
      port: 9999

This configuration specifies that the device in slot1 is connected to an HS100 smart plug with the IP address "192.168.1.7".

Configuration Parameters:

Each power switch type requires specific parameters:

  • orvbioS20: ip, mac, and optionally port and relay.
  • kasa: ip and options. Use --plug for single plugs and --strip with --index for power strips.
  • hs100: ip and optionally port.
  • apc: ip, username, and password.
  • olimex: ip, relay, and optionally port.
  • SLP: ip, username, password, outlet_id, and optionally port.

3. Using the powerControlClass

The framework typically handles the instantiation of the powerControlClass based on your rack configuration. You usually interact with its methods through other parts of the framework.

Available Methods:

  • powerOn(): Powers on the device.
  • powerOff(): Powers off the device.
  • reboot(): Performs a power cycle (off then on).

These methods return True if the operation is successful and False otherwise.

4. Error Handling and Logging

The powerControlClass incorporates error handling with retries to increase the reliability of power operations. It also uses the framework's logging mechanism to record events and errors, aiding in debugging and monitoring.

5. Important Considerations

  • Ensure your rack configuration file accurately reflects your hardware setup and power switch connections.
  • Consult the documentation for individual power switch modules for detailed information and troubleshooting.
  • This section assumes familiarity with the overall framework and its configuration. Refer to other sections for foundational knowledge.