Exemplo n.º 1
0
    def get_tx_power(self):
        """
        Retrieves the TX power of this SFP

        Returns:
            A list of four integer numbers, representing TX power in mW
            for channel 0 to channel 4.
            Ex. ['1.86', '1.86', '1.86', '1.86']
        """
        tx_power_list = []
        tx_power = "N/A"
        sfpd_obj = sff8472Dom()
        offset = DOM_OFFSET

        if not self.get_presence() or not sfpd_obj:
            return []

        dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
            (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH)
        if dom_channel_monitor_raw is not None:
            dom_voltage_data = sfpd_obj.parse_channel_monitor_params(
                dom_channel_monitor_raw, 0)
            tx_power = self.__convert_string_to_num(
                dom_voltage_data['data']['TXPower']['value'])

        tx_power_list.append(tx_power)
        tx_power_list.append("N/A")
        tx_power_list.append("N/A")
        tx_power_list.append("N/A")

        return tx_power_list
Exemplo n.º 2
0
    def get_voltage(self):
        """
        Retrieves the supply voltage of this SFP

        Returns:
            An integer number of supply voltage in mV
        """
        voltage = "N/A"
        sfpd_obj = sff8472Dom()
        offset = DOM_OFFSET

        if not self.get_presence() or not sfpd_obj:
            return voltage

        eeprom_ifraw = self.__read_eeprom_specific_bytes(0, DOM_OFFSET)
        sfpi_obj = sff8472InterfaceId(eeprom_ifraw)
        cal_type = sfpi_obj.get_calibration_type()
        sfpd_obj._calibration_type = cal_type

        dom_voltage_raw = self.__read_eeprom_specific_bytes(
            (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH)
        if dom_voltage_raw is not None:
            dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
            voltage = self.__convert_string_to_num(
                dom_voltage_data['data']['Vcc']['value'])

        return voltage
Exemplo n.º 3
0
    def get_temperature(self):
        """
        Retrieves the temperature of this SFP

        Returns:
            An integer number of current temperature in Celsius
        """
        temp = "N/A"
        sfpd_obj = sff8472Dom()
        offset = DOM_OFFSET

        if not self.get_presence() or not sfpd_obj:
            return temp

        eeprom_ifraw = self.__read_eeprom_specific_bytes(0, DOM_OFFSET)
        sfpi_obj = sff8472InterfaceId(eeprom_ifraw)
        cal_type = sfpi_obj.get_calibration_type()
        sfpd_obj._calibration_type = cal_type

        dom_temperature_raw = self.__read_eeprom_specific_bytes(
            (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH)
        if dom_temperature_raw is not None:
            dom_temperature_data = sfpd_obj.parse_temperature(
                dom_temperature_raw, 0)
            temp = self.__convert_string_to_num(
                dom_temperature_data['data']['Temperature']['value'])

        return temp
Exemplo n.º 4
0
 def __init__(self, index, sfp_type, eeprom_path):
     SfpBase.__init__(self)
     self.sfp_type = sfp_type
     self.index = index
     self.eeprom_path = eeprom_path
     self.qsfpInfo = sff8436InterfaceId()
     self.qsfpDomInfo = sff8436Dom()
     self.sfpInfo = sff8472InterfaceId()
     self.sfpDomInfo = sff8472Dom(None, 1)
Exemplo n.º 5
0
 def __init__(self, index, sfp_type, eeprom_path):
     SfpBase.__init__(self)
     self.index = index
     self.eeprom_path = eeprom_path
     #sfp_type is the native port type and media_type is the transceiver type
     #media_type will be detected in get_transceiver_info
     self.sfp_type = sfp_type
     self.media_type = self.sfp_type
     self.qsfpInfo = sff8436InterfaceId()
     self.qsfpDomInfo = sff8436Dom()
     self.sfpInfo = sff8472InterfaceId()
     self.sfpDomInfo = sff8472Dom(None, 1)
Exemplo n.º 6
0
    def get_rx_power(self):
        """
        Retrieves the received optical power for this SFP
        Returns:
            A list of four integer numbers, representing received optical
            power in mW for channel 0 to channel 4.
            Ex. ['1.77', '1.71', '1.68', '1.70']
        """
        rx_power_list = []
        if self.sfp_type == COPPER_TYPE:
            return None

        if self.sfp_type == SFP_TYPE:

            offset = 256

            sfpd_obj = sff8472Dom()
            if sfpd_obj is None:
                return None

            self._dom_capability_detect()
            if self.dom_supported:
                sfpd_obj._calibration_type = self.calibration

                dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
                    (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH)
                if dom_channel_monitor_raw is not None:
                    dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(
                        dom_channel_monitor_raw, 0)
                    rx_power_list.append(
                        self.__convert_string_to_num(
                            dom_channel_monitor_data['data']['RXPower']
                            ['value']))
                else:
                    return None
            else:
                return None

        return rx_power_list
Exemplo n.º 7
0
    def get_transceiver_threshold_info(self):
        """
        Retrieves transceiver threshold info of this SFP
        Returns:
            A dict which contains following keys/values :
        ========================================================================
        keys                       |Value Format   |Information
        ---------------------------|---------------|----------------------------
        temphighalarm              |FLOAT          |High Alarm Threshold value of temperature in Celsius.
        templowalarm               |FLOAT          |Low Alarm Threshold value of temperature in Celsius.
        temphighwarning            |FLOAT          |High Warning Threshold value of temperature in Celsius.
        templowwarning             |FLOAT          |Low Warning Threshold value of temperature in Celsius.
        vcchighalarm               |FLOAT          |High Alarm Threshold value of supply voltage in mV.
        vcclowalarm                |FLOAT          |Low Alarm Threshold value of supply voltage in mV.
        vcchighwarning             |FLOAT          |High Warning Threshold value of supply voltage in mV.
        vcclowwarning              |FLOAT          |Low Warning Threshold value of supply voltage in mV.
        rxpowerhighalarm           |FLOAT          |High Alarm Threshold value of received power in dBm.
        rxpowerlowalarm            |FLOAT          |Low Alarm Threshold value of received power in dBm.
        rxpowerhighwarning         |FLOAT          |High Warning Threshold value of received power in dBm.
        rxpowerlowwarning          |FLOAT          |Low Warning Threshold value of received power in dBm.
        txpowerhighalarm           |FLOAT          |High Alarm Threshold value of transmit power in dBm.
        txpowerlowalarm            |FLOAT          |Low Alarm Threshold value of transmit power in dBm.
        txpowerhighwarning         |FLOAT          |High Warning Threshold value of transmit power in dBm.
        txpowerlowwarning          |FLOAT          |Low Warning Threshold value of transmit power in dBm.
        txbiashighalarm            |FLOAT          |High Alarm Threshold value of tx Bias Current in mA.
        txbiaslowalarm             |FLOAT          |Low Alarm Threshold value of tx Bias Current in mA.
        txbiashighwarning          |FLOAT          |High Warning Threshold value of tx Bias Current in mA.
        txbiaslowwarning           |FLOAT          |Low Warning Threshold value of tx Bias Current in mA.
        ========================================================================
        """
        # check present status
        sfpd_obj = sff8472Dom()

        if not self.get_presence() and not sfpd_obj:
            return {}

        eeprom_ifraw = self.__read_eeprom_specific_bytes(0, DOM_OFFSET)
        sfpi_obj = sff8472InterfaceId(eeprom_ifraw)
        cal_type = sfpi_obj.get_calibration_type()
        sfpd_obj._calibration_type = cal_type

        offset = DOM_OFFSET
        transceiver_dom_threshold_info_dict = dict.fromkeys(
            self.threshold_dict_keys, 'N/A')
        dom_module_threshold_raw = self.__read_eeprom_specific_bytes(
            (offset + SFP_MODULE_THRESHOLD_OFFSET), SFP_MODULE_THRESHOLD_WIDTH)
        if dom_module_threshold_raw is not None:
            dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold(
                dom_module_threshold_raw, 0)

            transceiver_dom_threshold_info_dict[
                'temphighalarm'] = dom_module_threshold_data['data'][
                    'TempHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'templowalarm'] = dom_module_threshold_data['data'][
                    'TempLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'temphighwarning'] = dom_module_threshold_data['data'][
                    'TempHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'templowwarning'] = dom_module_threshold_data['data'][
                    'TempLowWarning']['value']
            transceiver_dom_threshold_info_dict[
                'vcchighalarm'] = dom_module_threshold_data['data'][
                    'VoltageHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'vcclowalarm'] = dom_module_threshold_data['data'][
                    'VoltageLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'vcchighwarning'] = dom_module_threshold_data['data'][
                    'VoltageHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'vcclowwarning'] = dom_module_threshold_data['data'][
                    'VoltageLowWarning']['value']
            transceiver_dom_threshold_info_dict[
                'txbiashighalarm'] = dom_module_threshold_data['data'][
                    'BiasHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'txbiaslowalarm'] = dom_module_threshold_data['data'][
                    'BiasLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'txbiashighwarning'] = dom_module_threshold_data['data'][
                    'BiasHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'txbiaslowwarning'] = dom_module_threshold_data['data'][
                    'BiasLowWarning']['value']
            transceiver_dom_threshold_info_dict[
                'txpowerhighalarm'] = dom_module_threshold_data['data'][
                    'TXPowerHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'txpowerlowalarm'] = dom_module_threshold_data['data'][
                    'TXPowerLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'txpowerhighwarning'] = dom_module_threshold_data['data'][
                    'TXPowerHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'txpowerlowwarning'] = dom_module_threshold_data['data'][
                    'TXPowerLowWarning']['value']
            transceiver_dom_threshold_info_dict[
                'rxpowerhighalarm'] = dom_module_threshold_data['data'][
                    'RXPowerHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'rxpowerlowalarm'] = dom_module_threshold_data['data'][
                    'RXPowerLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'rxpowerhighwarning'] = dom_module_threshold_data['data'][
                    'RXPowerHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'rxpowerlowwarning'] = dom_module_threshold_data['data'][
                    'RXPowerLowWarning']['value']

        for key in transceiver_dom_threshold_info_dict:
            transceiver_dom_threshold_info_dict[
                key] = self._convert_string_to_num(
                    transceiver_dom_threshold_info_dict[key])

        return transceiver_dom_threshold_info_dict
Exemplo n.º 8
0
    def get_transceiver_bulk_status(self):
        """
        Retrieves transceiver bulk status of this SFP
        Returns:
            A dict which contains following keys/values :
        ========================================================================
        keys                       |Value Format   |Information
        ---------------------------|---------------|----------------------------
        rx_los                     |BOOLEAN        |RX loss-of-signal status, True if has RX los, False if not.
        tx_fault                   |BOOLEAN        |TX fault status, True if has TX fault, False if not.
        reset_status               |BOOLEAN        |reset status, True if SFP in reset, False if not.
        lp_mode                    |BOOLEAN        |low power mode status, True in lp mode, False if not.
        tx_disable                 |BOOLEAN        |TX disable status, True TX disabled, False if not.
        tx_disabled_channel        |HEX            |disabled TX channels in hex, bits 0 to 3 represent channel 0
                                   |               |to channel 3.
        temperature                |INT            |module temperature in Celsius
        voltage                    |INT            |supply voltage in mV
        tx<n>bias                  |INT            |TX Bias Current in mA, n is the channel number,
                                   |               |for example, tx2bias stands for tx bias of channel 2.
        rx<n>power                 |INT            |received optical power in mW, n is the channel number,
                                   |               |for example, rx2power stands for rx power of channel 2.
        tx<n>power                 |INT            |TX output power in mW, n is the channel number,
                                   |               |for example, tx2power stands for tx power of channel 2.
        ========================================================================
        """
        # check present status
        sfpd_obj = sff8472Dom()
        if not self.get_presence() or not sfpd_obj:
            return {}

        eeprom_ifraw = self.__read_eeprom_specific_bytes(0, DOM_OFFSET)
        sfpi_obj = sff8472InterfaceId(eeprom_ifraw)
        cal_type = sfpi_obj.get_calibration_type()
        sfpd_obj._calibration_type = cal_type

        offset = DOM_OFFSET
        transceiver_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A')
        dom_temperature_raw = self.__read_eeprom_specific_bytes(
            (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH)

        if dom_temperature_raw is not None:
            dom_temperature_data = sfpd_obj.parse_temperature(
                dom_temperature_raw, 0)
            transceiver_dom_info_dict['temperature'] = dom_temperature_data[
                'data']['Temperature']['value']

        dom_voltage_raw = self.__read_eeprom_specific_bytes(
            (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH)
        if dom_voltage_raw is not None:
            dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
            transceiver_dom_info_dict['voltage'] = dom_voltage_data['data'][
                'Vcc']['value']

        dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
            (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH)
        if dom_channel_monitor_raw is not None:
            dom_voltage_data = sfpd_obj.parse_channel_monitor_params(
                dom_channel_monitor_raw, 0)
            transceiver_dom_info_dict['tx1power'] = dom_voltage_data['data'][
                'TXPower']['value']
            transceiver_dom_info_dict['rx1power'] = dom_voltage_data['data'][
                'RXPower']['value']
            transceiver_dom_info_dict['tx1bias'] = dom_voltage_data['data'][
                'TXBias']['value']

        for key in transceiver_dom_info_dict:
            transceiver_dom_info_dict[key] = self._convert_string_to_num(
                transceiver_dom_info_dict[key])

        transceiver_dom_info_dict['rx_los'] = self.get_rx_los()
        transceiver_dom_info_dict['tx_fault'] = self.get_tx_fault()
        transceiver_dom_info_dict['reset_status'] = self.get_reset_status()
        transceiver_dom_info_dict['lp_mode'] = self.get_lpmode()

        return transceiver_dom_info_dict
Exemplo n.º 9
0
    def get_transceiver_dom_info_dict(self, port_num):
        transceiver_dom_info_dict = {}

        logger.log_debug("QFX5200: get_transceiver_dom_info_dict Start")
        if port_num in self.osfp_ports:
            # Below part is added to avoid fail xcvrd, shall be implemented later
            transceiver_dom_info_dict['temperature'] = 'N/A'
            transceiver_dom_info_dict['voltage'] = 'N/A'
            transceiver_dom_info_dict['rx1power'] = 'N/A'
            transceiver_dom_info_dict['rx2power'] = 'N/A'
            transceiver_dom_info_dict['rx3power'] = 'N/A'
            transceiver_dom_info_dict['rx4power'] = 'N/A'
            transceiver_dom_info_dict['tx1bias'] = 'N/A'
            transceiver_dom_info_dict['tx2bias'] = 'N/A'
            transceiver_dom_info_dict['tx3bias'] = 'N/A'
            transceiver_dom_info_dict['tx4bias'] = 'N/A'
            transceiver_dom_info_dict['tx1power'] = 'N/A'
            transceiver_dom_info_dict['tx2power'] = 'N/A'
            transceiver_dom_info_dict['tx3power'] = 'N/A'
            transceiver_dom_info_dict['tx4power'] = 'N/A'

        elif port_num in self.qsfp_ports:
            offset = 0
            offset_xcvr = 128
            file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR)
            if not self._sfp_eeprom_present(file_path, 0):
                return None

            try:
                sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
            except IOError:
                print("Error: reading sysfs file %s" % file_path)
                return None

            sfpd_obj = sff8436Dom()
            if sfpd_obj is None:
                return None

            sfpi_obj = sff8436InterfaceId()
            if sfpi_obj is None:
                return None

            # QSFP capability byte parse, through this byte can know whether it support tx_power or not.
            # TODO: in the future when decided to migrate to support SFF-8636 instead of SFF-8436,
            # need to add more code for determining the capability and version compliance
            # in SFF-8636 dom capability definitions evolving with the versions.
            qsfp_dom_capability_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom, (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH)
            if qsfp_dom_capability_raw is not None:
                qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(qsfp_dom_capability_raw, 0)
            else:
                return None

            dom_temperature_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom, (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH)
            if dom_temperature_raw is not None:
                dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0)
            else:
                return None

            dom_voltage_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom, (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH)
            if dom_voltage_raw is not None:
                dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
            else:
                return None

            qsfp_dom_rev_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom, (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH)
            if qsfp_dom_rev_raw is not None:
                qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(qsfp_dom_rev_raw, 0)
            else:
                return None

            transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value']
            transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value']

            # The tx_power monitoring is only available on QSFP which compliant with SFF-8636
            # and claimed that it support tx_power with one indicator bit.
            dom_channel_monitor_data = {}
            qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value']
            qsfp_tx_power_support = qspf_dom_capability_data['data']['Tx_power_support']['value']
            if (qsfp_dom_rev[0:8] != 'SFF-8636' or (qsfp_dom_rev[0:8] == 'SFF-8636' and qsfp_tx_power_support != 'on')):
                dom_channel_monitor_raw = self._read_eeprom_specific_bytes(
                    sysfsfile_eeprom, (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH)
                if dom_channel_monitor_raw is not None:
                    dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0)
                else:
                    return None

                transceiver_dom_info_dict['tx1power'] = 'N/A'
                transceiver_dom_info_dict['tx2power'] = 'N/A'
                transceiver_dom_info_dict['tx3power'] = 'N/A'
                transceiver_dom_info_dict['tx4power'] = 'N/A'
            else:
                dom_channel_monitor_raw = self._read_eeprom_specific_bytes(
                    sysfsfile_eeprom, (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH)
                if dom_channel_monitor_raw is not None:
                    dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power(
                        dom_channel_monitor_raw, 0)
                else:
                    return None

                transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TX1Power']['value']
                transceiver_dom_info_dict['tx2power'] = dom_channel_monitor_data['data']['TX2Power']['value']
                transceiver_dom_info_dict['tx3power'] = dom_channel_monitor_data['data']['TX3Power']['value']
                transceiver_dom_info_dict['tx4power'] = dom_channel_monitor_data['data']['TX4Power']['value']

            try:
                sysfsfile_eeprom.close()
            except IOError:
                print("Error: closing sysfs file %s" % file_path)
                return None

            transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value']
            transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value']
            transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RX1Power']['value']
            transceiver_dom_info_dict['rx2power'] = dom_channel_monitor_data['data']['RX2Power']['value']
            transceiver_dom_info_dict['rx3power'] = dom_channel_monitor_data['data']['RX3Power']['value']
            transceiver_dom_info_dict['rx4power'] = dom_channel_monitor_data['data']['RX4Power']['value']
            transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TX1Bias']['value']
            transceiver_dom_info_dict['tx2bias'] = dom_channel_monitor_data['data']['TX2Bias']['value']
            transceiver_dom_info_dict['tx3bias'] = dom_channel_monitor_data['data']['TX3Bias']['value']
            transceiver_dom_info_dict['tx4bias'] = dom_channel_monitor_data['data']['TX4Bias']['value']

        else:
            offset = 256
            file_path = self._get_port_eeprom_path(port_num, self.DOM_EEPROM_ADDR)
            if not self._sfp_eeprom_present(file_path, 0):
                return None

            try:
                sysfsfile_eeprom = open(file_path, mode="rb", buffering=0)
            except IOError:
                print("Error: reading sysfs file %s" % file_path)
                return None

            sfpd_obj = sff8472Dom()
            if sfpd_obj is None:
                return None

            dom_temperature_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom, (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH)
            if dom_temperature_raw is not None:
                dom_temperature_data = sfpd_obj.parse_temperature(dom_temperature_raw, 0)
            else:
                return None

            dom_voltage_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom, (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH)
            if dom_voltage_raw is not None:
                dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
            else:
                return None

            dom_channel_monitor_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom, (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH)
            if dom_channel_monitor_raw is not None:
                dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(dom_channel_monitor_raw, 0)
            else:
                return None

            try:
                sysfsfile_eeprom.close()
            except IOError:
                print("Error: closing sysfs file %s" % file_path)
                return None

            transceiver_dom_info_dict['temperature'] = dom_temperature_data['data']['Temperature']['value']
            transceiver_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc']['value']
            transceiver_dom_info_dict['rx1power'] = dom_channel_monitor_data['data']['RXPower']['value']
            transceiver_dom_info_dict['rx2power'] = 'N/A'
            transceiver_dom_info_dict['rx3power'] = 'N/A'
            transceiver_dom_info_dict['rx4power'] = 'N/A'
            transceiver_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data']['TXBias']['value']
            transceiver_dom_info_dict['tx2bias'] = 'N/A'
            transceiver_dom_info_dict['tx3bias'] = 'N/A'
            transceiver_dom_info_dict['tx4bias'] = 'N/A'
            transceiver_dom_info_dict['tx1power'] = dom_channel_monitor_data['data']['TXPower']['value']
            transceiver_dom_info_dict['tx2power'] = 'N/A'
            transceiver_dom_info_dict['tx3power'] = 'N/A'
            transceiver_dom_info_dict['tx4power'] = 'N/A'

        logger.log_debug("QFX5200: get_transceiver_dom_info_dict End")
        return transceiver_dom_info_dict
Exemplo n.º 10
0
    def get_transceiver_dom_threshold_info_dict(self, port_num):
        transceiver_dom_threshold_info_dict = {}
        dom_info_dict_keys = ['temphighalarm',    'temphighwarning',
                              'templowalarm',     'templowwarning',
                              'vcchighalarm',     'vcchighwarning',
                              'vcclowalarm',      'vcclowwarning',
                              'rxpowerhighalarm', 'rxpowerhighwarning',
                              'rxpowerlowalarm',  'rxpowerlowwarning',
                              'txpowerhighalarm', 'txpowerhighwarning',
                              'txpowerlowalarm',  'txpowerlowwarning',
                              'txbiashighalarm',  'txbiashighwarning',
                              'txbiaslowalarm',   'txbiaslowwarning'
                              ]
        transceiver_dom_threshold_info_dict = dict.fromkeys(dom_info_dict_keys, 'N/A')

        logger.log_debug("QFX5200: get_transceiver_dom_threshold_info_dict Start")
        if port_num in self.qsfp_ports:
            file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR)
            if not self._sfp_eeprom_present(file_path, 0):
                return None

            try:
                sysfsfile_eeprom = io.open(file_path, mode="rb", buffering=0)
            except IOError:
                print("Error: reading sysfs file %s" % file_path)
                return None

            sfpd_obj = sff8436Dom()
            if sfpd_obj is None:
                return transceiver_dom_threshold_info_dict

            # Dom Threshold data starts from offset 384
            # Revert offset back to 0 once data is retrieved
            offset = 384
            dom_module_threshold_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom,
                (offset + QSFP_MODULE_THRESHOLD_OFFSET),
                QSFP_MODULE_THRESHOLD_WIDTH)
            if dom_module_threshold_raw is not None:
                dom_module_threshold_data = sfpd_obj.parse_module_threshold_values(dom_module_threshold_raw, 0)
            else:
                return transceiver_dom_threshold_info_dict

            dom_channel_threshold_raw = self._read_eeprom_specific_bytes(
                sysfsfile_eeprom,
                (offset + QSFP_CHANNL_THRESHOLD_OFFSET),
                QSFP_CHANNL_THRESHOLD_WIDTH)
            if dom_channel_threshold_raw is not None:
                dom_channel_threshold_data = sfpd_obj.parse_channel_threshold_values(dom_channel_threshold_raw, 0)
            else:
                return transceiver_dom_threshold_info_dict

            try:
                sysfsfile_eeprom.close()
            except IOError:
                print("Error: closing sysfs file %s" % file_path)
                return None

            # Threshold Data
            transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value']
            transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value']
            transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value']
            transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value']
            transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VccHighAlarm']['value']
            transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data['data']['VccHighWarning']['value']
            transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VccLowAlarm']['value']
            transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VccLowWarning']['value']
            transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_channel_threshold_data['data']['RxPowerHighAlarm']['value']
            transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_channel_threshold_data['data']['RxPowerHighWarning']['value']
            transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_channel_threshold_data['data']['RxPowerLowAlarm']['value']
            transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_channel_threshold_data['data']['RxPowerLowWarning']['value']
            transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_channel_threshold_data['data']['TxBiasHighAlarm']['value']
            transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_channel_threshold_data['data']['TxBiasHighWarning']['value']
            transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_channel_threshold_data['data']['TxBiasLowAlarm']['value']
            transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_channel_threshold_data['data']['TxBiasLowWarning']['value']

        else:
            offset = 256
            file_path = self._get_port_eeprom_path(port_num, self.DOM_EEPROM_ADDR)
            if not self._sfp_eeprom_present(file_path, 0):
                return None

            try:
                sysfsfile_eeprom = io.open(file_path, "rb", 0)
            except IOError:
                print("Error: reading sysfs file %s" % file_path)
                return None

            sfpd_obj = sff8472Dom(None, 1)
            if sfpd_obj is None:
                return transceiver_dom_threshold_info_dict

            dom_module_threshold_raw = self._read_eeprom_specific_bytes(sysfsfile_eeprom,
                                                                        (offset + SFP_MODULE_THRESHOLD_OFFSET), SFP_MODULE_THRESHOLD_WIDTH)

            if dom_module_threshold_raw is not None:
                dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold(dom_module_threshold_raw, 0)
            else:
                return transceiver_dom_threshold_info_dict

            try:
                sysfsfile_eeprom.close()
            except IOError:
                print("Error: closing sysfs file %s" % file_path)
                return None

            # Threshold Data
            transceiver_dom_threshold_info_dict['temphighalarm'] = dom_module_threshold_data['data']['TempHighAlarm']['value']
            transceiver_dom_threshold_info_dict['templowalarm'] = dom_module_threshold_data['data']['TempLowAlarm']['value']
            transceiver_dom_threshold_info_dict['temphighwarning'] = dom_module_threshold_data['data']['TempHighWarning']['value']
            transceiver_dom_threshold_info_dict['templowwarning'] = dom_module_threshold_data['data']['TempLowWarning']['value']
            transceiver_dom_threshold_info_dict['vcchighalarm'] = dom_module_threshold_data['data']['VoltageHighAlarm']['value']
            transceiver_dom_threshold_info_dict['vcclowalarm'] = dom_module_threshold_data['data']['VoltageLowAlarm']['value']
            transceiver_dom_threshold_info_dict['vcchighwarning'] = dom_module_threshold_data['data']['VoltageHighWarning']['value']
            transceiver_dom_threshold_info_dict['vcclowwarning'] = dom_module_threshold_data['data']['VoltageLowWarning']['value']
            transceiver_dom_threshold_info_dict['txbiashighalarm'] = dom_module_threshold_data['data']['BiasHighAlarm']['value']
            transceiver_dom_threshold_info_dict['txbiaslowalarm'] = dom_module_threshold_data['data']['BiasLowAlarm']['value']
            transceiver_dom_threshold_info_dict['txbiashighwarning'] = dom_module_threshold_data['data']['BiasHighWarning']['value']
            transceiver_dom_threshold_info_dict['txbiaslowwarning'] = dom_module_threshold_data['data']['BiasLowWarning']['value']
            transceiver_dom_threshold_info_dict['txpowerhighalarm'] = dom_module_threshold_data['data']['TXPowerHighAlarm']['value']
            transceiver_dom_threshold_info_dict['txpowerlowalarm'] = dom_module_threshold_data['data']['TXPowerLowAlarm']['value']
            transceiver_dom_threshold_info_dict['txpowerhighwarning'] = dom_module_threshold_data['data']['TXPowerHighWarning']['value']
            transceiver_dom_threshold_info_dict['txpowerlowwarning'] = dom_module_threshold_data['data']['TXPowerLowWarning']['value']
            transceiver_dom_threshold_info_dict['rxpowerhighalarm'] = dom_module_threshold_data['data']['RXPowerHighAlarm']['value']
            transceiver_dom_threshold_info_dict['rxpowerlowalarm'] = dom_module_threshold_data['data']['RXPowerLowAlarm']['value']
            transceiver_dom_threshold_info_dict['rxpowerhighwarning'] = dom_module_threshold_data['data']['RXPowerHighWarning']['value']
            transceiver_dom_threshold_info_dict['rxpowerlowwarning'] = dom_module_threshold_data['data']['RXPowerLowWarning']['value']

        logger.log_debug("QFX5200: get_transceiver_dom_threshold_info_dict End")
        return transceiver_dom_threshold_info_dict
Exemplo n.º 11
0
    def get_transceiver_threshold_info(self):
        """
        Retrieves transceiver threshold info of this SFP
        Returns:
            A dict which contains following keys/values :
        ========================================================================
        keys                       |Value Format   |Information
        ---------------------------|---------------|----------------------------
        temphighalarm              |FLOAT          |High Alarm Threshold value of temperature in Celsius.
        templowalarm               |FLOAT          |Low Alarm Threshold value of temperature in Celsius.
        temphighwarning            |FLOAT          |High Warning Threshold value of temperature in Celsius.
        templowwarning             |FLOAT          |Low Warning Threshold value of temperature in Celsius.
        vcchighalarm               |FLOAT          |High Alarm Threshold value of supply voltage in mV.
        vcclowalarm                |FLOAT          |Low Alarm Threshold value of supply voltage in mV.
        vcchighwarning             |FLOAT          |High Warning Threshold value of supply voltage in mV.
        vcclowwarning              |FLOAT          |Low Warning Threshold value of supply voltage in mV.
        rxpowerhighalarm           |FLOAT          |High Alarm Threshold value of received power in dBm.
        rxpowerlowalarm            |FLOAT          |Low Alarm Threshold value of received power in dBm.
        rxpowerhighwarning         |FLOAT          |High Warning Threshold value of received power in dBm.
        rxpowerlowwarning          |FLOAT          |Low Warning Threshold value of received power in dBm.
        txpowerhighalarm           |FLOAT          |High Alarm Threshold value of transmit power in dBm.
        txpowerlowalarm            |FLOAT          |Low Alarm Threshold value of transmit power in dBm.
        txpowerhighwarning         |FLOAT          |High Warning Threshold value of transmit power in dBm.
        txpowerlowwarning          |FLOAT          |Low Warning Threshold value of transmit power in dBm.
        txbiashighalarm            |FLOAT          |High Alarm Threshold value of tx Bias Current in mA.
        txbiaslowalarm             |FLOAT          |Low Alarm Threshold value of tx Bias Current in mA.
        txbiashighwarning          |FLOAT          |High Warning Threshold value of tx Bias Current in mA.
        txbiaslowwarning           |FLOAT          |Low Warning Threshold value of tx Bias Current in mA.
        ========================================================================
        """
        transceiver_dom_threshold_info_dict = dict.fromkeys(
            self.threshold_dict_keys, 'N/A')

        if self.sfp_type == COPPER_TYPE:
            return transceiver_dom_threshold_info_dict

        if self.sfp_type == SFP_TYPE:

            offset = SFP_MODULE_ADDRA2_OFFSET

            self._dom_capability_detect()
            if not self.dom_supported:
                return transceiver_dom_threshold_info_dict

            sfpd_obj = sff8472Dom(None, self.calibration)
            if sfpd_obj is None:
                return transceiver_dom_threshold_info_dict

            dom_module_threshold_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_MODULE_THRESHOLD_OFFSET),
                SFP_MODULE_THRESHOLD_WIDTH)
            if dom_module_threshold_raw is not None:
                dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold(
                    dom_module_threshold_raw, 0)
            else:
                return transceiver_dom_threshold_info_dict

            # Threshold Data
            transceiver_dom_threshold_info_dict[
                'temphighalarm'] = dom_module_threshold_data['data'][
                    'TempHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'templowalarm'] = dom_module_threshold_data['data'][
                    'TempLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'temphighwarning'] = dom_module_threshold_data['data'][
                    'TempHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'templowwarning'] = dom_module_threshold_data['data'][
                    'TempLowWarning']['value']
            transceiver_dom_threshold_info_dict[
                'vcchighalarm'] = dom_module_threshold_data['data'][
                    'VoltageHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'vcclowalarm'] = dom_module_threshold_data['data'][
                    'VoltageLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'vcchighwarning'] = dom_module_threshold_data['data'][
                    'VoltageHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'vcclowwarning'] = dom_module_threshold_data['data'][
                    'VoltageLowWarning']['value']
            transceiver_dom_threshold_info_dict[
                'txbiashighalarm'] = dom_module_threshold_data['data'][
                    'BiasHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'txbiaslowalarm'] = dom_module_threshold_data['data'][
                    'BiasLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'txbiashighwarning'] = dom_module_threshold_data['data'][
                    'BiasHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'txbiaslowwarning'] = dom_module_threshold_data['data'][
                    'BiasLowWarning']['value']
            transceiver_dom_threshold_info_dict[
                'txpowerhighalarm'] = dom_module_threshold_data['data'][
                    'TXPowerHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'txpowerlowalarm'] = dom_module_threshold_data['data'][
                    'TXPowerLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'txpowerhighwarning'] = dom_module_threshold_data['data'][
                    'TXPowerHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'txpowerlowwarning'] = dom_module_threshold_data['data'][
                    'TXPowerLowWarning']['value']
            transceiver_dom_threshold_info_dict[
                'rxpowerhighalarm'] = dom_module_threshold_data['data'][
                    'RXPowerHighAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'rxpowerlowalarm'] = dom_module_threshold_data['data'][
                    'RXPowerLowAlarm']['value']
            transceiver_dom_threshold_info_dict[
                'rxpowerhighwarning'] = dom_module_threshold_data['data'][
                    'RXPowerHighWarning']['value']
            transceiver_dom_threshold_info_dict[
                'rxpowerlowwarning'] = dom_module_threshold_data['data'][
                    'RXPowerLowWarning']['value']

        return transceiver_dom_threshold_info_dict
