Exemple #1
0
    def test_set_fans_led(self, duthost, localhost, platform_api_conn):
        LED_COLOR_LIST = [
            "off",
            "red",
            "amber",
            "green",
        ]


        for j in range(self.num_fan_drawers):
            num_fans = fan_drawer.get_num_fans(platform_api_conn, j)

            for i in range(num_fans):

                for color in LED_COLOR_LIST:

                    result = fan_drawer_fan.set_status_led(platform_api_conn, j, 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 {} fan {} to {}".format(j , i, color))

                    color_actual = fan_drawer_fan.get_status_led(platform_api_conn, j, 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 {})".format(
                                color, color_actual, i))

        self.assert_expectations()
    def test_set_fans_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 j in range(self.num_fan_drawers):
            num_fans = fan_drawer.get_num_fans(platform_api_conn, j)

            for i in range(num_fans):
                for index, led_type in enumerate(LED_COLOR_TYPES):
                    led_type_result = False
                    for color in led_type:
                        result = fan_drawer_fan.set_status_led(
                            platform_api_conn, j, 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_fan.get_status_led(
                            platform_api_conn, j, 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 {})"
                                    .format(color, color_actual, i))
                    self.expect(
                        result is True,
                        "Failed to set status_led for fan drawer {} fan {} to {}"
                        .format(j, i, LED_COLOR_TYPES_DICT[index]))

        self.assert_expectations()
Exemple #3
0
    def test_set_fans_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 j in range(self.num_fan_drawers):
            num_fans = fan_drawer.get_num_fans(platform_api_conn, j)
            fans_skipped = 0

            for i in range(num_fans):
                led_controllable = self.get_fan_facts(duthost, j, i, True,
                                                      "status_led",
                                                      "controllable")
                led_supported_colors = self.get_fan_facts(
                    duthost, j, 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 {} fan {} set status_led to {} (No supported colors)"
                                    .format(j, i, LED_COLOR_TYPES_DICT[index]))
                                led_type_skipped += 1
                                continue

                        led_type_result = False
                        for color in led_type:
                            result = fan_drawer_fan.set_status_led(
                                platform_api_conn, j, 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_fan.get_status_led(
                                platform_api_conn, j, 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 {})"
                                        .format(color, color_actual, i))
                        self.expect(
                            result is True,
                            "Failed to set status_led for fan drawer {} fan {} to {}"
                            .format(j, i, LED_COLOR_TYPES_DICT[index]))

                    if led_type_skipped == len(LED_COLOR_TYPES):
                        logger.info(
                            "test_status_led: Skipping fandrawer {} fan {} (no supported colors for all types)"
                            .format(j, i))
                        fans_skipped += 1

                else:
                    logger.info(
                        "test_status_led: Skipping fandrawer {} fan {} (LED is not controllable)"
                        .format(j, i))
                    fans_skipped += 1

            if fans_skipped == num_fans:
                fan_drawers_skipped += 1

        if fan_drawers_skipped == self.num_fan_drawers:
            pytest.skip(
                "skipped as all fandrawer fans' LED is not controllable/no supported colors"
            )

        self.assert_expectations()