docs: add more documentation to classes

This commit is contained in:
George Rawlinson 2020-11-20 07:50:15 +13:00
parent e0c916b6ae
commit ee759011b3
Signed by: grawlinson
GPG key ID: E0959FEA8B550539
2 changed files with 59 additions and 18 deletions

View file

@ -24,6 +24,7 @@ class Client:
username: Username. username: Username.
password: Password. password: Password.
session_timeout: Session timeout of the BMC (in minutes). session_timeout: Session timeout of the BMC (in minutes).
default: 30 minutes.
""" """
self.server = server self.server = server
self.username = username self.username = username
@ -84,7 +85,8 @@ class Client:
"""Acquire metrics for all power supplies. """Acquire metrics for all power supplies.
Returns: Returns:
str: XML response. list[PowerSupply]: All power supplies available on the PMBus
interface.
""" """
r = self._query( r = self._query(
data={ data={
@ -101,7 +103,7 @@ class Client:
"""Acquire metrics for all sensors. """Acquire metrics for all sensors.
Returns: Returns:
str: XML response. list[Sensor]: A list of all sensors available to the BMC.
""" """
r = self._query( r = self._query(
data={ data={
@ -115,7 +117,7 @@ class Client:
return sensors return sensors
def get_metrics(self, metrics=["pmbus", "sensor"]): # noqa: C901 def get_metrics(self, metrics=["pmbus", "sensor"]): # noqa: C901
"""Fetch metrics with minimum network calls. """Fetch all metrics available.
Args: Args:
metrics: List of metric(s) to query. metrics: List of metric(s) to query.

View file

@ -4,7 +4,14 @@ from enum import IntFlag
class SensorStateEnum(IntEnum): class SensorStateEnum(IntEnum):
"""Enumeration of sensor states.""" """Enumeration of sensor states.
Possible Values:
- Unspecified
- Present
- Not Present
"""
UNSPECIFIED = 0 UNSPECIFIED = 0
PRESENT = 1 PRESENT = 1
@ -12,7 +19,17 @@ class SensorStateEnum(IntEnum):
class SensorUnitEnum(IntEnum): class SensorUnitEnum(IntEnum):
"""Enumeration of sensor units.""" """Enumeration of sensor units.
Possible Values:
- Unspecified
- degrees Celsius (°C)
- Volts (V)
- Amps (A)
- Watts (W)
- revolutions per minute (rpm)
"""
UNSPECIFIED = 0 UNSPECIFIED = 0
DEGREES_CELSIUS = 1 DEGREES_CELSIUS = 1
@ -23,7 +40,16 @@ class SensorUnitEnum(IntEnum):
class SensorTypeEnum(IntEnum): class SensorTypeEnum(IntEnum):
"""Enumeration of sensor types.""" """Enumeration of sensor types.
Possible Values:
- Unspecified
- Temperature
- Voltage
- Fan
- Power Supply
"""
UNSPECIFIED = 0 UNSPECIFIED = 0
TEMPERATURE = 1 TEMPERATURE = 1
@ -33,7 +59,20 @@ class SensorTypeEnum(IntEnum):
class PowerSupplyFlag(IntFlag): class PowerSupplyFlag(IntFlag):
"""Flags for power supply specific events.""" """Bitflag for power supply specific events.
Flags:
- Unspecified
- Presence Detected
- Failure
- Predictive Failure
- Source Input Lost
- Source Input Out of Range
- Source Input Detected (Out of Range)
- Configuration Error
- Standby
"""
UNSPECIFIED = 0 UNSPECIFIED = 0
PRESENCE_DETECTED = 1 PRESENCE_DETECTED = 1
@ -53,16 +92,16 @@ class Sensor:
id: Psuedo-unique id. id: Psuedo-unique id.
name: Sensor name. name: Sensor name.
type: Sensor type. type: Sensor type.
unit: Reading unit. e.g. Temperature - degrees Celsius. unit: Reading unit.
state: Sensor state. state: Sensor state.
flags: Discrete sensors only; type specific flags. flags: Discrete sensors only; type specific flags.
reading: Sensor reading. reading: Sensor reading.
lnr: Lower non-recoverable indicator. lnr: Lower non-recoverable threshold.
lc: Lower critical indicator. lc: Lower critical threshold.
lnc: Lower non-critical indicator. lnc: Lower non-critical threshold.
unc: Upper non-critical indicator. unc: Upper non-critical threshold.
uc: Upper critical indicator. uc: Upper critical threshold.
unr: Upper non-recoverable indicator. unr: Upper non-recoverable threshold.
""" """
def __init__(self): def __init__(self):
@ -97,10 +136,10 @@ class PowerSupply:
output_voltage: Output voltage (V_DC). output_voltage: Output voltage (V_DC).
output_current: Output current (A). output_current: Output current (A).
output_power: Output power (W). output_power: Output power (W).
temp_1: Temperature 1. Possibly intake (degrees Celsius). temp_1: Temperature 1. Possibly intake (°C).
temp_2: Temperature 2. Possibly outlet (degrees Celsius). temp_2: Temperature 2. Possibly outlet (°C).
fan_1: Fan 1. Possibly intake (r.p.m.). fan_1: Fan 1. Possibly intake (rpm).
fan_2: Fan 2. Possibly outlet (r.p.m.). fan_2: Fan 2. Possibly outlet (rpm).
""" """
def __init__(self): def __init__(self):