diff --git a/releasenotes/notes/indicator-led-mappings-e7b34da03f6abb06.yaml b/releasenotes/notes/indicator-led-mappings-e7b34da03f6abb06.yaml new file mode 100644 index 00000000..e5b6c828 --- /dev/null +++ b/releasenotes/notes/indicator-led-mappings-e7b34da03f6abb06.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Adds mappings and constants for possible values of the Indicator LED + value in the System class. diff --git a/sushy/resources/system/constants.py b/sushy/resources/system/constants.py index fc2ddb14..9e80b6ae 100644 --- a/sushy/resources/system/constants.py +++ b/sushy/resources/system/constants.py @@ -44,6 +44,20 @@ SYSTEM_POWER_STATE_POWERING_OFF = 'powering off' """A temporary state between On and Off. The power off action can take time while the OS is in the shutdown process""" +# Indicator LED Constants + +SYSTEM_INDICATOR_LED_LIT = 'Lit' +"""The Indicator LED is lit""" + +SYSTEM_INDICATOR_LED_BLINKING = 'Blinking' +"""The Indicator LED is blinking""" + +SYSTEM_INDICATOR_LED_OFF = 'Off' +"""The Indicator LED is off""" + +SYSTEM_INDICATOR_LED_UNKNOWN = 'Unknown' +"""The state of the Indicator LED cannot be determine""" + # Boot source target constants BOOT_SOURCE_TARGET_NONE = 'none' diff --git a/sushy/resources/system/mappings.py b/sushy/resources/system/mappings.py index fb6e5abd..a275eb01 100644 --- a/sushy/resources/system/mappings.py +++ b/sushy/resources/system/mappings.py @@ -39,6 +39,13 @@ SYSTEM_POWER_STATE_MAP = { SYSTEM_POWER_STATE_MAP_REV = utils.revert_dictionary(SYSTEM_POWER_STATE_MAP) +SYSTEM_INDICATOR_LED_MAP = { + 'Lit': sys_cons.SYSTEM_INDICATOR_LED_LIT, + 'Blinking': sys_cons.SYSTEM_INDICATOR_LED_BLINKING, + 'Off': sys_cons.SYSTEM_INDICATOR_LED_OFF, + 'Unknown': sys_cons.SYSTEM_INDICATOR_LED_UNKNOWN, +} + BOOT_SOURCE_TARGET_MAP = { 'None': sys_cons.BOOT_SOURCE_TARGET_NONE, 'Pxe': sys_cons.BOOT_SOURCE_TARGET_PXE, diff --git a/sushy/resources/system/system.py b/sushy/resources/system/system.py index fbf2c551..b2a53b23 100644 --- a/sushy/resources/system/system.py +++ b/sushy/resources/system/system.py @@ -88,8 +88,8 @@ class System(base.ResourceBase): identity = base.Field('Id', required=True) """The system identity string""" - # TODO(lucasagomes): Create mappings for the indicator_led - indicator_led = base.Field('IndicatorLED') + indicator_led = base.MappedField('IndicatorLED', + sys_maps.SYSTEM_INDICATOR_LED_MAP) """Whether the indicator LED is lit or off""" manufacturer = base.Field('Manufacturer') diff --git a/sushy/tests/unit/resources/system/test_system.py b/sushy/tests/unit/resources/system/test_system.py index c31a5214..1ec4faa3 100644 --- a/sushy/tests/unit/resources/system/test_system.py +++ b/sushy/tests/unit/resources/system/test_system.py @@ -47,7 +47,8 @@ class SystemTestCase(base.TestCase): self.assertEqual('Web Front End node', self.sys_inst.description) self.assertEqual('web483', self.sys_inst.hostname) self.assertEqual('437XR1138R2', self.sys_inst.identity) - self.assertEqual('Off', self.sys_inst.indicator_led) + self.assertEqual(sushy.SYSTEM_INDICATOR_LED_OFF, + self.sys_inst.indicator_led) self.assertEqual('Contoso', self.sys_inst.manufacturer) self.assertEqual('WebFrontEnd483', self.sys_inst.name) self.assertEqual('224071-J23', self.sys_inst.part_number)