Subrack subpackage

This subpackage implements subrack functionality for the MCCS.

class FanMode(value)

Python enumerated type for FanMode attribute.

MANUAL = 0

Tango Device accepts commands from all clients.

class MccsSubrack(*args, **kwargs)

A Tango device for monitor and control of an SPS subrack.

PowerDownTpms()

Power down all TPMs.

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

PowerOffTpm(tpm_number)

Power down a TPM.

Parameters:

tpm_number (int) – the logical id of the TPM to power down

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

PowerOnTpm(tpm_number)

Power up a TPM.

Parameters:

tpm_number (int) – the logical id of the TPM to power up

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

PowerPduPortOff(port_number)

Turn the selected pdu port off.

Parameters:

port_number (int) – pdu port number

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

PowerPduPortOn(port_number)

Turn the selected pdu port on.

Parameters:

port_number (int) – pdu port number

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

PowerUpTpms()

Power up all TPMs.

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

ScheduleOff()

Turn self off.

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

ScheduleOn()

Turn self on.

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

SetPowerSupplyFanSpeed(power_supply_fan_id, speed_percent)

Set the selected power supply fan speed.

A json dictionary with mandatory keywords

Parameters:
  • power_supply_fan_id (int) – (int) power supply fan id from 1 to 2

  • speed_percent (int) – (int) fan speed in percent

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

SetSubrackFanMode(fan_id, mode)

Set the selected subrack backplane fan mode.

A json dictionary with mandatory keywords

Parameters:
  • fan_id (int) – (int) fan id from 1 to 4

  • mode (FanMode) – (int) mode: 0=MANUAL, 1=AUTO

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

SetSubrackFanSpeed(subrack_fan_id, speed_percent)

Set the selected subrack backplane fan speed.

A json dictionary with mandatory keywords

Parameters:
  • subrack_fan_id (int) – (int) fan id from 1 to 4

  • speed_percent (int) – (int) fan speed in percent

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purpose only.

UpdateHealthAttributes()

Request the subrack driver to poll the health status attributes.

Return type:

TaskFunctionType

Returns:

A tuple containing a return code and a string message indicating status. The message is for information purposes only.

property UseAttributesForHealth

Use the attribute quality factor in health. ADR-115.

__init__(*args, **kwargs)

Initialise this device object.

Parameters:
  • args (Any) – positional args to the init

  • kwargs (Any) – keyword args to the init

property attributeFilterType: str

The type of attribute filter applied.

property backplaneTemperatures

Read the backplane temperatures. Two values are returned, respectively for the first (bays 1-4) and second (bays 5-8) halves of the backplane.

Unit:

Celsius

property boardCurrent

Read the total current provided by the two power supplies.

Unit:

Ampere

property boardTemperatures

Read the Subrack board temperatures.

Unit:

Celsius

property cpldPllLocked

Read whether the CPLD PLL is locked.

create_component_manager()

Create and return a component manager for this device.

Return type:

SubrackComponentManager

Returns:

a component manager for this device.

delete_device()

Delete the device.

Return type:

None

property healthModelParams: str

Get the health params from the health model.

property healthReport: str

The current Subrack health state plus optional additional information.

property healthStatus

Read a dictionary of all Subrack monitoring points.

init_device()

Initialise the device.

This is overridden here to change the Tango serialisation model.

Return type:

None

property internalVoltages1V1: float

Subrack internal 1V1 supply voltage in Volts.

Unit:

Volt

property internalVoltages1V5: float

Subrack internal 1V5 supply voltage in Volts.

Unit:

Volt

property internalVoltages2V5: float

Subrack internal 2V5 supply voltage in Volts.

Unit:

Volt

property internalVoltages2V8: float

Subrack internal 2V8 supply voltage in Volts.

Unit:

Volt

property internalVoltages3V: float

Subrack internal 3V supply voltage in Volts.

Unit:

Volt

property internalVoltages3V3: float

Subrack internal 3V3 supply voltage in Volts.

Unit:

Volt

property internalVoltages5V: float

Subrack internal 5V supply voltage in Volts.

Unit:

Volt

property internalVoltagesARM: float

Subrack internal ARM supply voltage in Volts.

Unit:

Volt

property internalVoltagesCORE: float

Subrack internal CORE supply voltage in Volts.