Exemplo n.º 12
0
    def get_transceiver_bulk_status(self):
        """
        Retrieves transceiver bulk status of this SFP
        Returns:
            A dict which contains following keys/values :
        ========================================================================
        keys                       |Value Format   |Information
        ---------------------------|---------------|----------------------------
        rx_los                     |BOOLEAN        |RX loss-of-signal status, True if has RX los, False if not.
        tx_fault                   |BOOLEAN        |TX fault status, True if has TX fault, False if not.
        reset_status               |BOOLEAN        |reset status, True if SFP in reset, False if not.
        lp_mode                    |BOOLEAN        |low power mode status, True in lp mode, False if not.
        tx_disable                 |BOOLEAN        |TX disable status, True TX disabled, False if not.
        tx_disabled_channel        |HEX            |disabled TX channels in hex, bits 0 to 3 represent channel 0
                                   |               |to channel 3.
        temperature                |INT            |module temperature in Celsius
        voltage                    |INT            |supply voltage in mV
        tx<n>bias                  |INT            |TX Bias Current in mA, n is the channel number,
                                   |               |for example, tx2bias stands for tx bias of channel 2.
        rx<n>power                 |INT            |received optical power in mW, n is the channel number,
                                   |               |for example, rx2power stands for rx power of channel 2.
        tx<n>power                 |INT            |TX output power in mW, n is the channel number,
                                   |               |for example, tx2power stands for tx power of channel 2.
        ========================================================================
        """

        transceiver_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A')

        if self.sfp_type == COPPER_TYPE:
            return transceiver_dom_info_dict

        if self.sfp_type == SFP_TYPE:

            self._dom_capability_detect()
            if not self.dom_supported:
                return transceiver_dom_info_dict

            offset = 256
            sfpd_obj = sff8472Dom()
            if sfpd_obj is None:
                return transceiver_dom_info_dict
            sfpd_obj._calibration_type = self.calibration

            dom_data_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_DOM_BULK_DATA_START), SFP_DOM_BULK_DATA_SIZE)

            start = SFP_TEMPE_OFFSET - SFP_DOM_BULK_DATA_START
            end = start + SFP_TEMPE_WIDTH
            dom_temperature_data = sfpd_obj.parse_temperature(
                dom_data_raw[start:end], 0)

            start = SFP_VOLT_OFFSET - SFP_DOM_BULK_DATA_START
            end = start + SFP_VOLT_WIDTH
            dom_voltage_data = sfpd_obj.parse_voltage(dom_data_raw[start:end],
                                                      0)

            start = SFP_CHANNL_MON_OFFSET - SFP_DOM_BULK_DATA_START
            end = start + SFP_CHANNL_MON_WIDTH
            dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(
                dom_data_raw[start:end], 0)

            transceiver_dom_info_dict[
                'temperature'] = self.__convert_string_to_num(
                    dom_temperature_data['data']['Temperature']['value'])
            transceiver_dom_info_dict[
                'voltage'] = self.__convert_string_to_num(
                    dom_voltage_data['data']['Vcc']['value'])
            transceiver_dom_info_dict[
                'rx1power'] = self.__convert_string_to_num(
                    dom_channel_monitor_data['data']['RXPower']['value'])
            transceiver_dom_info_dict[
                'tx1bias'] = self.__convert_string_to_num(
                    dom_channel_monitor_data['data']['TXBias']['value'])
            transceiver_dom_info_dict[
                'tx1power'] = self.__convert_string_to_num(
                    dom_channel_monitor_data['data']['TXPower']['value'])

        transceiver_dom_info_dict['rx_los'] = self.get_rx_los()
        transceiver_dom_info_dict['tx_fault'] = self.get_tx_fault()
        transceiver_dom_info_dict['reset_status'] = self.get_reset_status()
        transceiver_dom_info_dict['lp_mode'] = self.get_lpmode()

        return transceiver_dom_info_dict
