Exemple #1
0
    def test_lpmode(self, duthosts, enum_rand_one_per_hwsku_hostname,
                    localhost, platform_api_conn):
        """This function tests both the get_lpmode() and set_lpmode() APIs"""
        for i in self.candidate_sfp:
            # First ensure that the transceiver type supports low-power mode
            info_dict = sfp.get_transceiver_info(platform_api_conn, i)
            if not self.expect(
                    info_dict is not None,
                    "Unable to retrieve transceiver {} info".format(i)):
                continue

            if not self.is_xcvr_optical(info_dict):
                logger.warning(
                    "test_lpmode: Skipping transceiver {} (not applicable for this transceiver type)"
                    .format(i))
                continue

            # Enable and disable low-power mode on each transceiver
            for state in [True, False]:
                ret = sfp.set_lpmode(platform_api_conn, i, state)
                self.expect(
                    ret is True,
                    "Failed to {} low-power mode for transceiver {}".format(
                        "enable" if state is True else "disable", i))
                lpmode = sfp.get_lpmode(platform_api_conn, i)
                if self.expect(
                        lpmode is not None,
                        "Unable to retrieve transceiver {} low-power mode".
                        format(i)):
                    self.expect(
                        lpmode == state,
                        "Transceiver {} low-power is incorrect".format(i))
        self.assert_expectations()
Exemple #2
0
 def _check_lpmode_status(self, sfp, platform_api_conn, i, state):
     return state == sfp.get_lpmode(platform_api_conn, i)