Unit:

Volt

property internalVoltagesDDR: float

Subrack internal DDR supply voltage in Volts.

Unit:

Volt

property internalVoltagesPOWERIN: float

Subrack power input voltage in Volts.

Unit:

Volt

property internalVoltagesSOC: float

Subrack internal SOC supply voltage in Volts.

Unit:

Volt

is_SetPowerSupplyFanSpeed_allowed(request_type=None)

Return whether the subrack can set the power supply fan speed.

Parameters:

request_type (Optional[LRCReqType]) – whether the command is being queued or executed. Both are refused on the same grounds, so this is not read.

Return type:

bool

Returns:

True if the command is allowed.

property pduHealth

The current health of the PDU.

property pduModel

The model of PDU in use.

property pduNumberPorts: int

Read the number of PDU ports.

property pduPortCurrents

Read the PDU port currents.

Unit:

Ampere

property pduPortStates

Read the PDU port states.

property pduPortVoltages

Read the PDU port voltages.

Unit:

Volt

property powerSupplyCurrents

Read the currents of the power supplies.

Unit:

Ampere

property powerSupplyFanSpeeds

Fan speeds of the power supply expressed as a percentage of maximum.

property powerSupplyPowers

Output power of Subrack power supplies.

Unit:

Watt

property powerSupplyVoltages

Output voltage of the Subrack power supplies.

Unit:

Volt

property psu1Load

Read the load on PSU1 expressed as a fraction of the maximum.

property psu1PowerIn: float

PSU1 input power in Watts.

Unit:

Watt

Max warning:

575.0

Max alarm:

600.0

property psu1PowerOut: float

PSU1 output power in Watts.

Unit:

Watt

Max warning:

600.0

Max alarm:

1140.0

property psu1Present

Presence of PSU1.

property psu1VoltageIn: float

PSU1 input voltage in Volts.

Unit:

Volt

Min warning:

215.0

Max warning:

240.0

Min alarm:

207.0

Max alarm:

253.0

property psu1VoltageOut: float

PSU1 output voltage in Volts.

Unit:

Volt

Min warning:

11.0

Max warning:

13.0

Min alarm:

10.0

Max alarm:

14.0

property psu2Load

Read the load on PSU2 expressed as a fraction of the maximum.

property psu2PowerIn: float

PSU2 input power in Watts.

Unit:

Watt

Max warning:

575.0

Max alarm:

600.0

property psu2PowerOut: float

PSU2 output power in Watts.

Unit:

Watt

Max warning:

600.0

Max alarm:

1140.0

property psu2Present

Presence of PSU2.

property psu2VoltageIn: float

PSU2 input voltage in Volts.

Unit:

Volt

Min warning:

215.0

Max warning:

240.0

Min alarm:

207.0

Max alarm:

253.0

property psu2VoltageOut: float

PSU2 output voltage in Volts.

Unit:

Volt

Min warning:

11.0

Max warning:

13.0

Min alarm:

10.0

Max alarm:

14.0

property psuDeadCount: int

Count of PSUs that are present and receive input voltage but supply no output voltage.

Max warning:

1

Max alarm:

2

property subrackBoardInfo

Read the Subrack board info

property subrackFanModes

Read the current Subrack fan modes.

property subrackFanSpeeds

Read the Subrack fan speeds.

Unit:

RPM

property subrackFanSpeedsPercent

Subrack fan speeds expressed as a percentage of maximum.

property subrackMaxFanSpeeds

Expected Fan Speeds at 100% pwm duty.

Unit:

RPM

Min warning:

4875

Max warning:

8125

Min alarm:

1625

Max alarm:

9750

property subrackPllLocked

Whether the PLL is locked.

property subrackTimestamp: int

Subrack current time.

property tpm1PowerState

The powerState of the TPM in bay 1.

property tpm2PowerState

The powerState of the TPM in bay 2.

property tpm3PowerState

The powerState of the TPM in bay 3.

property tpm4PowerState

The powerState of the TPM in bay 4.

property tpm5PowerState

The powerState of the TPM in bay 5.

property tpm6PowerState

The powerState of the TPM in bay 6.

property tpm7PowerState

The powerState of the TPM in bay 7.

property tpm8PowerState

The powerState of the TPM in bay 8.