Exemplo n.º 13
0
    def get_transceiver_threshold_info(self):
        """
        Retrieves transceiver threshold info of this SFP
        Returns:
            A dict which contains following keys/values :
        ========================================================================
        keys                       |Value Format   |Information
        ---------------------------|---------------|----------------------------
        temphighalarm              |FLOAT          |High Alarm Threshold value of temperature in Celsius.
        templowalarm               |FLOAT          |Low Alarm Threshold value of temperature in Celsius.
        temphighwarning            |FLOAT          |High Warning Threshold value of temperature in Celsius.
        templowwarning             |FLOAT          |Low Warning Threshold value of temperature in Celsius.
        vcchighalarm               |FLOAT          |High Alarm Threshold value of supply voltage in mV.
        vcclowalarm                |FLOAT          |Low Alarm Threshold value of supply voltage in mV.
        vcchighwarning             |FLOAT          |High Warning Threshold value of supply voltage in mV.
        vcclowwarning              |FLOAT          |Low Warning Threshold value of supply voltage in mV.
        rxpowerhighalarm           |FLOAT          |High Alarm Threshold value of received power in dBm.
        rxpowerlowalarm            |FLOAT          |Low Alarm Threshold value of received power in dBm.
        rxpowerhighwarning         |FLOAT          |High Warning Threshold value of received power in dBm.
        rxpowerlowwarning          |FLOAT          |Low Warning Threshold value of received power in dBm.
        txpowerhighalarm           |FLOAT          |High Alarm Threshold value of transmit power in dBm.
        txpowerlowalarm            |FLOAT          |Low Alarm Threshold value of transmit power in dBm.
        txpowerhighwarning         |FLOAT          |High Warning Threshold value of transmit power in dBm.
        txpowerlowwarning          |FLOAT          |Low Warning Threshold value of transmit power in dBm.
        txbiashighalarm            |FLOAT          |High Alarm Threshold value of tx Bias Current in mA.
        txbiaslowalarm             |FLOAT          |Low Alarm Threshold value of tx Bias Current in mA.
        txbiashighwarning          |FLOAT          |High Warning Threshold value of tx Bias Current in mA.
        txbiaslowwarning           |FLOAT          |Low Warning Threshold value of tx Bias Current in mA.
        ========================================================================
        """
        # check present status
        if not self.get_presence():
            return None

        xcvr_dom_threshold_info_dict = dict.fromkeys(self.threshold_dict_keys,
                                                     'N/A')

        if self.is_osfp_port:
            # Below part is added to avoid fail xcvrd, shall be implemented later
            pass
        elif self.is_qsfp_port:
            # QSFPs
            sfpd_obj = sff8436Dom()
            if sfpd_obj is None:
                return None

            dom_thres_raw = self.__read_eeprom_specific_bytes(
                QSFP_MODULE_THRESHOLD_OFFSET, QSFP_MODULE_THRESHOLD_WIDTH)

            if dom_thres_raw:
                module_threshold_values = sfpd_obj.parse_module_threshold_values(
                    dom_thres_raw, 0)
                module_threshold_data = module_threshold_values.get('data')
                if module_threshold_data:
                    xcvr_dom_threshold_info_dict[
                        'temphighalarm'] = module_threshold_data[
                            'TempHighAlarm']['value']
                    xcvr_dom_threshold_info_dict[
                        'templowalarm'] = module_threshold_data[
                            'TempLowAlarm']['value']
                    xcvr_dom_threshold_info_dict[
                        'temphighwarning'] = module_threshold_data[
                            'TempHighWarning']['value']
                    xcvr_dom_threshold_info_dict[
                        'templowwarning'] = module_threshold_data[
                            'TempLowWarning']['value']
                    xcvr_dom_threshold_info_dict[
                        'vcchighalarm'] = module_threshold_data[
                            'VccHighAlarm']['value']
                    xcvr_dom_threshold_info_dict[
                        'vcclowalarm'] = module_threshold_data['VccLowAlarm'][
                            'value']
                    xcvr_dom_threshold_info_dict[
                        'vcchighwarning'] = module_threshold_data[
                            'VccHighWarning']['value']
                    xcvr_dom_threshold_info_dict[
                        'vcclowwarning'] = module_threshold_data[
                            'VccLowWarning']['value']

            dom_thres_raw = self.__read_eeprom_specific_bytes(
                QSFP_CHANNEL_THRESHOLD_OFFSET, QSFP_CHANNEL_THRESHOLD_WIDTH)
            if dom_thres_raw:
                channel_threshold_values = sfpd_obj.parse_channel_threshold_values(
                    dom_thres_raw, 0)
                channel_threshold_data = channel_threshold_values.get('data')
                if channel_threshold_data:
                    xcvr_dom_threshold_info_dict[
                        'rxpowerhighalarm'] = channel_threshold_data[
                            'RxPowerHighAlarm']['value']
                    xcvr_dom_threshold_info_dict[
                        'rxpowerlowalarm'] = channel_threshold_data[
                            'RxPowerLowAlarm']['value']
                    xcvr_dom_threshold_info_dict[
                        'rxpowerhighwarning'] = channel_threshold_data[
                            'RxPowerHighWarning']['value']
                    xcvr_dom_threshold_info_dict[
                        'rxpowerlowwarning'] = channel_threshold_data[
                            'RxPowerLowWarning']['value']
                    xcvr_dom_threshold_info_dict['txpowerhighalarm'] = "0.0dBm"
                    xcvr_dom_threshold_info_dict['txpowerlowalarm'] = "0.0dBm"
                    xcvr_dom_threshold_info_dict[
                        'txpowerhighwarning'] = "0.0dBm"
                    xcvr_dom_threshold_info_dict[
                        'txpowerlowwarning'] = "0.0dBm"
                    xcvr_dom_threshold_info_dict[
                        'txbiashighalarm'] = channel_threshold_data[
                            'TxBiasHighAlarm']['value']
                    xcvr_dom_threshold_info_dict[
                        'txbiaslowalarm'] = channel_threshold_data[
                            'TxBiasLowAlarm']['value']
                    xcvr_dom_threshold_info_dict[
                        'txbiashighwarning'] = channel_threshold_data[
                            'TxBiasHighWarning']['value']
                    xcvr_dom_threshold_info_dict[
                        'txbiaslowwarning'] = channel_threshold_data[
                            'TxBiasLowWarning']['value']

        else:
            # SFPs
            sfpd_obj = sff8472Dom()
            offset = 256
            eeprom_ifraw = self.__read_eeprom_specific_bytes(0, offset)
            sfpi_obj = sff8472InterfaceId(eeprom_ifraw)
            cal_type = sfpi_obj.get_calibration_type()
            sfpd_obj._calibration_type = cal_type

            dom_module_threshold_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_MODULE_THRESHOLD_OFFSET),
                SFP_MODULE_THRESHOLD_WIDTH)
            if dom_module_threshold_raw is not None:
                dom_module_threshold_data = sfpd_obj.parse_alarm_warning_threshold(
                    dom_module_threshold_raw, 0)

                xcvr_dom_threshold_info_dict[
                    'temphighalarm'] = dom_module_threshold_data['data'][
                        'TempHighAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'templowalarm'] = dom_module_threshold_data['data'][
                        'TempLowAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'temphighwarning'] = dom_module_threshold_data['data'][
                        'TempHighWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'templowwarning'] = dom_module_threshold_data['data'][
                        'TempLowWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'vcchighalarm'] = dom_module_threshold_data['data'][
                        'VoltageHighAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'vcclowalarm'] = dom_module_threshold_data['data'][
                        'VoltageLowAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'vcchighwarning'] = dom_module_threshold_data['data'][
                        'VoltageHighWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'vcclowwarning'] = dom_module_threshold_data['data'][
                        'VoltageLowWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'txbiashighalarm'] = dom_module_threshold_data['data'][
                        'BiasHighAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'txbiaslowalarm'] = dom_module_threshold_data['data'][
                        'BiasLowAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'txbiashighwarning'] = dom_module_threshold_data['data'][
                        'BiasHighWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'txbiaslowwarning'] = dom_module_threshold_data['data'][
                        'BiasLowWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'txpowerhighalarm'] = dom_module_threshold_data['data'][
                        'TXPowerHighAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'txpowerlowalarm'] = dom_module_threshold_data['data'][
                        'TXPowerLowAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'txpowerhighwarning'] = dom_module_threshold_data['data'][
                        'TXPowerHighWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'txpowerlowwarning'] = dom_module_threshold_data['data'][
                        'TXPowerLowWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'rxpowerhighalarm'] = dom_module_threshold_data['data'][
                        'RXPowerHighAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'rxpowerlowalarm'] = dom_module_threshold_data['data'][
                        'RXPowerLowAlarm']['value']
                xcvr_dom_threshold_info_dict[
                    'rxpowerhighwarning'] = dom_module_threshold_data['data'][
                        'RXPowerHighWarning']['value']
                xcvr_dom_threshold_info_dict[
                    'rxpowerlowwarning'] = dom_module_threshold_data['data'][
                        'RXPowerLowWarning']['value']

        return xcvr_dom_threshold_info_dict
