Skip to content

Commit

Permalink
Abstract out ElementStatus and ElementType for reuse
Browse files Browse the repository at this point in the history
Also add RedfishStatusHealth and RedfishStatusState enums
  • Loading branch information
bmeagherix committed Jun 26, 2024
1 parent 54943cd commit c3a25b2
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 35 deletions.
73 changes: 38 additions & 35 deletions src/middlewared/middlewared/plugins/enclosure_/element_types.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .enums import ElementStatus, ElementType


def alarm(value_raw):
"""See SES-4 7.3.8 Audible Alarm element, Table 98 — Audible Alarm status element
Expand Down Expand Up @@ -224,15 +227,15 @@ def sas_exp(value_raw):

# See SES-4 7.2.3 Status element format, Table 74 — ELEMENT STATUS CODE field
ELEMENT_DESC = {
0: 'Unsupported',
1: 'OK',
2: 'Critical',
3: 'Noncritical',
4: 'Unrecoverable',
5: 'Not installed',
6: 'Unknown',
7: 'Not available',
8: 'No access allowed',
0: ElementStatus.UNSUPPORTED.value,
1: ElementStatus.OK.value,
2: ElementStatus.CRITICAL.value,
3: ElementStatus.NONCRITICAL.value,
4: ElementStatus.UNRECOVERABLE.value,
5: ElementStatus.NOT_INSTALLED.value,
6: ElementStatus.UNKNOWN.value,
7: ElementStatus.NOT_AVAILABLE.value,
8: ElementStatus.NO_ACCESS_ALLOWED.value,
9: 'reserved [9]',
10: 'reserved [10]',
11: 'reserved [11]',
Expand All @@ -247,30 +250,30 @@ def sas_exp(value_raw):
21: 'Not Installed, Swapped',
}
ELEMENT_TYPES = {
0: ('Unspecified', lambda *args: None),
1: ('Device Slot', lambda *args: None),
2: ('Power Supply', psu),
3: ('Cooling', cooling),
4: ('Temperature Sensors', temp),
5: ('Door Lock', lambda *args: None),
6: ('Audible Alarm', alarm),
7: ('Enclosure Services Controller Electronics', lambda *args: None),
8: ('SCC Controller Electronics', lambda *args: None),
9: ('Nonvolatile Cache', lambda *args: None),
10: ('Invalid Operation Reason', lambda *args: None),
11: ('Uninterruptible Power Supply', lambda *args: None),
12: ('Display', lambda *args: None),
13: ('Key Pad Entry', lambda *args: None),
14: ('Enclosure', enclosure),
15: ('SCSI Port/Transciever', lambda *args: None),
16: ('Language', lambda *args: None),
17: ('Communication Port', comm),
18: ('Voltage Sensor', volt),
19: ('Current Sensor', current),
20: ('SCSI Target Port', lambda *args: None),
21: ('SCSI Initiator Port', lambda *args: None),
22: ('Simple Subenclosure', lambda *args: None),
23: ('Array Device Slot', array_dev),
24: ('SAS Expander', sas_exp),
25: ('SAS Connector', sas_conn),
0: (ElementType.UNSPECIFIED.value, lambda *args: None),
1: (ElementType.DEVICE_SLOT.value, lambda *args: None),
2: (ElementType.POWER_SUPPLY.value, psu),
3: (ElementType.COOLING.value, cooling),
4: (ElementType.TEMPERATURE_SENSORS.value, temp),
5: (ElementType.DOOR_LOCK.value, lambda *args: None),
6: (ElementType.AUDIBLE_ALARM.value, alarm),
7: (ElementType.ENCLOSURE_SERVICES_CONTROLLER_ELECTRONICS.value, lambda *args: None),
8: (ElementType.SCC_CONTROLLER_ELECTRONICS.value, lambda *args: None),
9: (ElementType.NONVOLATILE_CACHE.value, lambda *args: None),
10: (ElementType.INVALID_OPERATION_REASON.value, lambda *args: None),
11: (ElementType.UNINTERRUPTIBLE_POWER_SUPPLY.value, lambda *args: None),
12: (ElementType.DISPLAY.value, lambda *args: None),
13: (ElementType.KEY_PAD_ENTRY.value, lambda *args: None),
14: (ElementType.ENCLOSURE.value, enclosure),
15: (ElementType.SCSI_PORT_TRANSCEIVER.value, lambda *args: None),
16: (ElementType.LANGUAGE.value, lambda *args: None),
17: (ElementType.COMMUNICATION_PORT.value, comm),
18: (ElementType.VOLTAGE_SENSOR.value, volt),
19: (ElementType.CURRENT_SENSOR.value, current),
20: (ElementType.SCSI_TARGET_PORT.value, lambda *args: None),
21: (ElementType.SCSI_INITIATOR_PORT.value, lambda *args: None),
22: (ElementType.SIMPLE_SUBENCLOSURE.value, lambda *args: None),
23: (ElementType.ARRAY_DEVICE_SLOT.value, array_dev),
24: (ElementType.SAS_EXPANDER.value, sas_exp),
25: (ElementType.SAS_CONNECTOR.value, sas_conn),
}
70 changes: 70 additions & 0 deletions src/middlewared/middlewared/plugins/enclosure_/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,73 @@ class JbofModels(Enum):
# name is iX's model (ES24N)
# while the value (VDS2249R2) is the OEM's model
ES24N = 'VDS2249R2'


# See SES-4 7.2.3 Status element format, Table 74 — ELEMENT STATUS CODE field
@unique
class ElementStatus(Enum):
UNSUPPORTED = 'Unsupported'
OK = 'OK'
CRITICAL = 'Critical'
NONCRITICAL = 'Noncritical'
UNRECOVERABLE = 'Unrecoverable'
NOT_INSTALLED = 'Not installed'
UNKNOWN = 'Unknown'
NOT_AVAILABLE = 'Not available'
NO_ACCESS_ALLOWED = 'No access allowed'


# See SES-4 7.1 Element definitions overview, Table 71 — Element type codes
@unique
class ElementType(Enum):
UNSPECIFIED = 'Unspecified'
DEVICE_SLOT = 'Device Slot'
POWER_SUPPLY = 'Power Supply'
COOLING = 'Cooling'
TEMPERATURE_SENSORS = 'Temperature Sensors'
DOOR_LOCK = 'Door Lock'
AUDIBLE_ALARM = 'Audible Alarm'
ENCLOSURE_SERVICES_CONTROLLER_ELECTRONICS = 'Enclosure Services Controller Electronics'
SCC_CONTROLLER_ELECTRONICS = 'SCC Controller Electronics'
NONVOLATILE_CACHE = 'Nonvolatile Cache'
INVALID_OPERATION_REASON = 'Invalid Operation Reason'
UNINTERRUPTIBLE_POWER_SUPPLY = 'Uninterruptible Power Supply'
DISPLAY = 'Display'
KEY_PAD_ENTRY = 'Key Pad Entry'
ENCLOSURE = 'Enclosure'
SCSI_PORT_TRANSCEIVER = 'SCSI Port/Transciever'
LANGUAGE = 'Language'
COMMUNICATION_PORT = 'Communication Port'
VOLTAGE_SENSOR = 'Voltage Sensor'
CURRENT_SENSOR = 'Current Sensor'
SCSI_TARGET_PORT = 'SCSI Target Port'
SCSI_INITIATOR_PORT = 'SCSI Initiator Port'
SIMPLE_SUBENCLOSURE = 'Simple Subenclosure'
ARRAY_DEVICE_SLOT = 'Array Device Slot'
SAS_EXPANDER = 'SAS Expander'
SAS_CONNECTOR = 'SAS Connector'


# See DSP0268_2023.1 4.16.3.1 Health (https://www.dmtf.org/dsp/DSP0268)
@unique
class RedfishStatusHealth(Enum):
CRITICAL = 'Critical'
OK = 'OK'
WARNING = 'Warning'


# See DSP0268_2023.1 4.16.3.4 State (https://www.dmtf.org/dsp/DSP0268)
@unique
class RedfishStatusState(Enum):
ABSENT = 'Absent'
DEFERRING = 'Deferring'
DISABLED = 'Disabled'
ENABLED = 'Enabled'
INTEST = 'InTest'
QUALIFIED = 'Qualified'
QUIESCED = 'Quiesced'
STANDBY_OFFLINE = 'StandbyOffline'
STANDBY_SPARE = 'StandbySpare'
STARTING = 'Starting'
UNAVAILABLE_OFFLINE = 'UnavailableOffline'
UPDATING = 'Updating'

0 comments on commit c3a25b2

Please sign in to comment.