property tpmCount: int

Read the TPM count of this Subrack.

property tpmCurrents

Read the current of all TPMs.

Unit:

Ampere

property tpmPowers

Read the powers of all TPMs.

Unit:

Watt

Max alarm:

120.0

property tpmPresent

Read the presence of TPMs in each Subrack bay.

property tpmVoltages

Read the voltages of all TPMs.

Unit:

Volt

Min alarm:

11.4

Max alarm:

12.6

property useAttributesForHealth: bool

Return if adr115 is in use. True if attributes quality is being evaluated in health.

class SubrackComponentManager(subrack_ip, subrack_port, logger, pdu_trl, pdu_ports, power_marshaller_trl, simulated_pdu, communication_state_changed_callback, component_state_changed_callback, update_rate=5.0, command_update_rate=20.0, max_fan_errors=5, max_fan_delta=25, _driver=None, _initial_power_state=ska_control_model.PowerState.ON, _initial_fail=False)

A component manager for an subrack (simulator or driver) and its power supply.

__init__(subrack_ip, subrack_port, logger, pdu_trl, pdu_ports, power_marshaller_trl, simulated_pdu, communication_state_changed_callback, component_state_changed_callback, update_rate=5.0, command_update_rate=20.0, max_fan_errors=5, max_fan_delta=25, _driver=None, _initial_power_state=ska_control_model.PowerState.ON, _initial_fail=False)

Initialise a new instance.

Parameters:
  • subrack_ip (str) – the IP address of the subrack

  • subrack_port (int) – the subrack port

  • logger (Logger) – a logger for this object to use

  • pdu_trl (str) – trl for the pdu device

  • pdu_ports (list[int]) – the ports of the pdu that this subrack is plugged into

  • power_marshaller_trl (str) – trl for the power marshaller device

  • simulated_pdu (bool) – if we are using a simulated pdu or not

  • communication_state_changed_callback (Callable[[CommunicationStatus], None]) – callback to be called when the status of the communications channel between the component manager and its component changes

  • component_state_changed_callback (Callable[..., None]) – callback to be called when the component state changes

  • update_rate (float) – how often updates to attribute values should be provided. This is not necessarily the same as the rate at which the instrument is polled. For example, the instrument may be polled every 0.1 seconds, thus ensuring that any invoked commands or writes will be executed promptly. However, if the update_rate is 5.0, then routine reads of instrument values will only occur every 50th poll (i.e. every 5 seconds).

  • command_update_rate (float) – similar to update_rate but for polled commands such as get_health_status.

  • max_fan_errors (int) – the maximum amount of consecutive estimated fan speed values that are out of bounds. These values are caused by out of sync rpm and pwm values when the fan changes speed (inertia).

  • max_fan_delta (float) – the percentage variance in fan max rpm. Any value within max_fan_delta % of the expected fan rpm is considered ok.

  • _driver (Optional[SubrackDriver]) – for testing only, we can inject a driver rather then letting the component manager create its own. If provided, this overrides driver-specific arguments such as the IP and port.

  • _initial_power_state (PowerState) – for testing only, we can set the initial power state of the simulated subrack power supply. If not provided, the default is ON, since all our current facilities with a real hardware subrack do not yet allow it to be powered on and off.

  • _initial_fail (bool) – for testing only, we can set the simulated subrack power supply to fail.

get_health_status(task_callback=None)

Read all the monitoring points available in health status.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

pdu_health_state()

Get PDU health.

Return type:

Optional[str]

Returns:

pdu health.

pdu_model()

Get PDU model type.

Return type:

Optional[str]

Returns:

pdu model type.

pdu_number_of_ports()

Get number of pdu ports .

Return type:

Optional[int]

Returns:

number of pdu ports

pdu_port_currents()

Get the currents for a pdu port.

Return type:

Optional[list[float]]

Returns:

pdu port currents.

pdu_port_states()

Get the states for a pdu port.

Return type:

Optional[list[int]]

Returns:

pdu port statuses.

pdu_port_voltages()

Get the voltages for a pdu port.

Return type:

Optional[list[float]]

Returns:

pdu port voltages.

power_pdu_port_off(port_number, task_callback=None, task_abort_event=None)

Turn a pdu port off.