Exemplo n.º 14
0
    def get_transceiver_bulk_status(self):
        """
        Retrieves transceiver bulk status of this SFP

        Returns:
            A dict which contains following keys/values :
        ========================================================================
        keys                       |Value Format   |Information	
        ---------------------------|---------------|----------------------------
        RX LOS                     |BOOLEAN        |RX lost-of-signal status,
                                   |               |True if has RX los, False if not.
        TX FAULT                   |BOOLEAN        |TX fault status,
                                   |               |True if has TX fault, False if not.
        Reset status               |BOOLEAN        |reset status,
                                   |               |True if SFP in reset, False if not.
        LP mode                    |BOOLEAN        |low power mode status,
                                   |               |True in lp mode, False if not.
        TX disable                 |BOOLEAN        |TX disable status,
                                   |               |True TX disabled, False if not.
        TX disabled channel        |HEX            |disabled TX channles in hex,
                                   |               |bits 0 to 3 represent channel 0
                                   |               |to channel 3.
        Temperature                |INT            |module temperature in Celsius
        Voltage                    |INT            |supply voltage in mV
        TX bias                    |INT            |TX Bias Current in mA
        RX power                   |INT            |received optical power in mW
        TX power                   |INT            |TX output power in mW
        ========================================================================
        """
        # check present status
        if not self.get_presence():
            return None

        xcvr_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A')

        if self.is_osfp_port:
            # Below part is added to avoid fail xcvrd, shall be implemented later
            pass
        elif self.is_qsfp_port:
            # QSFPs
            offset = 0
            offset_xcvr = 128

            sfpd_obj = sff8436Dom()
            if sfpd_obj is None:
                return None

            sfpi_obj = sff8436InterfaceId()
            if sfpi_obj is None:
                return None

            qsfp_dom_capability_raw = self.__read_eeprom_specific_bytes(
                (offset_xcvr + XCVR_DOM_CAPABILITY_OFFSET),
                XCVR_DOM_CAPABILITY_WIDTH)
            if qsfp_dom_capability_raw is not None:
                qspf_dom_capability_data = sfpi_obj.parse_qsfp_dom_capability(
                    qsfp_dom_capability_raw, 0)
            else:
                return None

            dom_temperature_raw = self.__read_eeprom_specific_bytes(
                (offset + QSFP_TEMPE_OFFSET), QSFP_TEMPE_WIDTH)
            if dom_temperature_raw is not None:
                dom_temperature_data = sfpd_obj.parse_temperature(
                    dom_temperature_raw, 0)
            else:
                return None

            dom_voltage_raw = self.__read_eeprom_specific_bytes(
                (offset + QSFP_VOLT_OFFSET), QSFP_VOLT_WIDTH)
            if dom_voltage_raw is not None:
                dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
            else:
                return None

            qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes(
                (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH)
            if qsfp_dom_rev_raw is not None:
                qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(
                    qsfp_dom_rev_raw, 0)
            else:
                return None

            xcvr_dom_info_dict['temperature'] = dom_temperature_data['data'][
                'Temperature']['value']
            xcvr_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc'][
                'value']

            # The tx_power monitoring is only available on QSFP which compliant with SFF-8636
            # and claimed that it support tx_power with one indicator bit.
            dom_channel_monitor_data = {}
            qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value']
            qsfp_tx_power_support = qspf_dom_capability_data['data'][
                'Tx_power_support']['value']
            if (qsfp_dom_rev[0:8] != 'SFF-8636'
                    or (qsfp_dom_rev[0:8] == 'SFF-8636'
                        and qsfp_tx_power_support != 'on')):
                dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
                    (offset + QSFP_CHANNL_MON_OFFSET), QSFP_CHANNL_MON_WIDTH)
                if dom_channel_monitor_raw is not None:
                    dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(
                        dom_channel_monitor_raw, 0)
                else:
                    return None

                xcvr_dom_info_dict['tx1power'] = 'N/A'
                xcvr_dom_info_dict['tx2power'] = 'N/A'
                xcvr_dom_info_dict['tx3power'] = 'N/A'
                xcvr_dom_info_dict['tx4power'] = 'N/A'
            else:
                dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
                    (offset + QSFP_CHANNL_MON_OFFSET),
                    QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH)
                if dom_channel_monitor_raw is not None:
                    dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power(
                        dom_channel_monitor_raw, 0)
                else:
                    return None

                xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data[
                    'data']['TX1Power']['value']
                xcvr_dom_info_dict['tx2power'] = dom_channel_monitor_data[
                    'data']['TX2Power']['value']
                xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data[
                    'data']['TX3Power']['value']
                xcvr_dom_info_dict['tx4power'] = dom_channel_monitor_data[
                    'data']['TX4Power']['value']

            if dom_channel_monitor_raw:
                xcvr_dom_info_dict['temperature'] = dom_temperature_data[
                    'data']['Temperature']['value']
                xcvr_dom_info_dict['voltage'] = dom_voltage_data['data'][
                    'Vcc']['value']
                xcvr_dom_info_dict['rx1power'] = dom_channel_monitor_data[
                    'data']['RX1Power']['value']
                xcvr_dom_info_dict['rx2power'] = dom_channel_monitor_data[
                    'data']['RX2Power']['value']
                xcvr_dom_info_dict['rx3power'] = dom_channel_monitor_data[
                    'data']['RX3Power']['value']
                xcvr_dom_info_dict['rx4power'] = dom_channel_monitor_data[
                    'data']['RX4Power']['value']
                xcvr_dom_info_dict['tx1bias'] = dom_channel_monitor_data[
                    'data']['TX1Bias']['value']
                xcvr_dom_info_dict['tx2bias'] = dom_channel_monitor_data[
                    'data']['TX2Bias']['value']
                xcvr_dom_info_dict['tx3bias'] = dom_channel_monitor_data[
                    'data']['TX3Bias']['value']
                xcvr_dom_info_dict['tx4bias'] = dom_channel_monitor_data[
                    'data']['TX4Bias']['value']

        else:
            # SFPs
            offset = 256

            sfpd_obj = sff8472Dom()
            if sfpd_obj is None:
                return None

            dom_temperature_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH)
            if dom_temperature_raw is not None:
                dom_temperature_data = sfpd_obj.parse_temperature(
                    dom_temperature_raw, 0)
            else:
                return None

            dom_voltage_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH)
            if dom_voltage_raw is not None:
                dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
            else:
                return None

            dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH)
            if dom_channel_monitor_raw is not None:
                dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(
                    dom_channel_monitor_raw, 0)
            else:
                return None

            xcvr_dom_info_dict['temperature'] = dom_temperature_data['data'][
                'Temperature']['value']
            xcvr_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc'][
                'value']
            xcvr_dom_info_dict['rx1power'] = dom_channel_monitor_data['data'][
                'RXPower']['value']
            xcvr_dom_info_dict['rx2power'] = 'N/A'
            xcvr_dom_info_dict['rx3power'] = 'N/A'
            xcvr_dom_info_dict['rx4power'] = 'N/A'
            xcvr_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data'][
                'TXBias']['value']
            xcvr_dom_info_dict['tx2bias'] = 'N/A'
            xcvr_dom_info_dict['tx3bias'] = 'N/A'
            xcvr_dom_info_dict['tx4bias'] = 'N/A'
            xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data'][
                'TXPower']['value']
            xcvr_dom_info_dict['tx2power'] = 'N/A'
            xcvr_dom_info_dict['tx3power'] = 'N/A'
            xcvr_dom_info_dict['tx4power'] = 'N/A'

        xcvr_dom_info_dict['rx_los'] = self.get_rx_los()
        xcvr_dom_info_dict['tx_fault'] = self.get_tx_fault()
        xcvr_dom_info_dict['reset_status'] = self.get_reset_status()
        xcvr_dom_info_dict['lp_mode'] = self.get_lpmode()

        return xcvr_dom_info_dict
