def test_set_fan_drawers_led(self, duthost, localhost, platform_api_conn): LED_COLOR_LIST = [ "off", "red", "amber", "green", ] for i in range(self.num_fan_drawers): for color in LED_COLOR_LIST: result = fan_drawer.set_status_led(platform_api_conn, i, color) if self.expect(result is not None, "Failed to perform set_status_led"): self.expect( result is True, "Failed to set status_led for fan_drawer {} to {}". format(i, color)) color_actual = fan_drawer.get_status_led(platform_api_conn, i) if self.expect(color_actual is not None, "Failed to retrieve status_led"): if self.expect(isinstance(color_actual, STRING_TYPE), "Status LED color appears incorrect"): self.expect( color == color_actual, "Status LED color incorrect (expected: {}, actual: {} for fan_drawer {})" .format(color, color_actual, i)) self.assert_expectations()
def test_set_fan_drawers_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): duthost = duthosts[enum_rand_one_per_hwsku_hostname] FAULT_LED_COLOR_LIST = [STATUS_LED_COLOR_AMBER, STATUS_LED_COLOR_RED] NORMAL_LED_COLOR_LIST = [STATUS_LED_COLOR_GREEN] OFF_LED_COLOR_LIST = [STATUS_LED_COLOR_OFF] LED_COLOR_TYPES = [] LED_COLOR_TYPES.append(FAULT_LED_COLOR_LIST) LED_COLOR_TYPES.append(NORMAL_LED_COLOR_LIST) # Mellanox is not supporting set leds to 'off' if duthost.facts.get("asic_type") != "mellanox": LED_COLOR_TYPES.append(OFF_LED_COLOR_LIST) LED_COLOR_TYPES_DICT = {0: "fault", 1: "normal", 2: "off"} for i in range(self.num_fan_drawers): for index, led_type in enumerate(LED_COLOR_TYPES): led_type_result = False for color in led_type: result = fan_drawer.set_status_led(platform_api_conn, i, color) if self.expect(result is not None, "Failed to perform set_status_led"): led_type_result = result or led_type_result if ((result is None) or (not result)): continue color_actual = fan_drawer.get_status_led( platform_api_conn, i) if self.expect(color_actual is not None, "Failed to retrieve status_led"): if self.expect(isinstance(color_actual, STRING_TYPE), "Status LED color appears incorrect"): self.expect( color == color_actual, "Status LED color incorrect (expected: {}, actual: {} for fan_drawer {})" .format(color, color_actual, i)) self.expect( led_type_result is True, "Failed to set status_led for fan_drawer {} to {}".format( i, LED_COLOR_TYPES_DICT[index])) self.assert_expectations()
def test_set_fan_drawers_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn): duthost = duthosts[enum_rand_one_per_hwsku_hostname] FAULT_LED_COLOR_LIST = [STATUS_LED_COLOR_AMBER, STATUS_LED_COLOR_RED] NORMAL_LED_COLOR_LIST = [STATUS_LED_COLOR_GREEN] OFF_LED_COLOR_LIST = [STATUS_LED_COLOR_OFF] LED_COLOR_TYPES = [] LED_COLOR_TYPES.append(FAULT_LED_COLOR_LIST) LED_COLOR_TYPES.append(NORMAL_LED_COLOR_LIST) # Mellanox is not supporting set leds to 'off' if duthost.facts.get("asic_type") != "mellanox": LED_COLOR_TYPES.append(OFF_LED_COLOR_LIST) LED_COLOR_TYPES_DICT = {0: "fault", 1: "normal", 2: "off"} fan_drawers_skipped = 0 for i in range(self.num_fan_drawers): led_controllable = self.get_fan_drawer_facts( duthost, i, True, "status_led", "controllable") led_supported_colors = self.get_fan_drawer_facts( duthost, i, None, "status_led", "colors") if led_controllable: led_type_skipped = 0 for index, led_type in enumerate(LED_COLOR_TYPES): if led_supported_colors: led_type = set(led_type) & set(led_supported_colors) if not led_type: logger.warning( "test_status_led: Skipping fandrawer {} set status_led to {} (No supported colors)" .format(i, LED_COLOR_TYPES_DICT[index])) led_type_skipped += 1 continue led_type_result = False for color in led_type: result = fan_drawer.set_status_led( platform_api_conn, i, color) if self.expect(result is not None, "Failed to perform set_status_led"): led_type_result = result or led_type_result if ((result is None) or (not result)): continue color_actual = fan_drawer.get_status_led( platform_api_conn, i) if self.expect(color_actual is not None, "Failed to retrieve status_led"): if self.expect( isinstance(color_actual, STRING_TYPE), "Status LED color appears incorrect"): self.expect( color == color_actual, "Status LED color incorrect (expected: {}, actual: {} for fan_drawer {})" .format(color, color_actual, i)) self.expect( led_type_result is True, "Failed to set status_led for fan_drawer {} to {}". format(i, LED_COLOR_TYPES_DICT[index])) if led_type_skipped == len(LED_COLOR_TYPES): logger.info( "test_status_led: Skipping fandrawer {} (no supported colors for all types)" .format(i)) fan_drawers_skipped += 1 else: logger.info( "test_status_led: Skipping fandrawer {} (LED is not controllable)" .format(i)) fan_drawers_skipped += 1 if fan_drawers_skipped == self.num_fan_drawers: pytest.skip( "skipped as all fandrawers' LED is not controllable/no supported colors" ) self.assert_expectations()