Parameters:
  • port_number (int) – (one-based) number of the port to turn off.

  • task_callback (Optional[Callable]) – Update task state, defaults to None

  • task_abort_event (Optional[Event]) – Check for abort, defaults to None

Return type:

None

power_pdu_port_on(port_number, task_callback=None, task_abort_event=None)

Turn a pdu port on.

Parameters:
  • port_number (int) – (one-based) number of the port to turn on.

  • task_callback (Optional[Callable]) – Update task state, defaults to None

  • task_abort_event (Optional[Event]) – Check for abort, defaults to None

Return type:

None

read_health_status()

Read all the monitoring points available in health status.

Return type:

dict

Returns:

monitoring points available in health status.

schedule_off(task_callback=None, task_abort_event=None)

Turn self off.

Parameters:
  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

  • task_abort_event (Optional[Event]) – Check for abort, defaults to None

Return type:

None

schedule_on(task_callback=None, task_abort_event=None)

Schedule self on.

Parameters:
  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

  • task_abort_event (Optional[Event]) – Check for abort, defaults to None

Return type:

None

set_power_supply_fan_speed(fan_number, speed, task_callback=None)

Set the target speed of a power supply fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • speed (float) – speed setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

set_subrack_fan_mode(fan_number, mode, task_callback=None)

Set the target speed mode of a subrack fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • mode (FanMode) – speed mode setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

set_subrack_fan_speed(fan_number, speed, task_callback=None)

Set the target speed of a subrack fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • speed (float) – speed setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

start_communicating()

Establish communication with the subrack components.

Return type:

None

stop_communicating()

Break off communication with the subrack components.

Return type:

None

turn_off_tpm(tpm_number, task_callback=None)

Turn a TPM off.

Parameters:
  • tpm_number (int) – (one-based) number of the TPM to turn off.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

turn_off_tpms(task_callback=None)

Turn all TPMs off.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

turn_on_tpm(tpm_number, task_callback=None)

Turn a TPM on.

Parameters:
  • tpm_number (int) – (one-based) number of the TPM to turn on.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

turn_on_tpms(task_callback=None)

Turn all TPMs on.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

class SubrackData

This class contain data/facts about a subrack that are needed by multiple classes.

For example, the fact that a subrack contains 8 TPM bays is something that a subrack driver may need to know, a subrack Tango device may need to know, and a subrack simulator certainly needs to know. So rather than store this fact in three separate places, we store it here.

MAX_SUBRACK_FAN_SPEED = 6500.0

The maximum fan speed for the subrack.

This is from the fan’s datasheet, at 100% duty cycle, 12V

TPM_BAY_COUNT = 8

The number of TPM bays (some bays may be empty)

static bios_version(board_info)

Return the BIOS version reported in the board info.

Parameters:

board_info (dict) – the board info reported by the subrack.

Return type:

list[int]

Returns:

the BIOS version, e.g. [1, 8, 0].

static supports_power_supply_fan_speed(board_info)

Return whether the subrack can set the power supply fan speed.

API 1.8.0 has no set_power_supply_fan_speed command. Until the board info has been read, it is assumed to be supported.

Parameters:

board_info (Optional[dict]) – the board info reported by the subrack, if known.

Return type:

bool

Returns:

whether the subrack can set the power supply fan speed.

static supports_tpm_currents(board_info)

Return whether the subrack reports TPM currents.

From API 1.8.0 the SMB no longer reports TPM currents. Until the board info has been read, they are assumed to be supported.

Parameters:

board_info (Optional[dict]) – the board info reported by the subrack, if known.

Return type:

bool

Returns:

whether the subrack reports TPM currents.

class SubrackDriver(host, port, logger, communication_state_callback, component_state_callback, update_rate=5.0, command_update_rate=20.0, max_fan_errors=5, max_fan_delta=25, _subrack_client=None)

A component manager for an SPS subrack.

__init__(host, port, logger, communication_state_callback, component_state_callback, update_rate=5.0, command_update_rate=20.0, max_fan_errors=5, max_fan_delta=25, _subrack_client=None)

Initialise a new instance.

