示例#1
0
    def test_set_fans_led(self, duthosts, enum_rand_one_per_hwsku_hostname,
                          localhost, platform_api_conn):
        LED_COLOR_LIST = [
            "off",
            "red",
            "amber",
            "green",
        ]

        for i in range(self.num_fans):
            for color in LED_COLOR_LIST:

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

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

        self.assert_expectations()
示例#2
0
    def test_set_fans_led(self, duthosts, enum_rand_one_per_hwsku_hostname, localhost, platform_api_conn):
        LED_COLOR_LIST = [
            "off",
            "red",
            "amber",
            "green",
        ]
        duthost = duthosts[enum_rand_one_per_hwsku_hostname]
        fans_skipped = 0

        for i in range(self.num_fans):
            led_controllable = self.get_fan_facts(duthost, i, True, "status_led", "controllable")
            if not led_controllable:
                logger.info("test_set_fans_led: Skipping chassis fan {} (LED not controllable)".format(i))
                fans_skipped += 1
                continue

            LED_COLOR_LIST = self.get_fan_facts(duthost, i, LED_COLOR_LIST, "status_led", "colors")
            for color in LED_COLOR_LIST:

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

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

        if fans_skipped == self.num_fans:
            pytest.skip("skipped as all chassis fans' LED is not controllable")

        self.assert_expectations()