Exemplo n.º 15
0
    def get_transceiver_bulk_status(self):
        # check present status
        if not self.get_presence():
            return None
        self.__dom_capability_detect()

        xcvr_dom_info_dict = dict.fromkeys(self.dom_dict_keys, 'N/A')

        if self.is_osfp_port:
            # Below part is added to avoid fail xcvrd, shall be implemented later
            pass
        elif self.is_qsfp_port:
            # QSFPs
            xcvr_dom_info_dict = super(Sfp, self).get_transceiver_bulk_status()

            # pddf_sfp "qsfp_tx_power_support != 'on'" is wrong

            offset = 0
            sfpd_obj = sff8436Dom()
            if sfpd_obj is None:
                return None

            qsfp_dom_rev_raw = self.__read_eeprom_specific_bytes(
                (offset + QSFP_DOM_REV_OFFSET), QSFP_DOM_REV_WIDTH)
            if qsfp_dom_rev_raw is not None:
                qsfp_dom_rev_data = sfpd_obj.parse_sfp_dom_rev(
                    qsfp_dom_rev_raw, 0)
            else:
                return None

            dom_channel_monitor_data = {}
            qsfp_dom_rev = qsfp_dom_rev_data['data']['dom_rev']['value']

            if (qsfp_dom_rev[0:8] == 'SFF-8636'
                    and self.dom_tx_power_supported is True):
                dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
                    (offset + QSFP_CHANNL_MON_OFFSET),
                    QSFP_CHANNL_MON_WITH_TX_POWER_WIDTH)
                if dom_channel_monitor_raw is not None:
                    dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params_with_tx_power(
                        dom_channel_monitor_raw, 0)
                else:
                    return None

                xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data[
                    'data']['TX1Power']['value']
                xcvr_dom_info_dict['tx2power'] = dom_channel_monitor_data[
                    'data']['TX2Power']['value']
                xcvr_dom_info_dict['tx3power'] = dom_channel_monitor_data[
                    'data']['TX3Power']['value']
                xcvr_dom_info_dict['tx4power'] = dom_channel_monitor_data[
                    'data']['TX4Power']['value']
        else:
            # SFPs
            offset = 256
            if not self.dom_supported:
                return xcvr_dom_info_dict

            sfpd_obj = sff8472Dom()
            if sfpd_obj is None:
                return None

            sfpd_obj._calibration_type = self.calibration

            dom_temperature_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_TEMPE_OFFSET), SFP_TEMPE_WIDTH)
            if dom_temperature_raw is not None:
                dom_temperature_data = sfpd_obj.parse_temperature(
                    dom_temperature_raw, 0)
            else:
                return None

            dom_voltage_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_VOLT_OFFSET), SFP_VOLT_WIDTH)
            if dom_voltage_raw is not None:
                dom_voltage_data = sfpd_obj.parse_voltage(dom_voltage_raw, 0)
            else:
                return None

            dom_channel_monitor_raw = self.__read_eeprom_specific_bytes(
                (offset + SFP_CHANNL_MON_OFFSET), SFP_CHANNL_MON_WIDTH)
            if dom_channel_monitor_raw is not None:
                dom_channel_monitor_data = sfpd_obj.parse_channel_monitor_params(
                    dom_channel_monitor_raw, 0)
            else:
                return None

            xcvr_dom_info_dict['temperature'] = dom_temperature_data['data'][
                'Temperature']['value']
            xcvr_dom_info_dict['voltage'] = dom_voltage_data['data']['Vcc'][
                'value']
            xcvr_dom_info_dict['rx1power'] = dom_channel_monitor_data['data'][
                'RXPower']['value']
            xcvr_dom_info_dict['rx2power'] = 'N/A'
            xcvr_dom_info_dict['rx3power'] = 'N/A'
            xcvr_dom_info_dict['rx4power'] = 'N/A'
            xcvr_dom_info_dict['tx1bias'] = dom_channel_monitor_data['data'][
                'TXBias']['value']
            xcvr_dom_info_dict['tx2bias'] = 'N/A'
            xcvr_dom_info_dict['tx3bias'] = 'N/A'
            xcvr_dom_info_dict['tx4bias'] = 'N/A'
            xcvr_dom_info_dict['tx1power'] = dom_channel_monitor_data['data'][
                'TXPower']['value']
            xcvr_dom_info_dict['tx2power'] = 'N/A'
            xcvr_dom_info_dict['tx3power'] = 'N/A'
            xcvr_dom_info_dict['tx4power'] = 'N/A'

            xcvr_dom_info_dict['rx_los'] = self.get_rx_los()
            xcvr_dom_info_dict['tx_fault'] = self.get_tx_fault()
            xcvr_dom_info_dict['reset_status'] = self.get_reset_status()
            xcvr_dom_info_dict['lp_mode'] = self.get_lpmode()

        return xcvr_dom_info_dict