Parameters:
  • host (str) – the host name or IP address of the subrack management board.

  • port (int) – the port of the subrack management board.

  • logger (Logger) – a logger for this component manager to use for logging

  • communication_state_callback (Callable) – callback to be called when the status of communications between the component manager and its component changes.

  • component_state_callback (Callable) – callback to be called when the state of the component changes.

  • update_rate (float) – how often updates to attribute values should be provided. This is not necessarily the same as the rate at which the instrument is polled. For example, the instrument may be polled every 0.1 seconds, thus ensuring that any invoked commands or writes will be executed promptly. However, if the update_rate is 5.0, then routine reads of instrument values will only occur every 50th poll (i.e. every 5 seconds).

  • command_update_rate (float) – similar to update_rate but for polled commands.

  • max_fan_errors (int) – the maximum amount of consecutive estimeted fan speed values that are out of bounds. These values are caused by out of sync rpm and pwm values when the fan changes speed (inertia).

  • max_fan_delta (float) – the percentage variance in fan max rpm. Any value within max_fan_delta % of the expected fan rpm is considered ok.

  • _subrack_client (Optional[Any]) – an optional subrack client to use.

get_health_status(task_callback=None)

Read all the monitoring points available in health status.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

get_request()

Return the reads, writes and commands to be executed in the next poll.

Return type:

HttpPollRequest

Returns:

reads, writes and commands to be executed in the next poll.

off(task_callback=None)

Turn the component off.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Raises:

NotImplementedError – because this command is not yet implemented

Return type:

tuple[TaskStatus, str]

on(task_callback=None)

Turn the component on.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Raises:

NotImplementedError – because this command is not yet implemented

Return type:

tuple[TaskStatus, str]

poll(poll_request)

Poll the hardware.

Connect to the hardware, write any values that are to be written, and then read all values.

Parameters:

poll_request (HttpPollRequest) – specification of the reads and writes to be performed in this poll.

Raises:
  • RequestError – When the client returns HardwareClientResponseStatusCodes.REQUEST_EXCEPTION

  • HttpError – When the client returns HardwareClientResponseStatusCodes.HTTP_ERROR

  • ValueError – When the client returns an unknown HardwareClientResponseStatusCodes.

Return type:

HttpPollResponse

Returns:

responses to queries in this poll

poll_failed(exception)

Override parent to set PowerState.UNKNOWN when polling fails.

This is a bug fix that should be upstreamed to ska-tango-base - see MR https://gitlab.com/ska-telescope/ska-tango-base/-/merge_requests/133

Parameters:

exception (Exception) – the exception that was raised by a recent poll attempt.

Return type:

None

poll_succeeded(poll_response)

Handle the receipt of new polling values.

This is a hook called by the poller when values have been read during a poll.

Parameters:

poll_response (HttpPollResponse) – response to the pool, including any values read.

Return type:

None

polling_stopped()

Respond to polling having stopped.

This is a hook called by the poller when it stops polling.

Return type:

None

power_pdu_port_off(port_number, task_callback=None)

Turn a pdu port off.

Parameters:
  • port_number (int) – (one-based) number of the pdu port to turn off.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

power_pdu_port_on(port_number, task_callback=None)

Turn a pdu port on.

Parameters:
  • port_number (int) – (one-based) number of the pdu port to turn on.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

read_health_status()

Read all the monitoring points available in health status.

Return type:

dict

Returns:

the task status and a human-readable status message

reset(task_callback=None)

Reset the component (from fault state).

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Raises:

NotImplementedError – because this command is not yet implemented

Return type:

tuple[TaskStatus, str]

set_power_supply_fan_speed(fan_number, speed, task_callback=None)

Set the target speed of a power supply fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • speed (float) – speed setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

set_subrack_fan_mode(fan_number, mode, task_callback=None)

Set the target speed mode of a subrack fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • mode (FanMode) – speed mode setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

set_subrack_fan_speed(fan_number, speed, task_callback=None)

Set the target speed of a subrack fan.

Parameters:
  • fan_number (int) – one-based number of the fan to be set.

  • speed (float) – speed setting for the fan.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

standby(task_callback=None)

Put the component into low-power standby mode.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Raises:

NotImplementedError – because this command is not yet implemented

Return type:

tuple[TaskStatus, str]

turn_off_tpm(tpm_number, task_callback=None)

Turn a TPM off.

Parameters:
  • tpm_number (int) – (one-based) number of the TPM to turn off.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

