Пример #1
0
    def test_status_led(self, duthost, localhost, platform_api_conn):
        # TODO: Get a platform-specific list of available colors for the status LED
        LED_COLOR_LIST = [
            "off",
            "red",
            "amber",
            "green",
        ]

        for color in LED_COLOR_LIST:
            result = chassis.set_status_led(platform_api_conn, color)
            if self.expect(result is not None,
                           "Failed to perform set_status_led"):
                self.expect(result is True,
                            "Failed to set status_led to {}".format(color))

            color_actual = chassis.get_status_led(platform_api_conn)
            if self.expect(color_actual is not None,
                           "Failed to retrieve status_led"):
                if self.expect(isinstance(color_actual, str),
                               "Status LED color appears incorrect"):
                    self.expect(
                        color == color_actual,
                        "Status LED color incorrect (expected: {}, actual: {})"
                        .format(color, color_actual))
        self.assert_expectations()
Пример #2
0
    def test_status_led(self, duthosts, enum_rand_one_per_hwsku_hostname,
                        localhost, platform_api_conn):
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        # TODO: Get a platform-specific list of available colors for the status LED

        FAULT_LED_COLOR_LIST = ["amber", "red"]

        NORMAL_LED_COLOR_LIST = ["green"]

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

        self.assert_expectations()
Пример #3
0
    def test_status_led(self, duthosts, enum_rand_one_per_hwsku_hostname,
                        localhost, platform_api_conn):
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        # TODO: Get a platform-specific list of available colors for the status LED

        FAULT_LED_COLOR_LIST = ["amber", "red"]

        NORMAL_LED_COLOR_LIST = ["green"]

        OFF_LED_COLOR_LIST = ["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"}

        led_controllable = True
        led_supported_colors = []
        if duthost.facts.get("chassis"):
            status_led = duthost.facts.get("chassis").get("status_led")
            if status_led:
                led_controllable = status_led.get("controllable", True)
                led_supported_colors = status_led.get("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 set status_led to {} (No supported colors)"
                            .format(LED_COLOR_TYPES_DICT[index]))
                        led_type_skipped += 1
                        continue

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

            if led_type_skipped == len(LED_COLOR_TYPES):
                pytest.skip("skipped as no supported colors for all types")

        else:
            pytest.skip("skipped as chassis's status led is not controllable")

        self.assert_expectations()