コード例 #1
0
def fan_speed_info_get():
    for fan_num in range(1, _MAX_FAN + 1):
        def get_data(client, fan_num=fan_num):
            return client.pltfm_mgr.pltfm_mgr_fan_info_get(fan_num)
        fan_info = thrift_try(get_data)
        if fan_info.fan_num == fan_num:
            yield fan_info
コード例 #2
0
    def get_lpmode(self):
        """
        Retrieves the lpmode (low power mode) status of this SFP
        """
        def qsfp_lpmode_get(client):
            return client.pltfm_mgr.pltfm_mgr_qsfp_lpmode_get(self.index)

        return thrift_try(qsfp_lpmode_get)
コード例 #3
0
def _fan_info_get(fan_num, cb, default=None):
    def get_data(client):
        return client.pltfm_mgr.pltfm_mgr_fan_info_get(fan_num)

    fan_info = thrift_try(get_data)
    if fan_num == fan_info.fan_num:
        return cb(fan_info)
    if default is None:
        raise LookupError
    return default
コード例 #4
0
    def set_lpmode(self, lpmode):
        """
        Sets the lpmode (low power mode) of SFP
        """
        def qsfp_lpmode_set(client):
            return client.pltfm_mgr.pltfm_mgr_qsfp_lpmode_set(
                self.index, lpmode)

        status = thrift_try(qsfp_lpmode_set)
        return (status == 0)
コード例 #5
0
    def reset(self):
        """
        Reset SFP and return all user module settings to their default srate.
        """
        def qsfp_reset(client):
            client.pltfm_mgr.pltfm_mgr_qsfp_reset(self.index, True)
            return client.pltfm_mgr.pltfm_mgr_qsfp_reset(self.index, False)

        err = thrift_try(qsfp_reset)
        return not err
コード例 #6
0
    def get_eeprom_path(self):
        def qsfp_info_get(client):
            return client.pltfm_mgr.pltfm_mgr_qsfp_info_get(self.index)

        if self.get_presence():
            eeprom_hex = thrift_try(qsfp_info_get)
            eeprom_raw = bytearray.fromhex(eeprom_hex)
            with open(self.eeprom_path, 'wb') as fp:
                fp.write(eeprom_raw)
            return self.eeprom_path

        return None
コード例 #7
0
    def __update_port_info(self):
        def qsfp_max_port_get(client):
            return client.pltfm_mgr.pltfm_mgr_qsfp_get_max_port()

        if self.QSFP_PORT_END == 0:
            platform = device_info.get_platform()
            self.QSFP_PORT_END = thrift_try(qsfp_max_port_get)
            exclude_cpu_port = [
                "x86_64-accton_as9516_32d-r0", "x86_64-accton_as9516bf_32d-r0",
                "x86_64-accton_wedge100bf_32x-r0"
            ]
            if platform in exclude_cpu_port:
                self.QSFP_PORT_END -= 1
            self.PORT_END = self.QSFP_PORT_END
            self.PORTS_IN_BLOCK = self.QSFP_PORT_END
コード例 #8
0
def platform_sensors_get(args):
    options = ""
    if len(args) != 0:
        options = urllib.quote(" ".join(args))

    def get_data(client):
        return client.pltfm_mgr.pltfm_mgr_sensor_info_get(options)

    raw_out = thrift_try(get_data)
    raw_list = raw_out.split('\"')
    if len(raw_list) >= 2:
        sensors_out = raw_list[1]
        sensors_out = codecs.decode(sensors_out, "unicode_escape")
        return sensors_out
    return None
コード例 #9
0
    def get_presence(self):
        """
        Retrieves the presence of the sfp
        """
        presence = False

        def qsfp_presence_get(client):
            return client.pltfm_mgr.pltfm_mgr_qsfp_presence_get(self.index)

        try:
            presence = thrift_try(qsfp_presence_get)
        except Exception as e:
            print(e.__doc__)
            print(e.message)

        return presence
コード例 #10
0
    def tx_disable_channel(self, channel, disable):
        """
        Sets the tx_disable for specified SFP channels

        Args:
            channel : A hex of 4 bits (bit 0 to bit 3) which represent channel 0 to 3,
                      e.g. 0x5 for channel 0 and channel 2.
            disable : A boolean, True to disable TX channels specified in channel,
                      False to enable

        Returns:
            A boolean, True if successful, False if not
        """
        def qsfp_tx_disable_channel(client):
            return client.pltfm_mgr.pltfm_mgr_qsfp_tx_disable(
                self.index, channel, disable)

        if self.sfp_type == QSFP_TYPE:
            status = thrift_try(qsfp_tx_disable_channel)
            return (status == 0)
        return False
コード例 #11
0
    def set_speed(self, percent):
        def set_fan_speed(client):
            return client.pltfm_mgr.pltfm_mgr_fan_speed_set(fan, percent)

        return thrift_try(set_fan_speed)