turn_off_tpms(task_callback=None)

Turn all TPMs off.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

turn_on_tpm(tpm_number, task_callback=None)

Turn a TPM on.

Parameters:
  • tpm_number (int) – (one-based) number of the TPM to turn on.

  • task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

turn_on_tpms(task_callback=None)

Turn all TPMs on.

Parameters:

task_callback (Optional[Callable]) – callback to be called when the status of the command changes

Return type:

None

write_attribute(**kwargs)

Update subrack attribute value(s).

This doesn’t actually immediately write to the subrack. It only stores the details of the requested write where it will be picked up by the next iteration of the polling loop.

Parameters:

kwargs (Any) – keyword arguments specifying attributes to be written along with their corresponding value.

Return type:

None

class SubrackHealthModel(component_state_changed_callback, thresholds=None)

A health model for a subrack.

__init__(component_state_changed_callback, thresholds=None)

Initialise a new instance.

Parameters:
  • component_state_changed_callback (HealthChangedCallbackProtocol) – callback to be called whenever there is a change to this this health model’s evaluated health state.

  • thresholds (Optional[dict[str, Any]]) – Thresholds for the subrack device.

evaluate_health()

Compute overall health of the subrack.

The overall health is based on the fault and communication status of the subrack overall, together with the health of the tpms that it manages.

This implementation simply sets the health of the subrack to the health of its least healthy component.

Return type:

tuple[HealthState, str]

Returns:

an overall health of the subrack

update_data(new_states)

Update this health model with state relevant to evaluating health.

Parameters:

new_states (dict) – New states of the data points.

Return type:

None

class SubrackSimulator(bios_version='1.6.0', **kwargs)

A simple simulator of a subrack management board web server.

__init__(bios_version='1.6.0', **kwargs)

Initialise a new instance.

Parameters:
  • bios_version (str) – the SMM BIOS version whose web API the simulator should emulate. It is also reported in board_info.

  • kwargs (Any) – initial values, different from the defaults, that the simulator should take.

Raises:
property bios_version: str

Return the SMM BIOS version whose web API this simulator emulates.

Returns:

the emulated BIOS version, e.g. “1.8.0”.

execute_command(name, argument)

Execute a command on the subrack hardware/simulator.

It works by checking for a method named f”_{name}”; that is, if the command name is “turn_on_tpms”, then it checks for a method named “_turn_on_tpms”. If it finds such a method, it calls it with the provided argument, and returns the return value.

Otherwise, it checks for a method named f”_async_{name}; for example, “_async_turn_on_tpms”. If it finds such a method, it simulates a long running command by returning “STARTED”, then letting a little time pass, then invoking the method.

Parameters:
  • name (str) – name of the command to execute.

  • argument (Optional[Any]) – argument to the command.

Return type:

Any

Returns:

the return value. For synchronous commands, this is the returned value of the fully executed command. For asynchronous commands, this is the string “STARTED” or “FAILED”.

Raises:

AttributeError – if the command method does not exist in the simulator.

get_attribute(name)

Return the value of a simulator attribute.

Parameters:

name (str) – name of the simulator attribute to be returned.

Return type:

Any

Returns:

the value of the attribute

Raises:

RuntimeError – if a failure of the attribute is being simulated.

property network_jitter_limits: tuple[int, int]

Return the max network jitter in miliseconds.

Returns:

the maximum network jitter in milliseconds.

set_attribute(name, value)

Set the value of a simulator attribute.

Parameters:
  • name (str) – name of the simulator attribute to be set.

  • value (Any) – new values for the simulator attribute

Raises:

AttributeError – If name is not a valid attribute

Return type:

Any

Returns:

the new values for the attribute

simulate_attribute(name, values)

Simulate a change in attribute value.

Parameters:
  • name (str) – name of the simulator attribute to be set.

  • values (Any) – new values for the simulator attribute

Return type:

Any

Returns:

the new values for the attribute

simulate_attribute_failure(name, failing=True)

Simulate a failure to read an attribute.

While an attribute is failing, every read of it raises an exception, which the web API reports as an ERROR response.

Parameters:
  • name (str) – name of the simulator attribute.

  • failing (bool) – whether reads of the attribute should fail.

Raises:

AttributeError – if the attribute does not exist.

Return type:

None