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
def _dom_capability_detect(self): if self.sfp_type == "SFP": sfpi_obj = sff8472InterfaceId() if sfpi_obj is None: return None sfp_dom_capability_raw = self.__read_eeprom_specific_bytes( XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH) if sfp_dom_capability_raw is not None: sfp_dom_capability = int(sfp_dom_capability_raw[0], 16) self.dom_supported = (sfp_dom_capability & 0x40 != 0) if self.dom_supported: self.dom_temp_supported = True self.dom_volt_supported = True self.dom_rx_power_supported = True self.dom_tx_power_supported = True if sfp_dom_capability & 0x20 != 0: self.calibration = 1 elif sfp_dom_capability & 0x10 != 0: self.calibration = 2 else: self.calibration = 0 else: self.dom_temp_supported = False self.dom_volt_supported = False self.dom_rx_power_supported = False self.dom_tx_power_supported = False self.calibration = 0 self.dom_tx_disable_supported = ( int(sfp_dom_capability_raw[1], 16) & 0x40 != 0) else: self.dom_supported = False self.dom_temp_supported = False self.dom_volt_supported = False self.dom_rx_power_supported = False self.dom_tx_power_supported = False
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
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)
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)
def get_serial(self): """ Retrieves the serial number of the device Returns: string: Serial number of device """ serial = "N/A" offset = INFO_OFFSET sfpi_obj = sff8472InterfaceId() if not self.get_presence() or not sfpi_obj: return serial sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn(sfp_vendor_sn_raw, 0) serial = sfp_vendor_sn_data['data']['Vendor SN'][ 'value'] if sfp_vendor_sn_data else 'N/A' return serial
def get_model(self): """ Retrieves the model number (or part number) of the device Returns: string: Model/part number of device """ model = "N/A" offset = INFO_OFFSET sfpi_obj = sff8472InterfaceId() if not self.get_presence() or not sfpi_obj: return model sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_vendor_pn_raw, 0) model = sfp_vendor_pn_data['data']['Vendor PN'][ 'value'] if sfp_vendor_pn_data else 'N/A' return model
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
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
def get_transceiver_info(self): """ Retrieves transceiver info of this SFP Returns: A dict which contains following keys/values : ======================================================================== keys |Value Format |Information ---------------------------|---------------|---------------------------- type |1*255VCHAR |type of SFP hardwarerev |1*255VCHAR |hardware version of SFP serialnum |1*255VCHAR |serial number of the SFP manufacturename |1*255VCHAR |SFP vendor name modelname |1*255VCHAR |SFP model name Connector |1*255VCHAR |connector information encoding |1*255VCHAR |encoding information ext_identifier |1*255VCHAR |extend identifier ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance cable_length |INT |cable length in m nominal_bit_rate |INT |nominal bit rate by 100Mbs specification_compliance |1*255VCHAR |specification compliance vendor_date |1*255VCHAR |vendor date vendor_oui |1*255VCHAR |vendor OUI ======================================================================== """ # check present status sfpi_obj = sff8472InterfaceId() if not self.get_presence() or not sfpi_obj: return {} offset = INFO_OFFSET sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_INTFACE_BULK_OFFSET), XCVR_INTFACE_BULK_WIDTH_SFP) sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( sfp_interface_bulk_raw, 0) sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) sfp_vendor_name_data = sfpi_obj.parse_vendor_name( sfp_vendor_name_raw, 0) sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_vendor_pn_raw, 0) sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_SFP) sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev(sfp_vendor_rev_raw, 0) sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn(sfp_vendor_sn_raw, 0) sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) if sfp_vendor_oui_raw is not None: sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( sfp_vendor_oui_raw, 0) sfp_vendor_date_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) sfp_vendor_date_data = sfpi_obj.parse_vendor_date( sfp_vendor_date_raw, 0) transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') compliance_code_dict = dict() if sfp_interface_bulk_data: transceiver_info_dict['type'] = sfp_interface_bulk_data['data'][ 'type']['value'] transceiver_info_dict['Connector'] = sfp_interface_bulk_data[ 'data']['Connector']['value'] transceiver_info_dict['encoding'] = sfp_interface_bulk_data[ 'data']['EncodingCodes']['value'] transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data[ 'data']['Extended Identifier']['value'] transceiver_info_dict[ 'ext_rateselect_compliance'] = sfp_interface_bulk_data['data'][ 'RateIdentifier']['value'] transceiver_info_dict['type_abbrv_name'] = sfp_interface_bulk_data[ 'data']['type_abbrv_name']['value'] transceiver_info_dict['manufacturename'] = sfp_vendor_name_data[ 'data']['Vendor Name']['value'] if sfp_vendor_name_data else 'N/A' transceiver_info_dict['modelname'] = sfp_vendor_pn_data['data'][ 'Vendor PN']['value'] if sfp_vendor_pn_data else 'N/A' transceiver_info_dict['hardwarerev'] = sfp_vendor_rev_data['data'][ 'Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A' transceiver_info_dict['serialnum'] = sfp_vendor_sn_data['data'][ 'Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A' transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data['data'][ 'Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A' transceiver_info_dict['vendor_date'] = sfp_vendor_date_data['data'][ 'VendorDataCode(YYYY-MM-DD Lot)'][ 'value'] if sfp_vendor_date_data else 'N/A' transceiver_info_dict['cable_type'] = "Unknown" transceiver_info_dict['cable_length'] = "Unknown" for key in sfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: transceiver_info_dict['cable_type'] = key transceiver_info_dict['cable_length'] = str( sfp_interface_bulk_data['data'][key]['value']) for key in sfp_compliance_code_tup: if key in sfp_interface_bulk_data['data'][ 'Specification compliance']['value']: compliance_code_dict[key] = sfp_interface_bulk_data['data'][ 'Specification compliance']['value'][key]['value'] transceiver_info_dict['specification_compliance'] = str( compliance_code_dict) transceiver_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data'] ['NominalSignallingRate(UnitsOf100Mbd)']['value']) return transceiver_info_dict
def get_transceiver_info_dict(self, port_num): transceiver_info_dict = {} compliance_code_dict = {} logger.log_debug("QFX5200: get_transceiver_info_dict Start") # ToDo: OSFP tranceiver info parsing not fully supported. # in inf8628.py lack of some memory map definition # will be implemented when the inf8628 memory map ready if port_num in self.osfp_ports: offset = 0 vendor_rev_width = XCVR_HW_REV_WIDTH_OSFP sfpi_obj = inf8628InterfaceId() if sfpi_obj is None: print("Error: sfp_object open failed") return None file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR) if not self._sfp_eeprom_present(file_path, 0): print("Error, file not exist %s" % file_path) return None try: sysfsfile_eeprom = open(file_path, mode="rb", buffering=0) except IOError: print("Error: reading sysfs file %s" % file_path) return None sfp_type_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + OSFP_TYPE_OFFSET), XCVR_TYPE_WIDTH) if sfp_type_raw is not None: sfp_type_data = sfpi_obj.parse_sfp_type(sfp_type_raw, 0) else: return None sfp_vendor_name_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + OSFP_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) if sfp_vendor_name_raw is not None: sfp_vendor_name_data = sfpi_obj.parse_vendor_name(sfp_vendor_name_raw, 0) else: return None sfp_vendor_pn_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + OSFP_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) if sfp_vendor_pn_raw is not None: sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_vendor_pn_raw, 0) else: return None sfp_vendor_rev_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + OSFP_HW_REV_OFFSET), vendor_rev_width) if sfp_vendor_rev_raw is not None: sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev(sfp_vendor_rev_raw, 0) else: return None sfp_vendor_sn_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + OSFP_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) if sfp_vendor_sn_raw is not None: sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn(sfp_vendor_sn_raw, 0) else: return None try: sysfsfile_eeprom.close() except IOError: print("Error: closing sysfs file %s" % file_path) return None transceiver_info_dict['type'] = sfp_type_data['data']['type']['value'] transceiver_info_dict['type_abbrv_name'] = sfp_type_data['data']['type_abbrv_name']['value'] transceiver_info_dict['manufacturer'] = sfp_vendor_name_data['data']['Vendor Name']['value'] transceiver_info_dict['model'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] transceiver_info_dict['hardware_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] transceiver_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] # Below part is added to avoid fail the xcvrd, shall be implemented later transceiver_info_dict['vendor_oui'] = 'N/A' transceiver_info_dict['vendor_date'] = 'N/A' transceiver_info_dict['connector'] = 'N/A' transceiver_info_dict['encoding'] = 'N/A' transceiver_info_dict['ext_identifier'] = 'N/A' transceiver_info_dict['ext_rateselect_compliance'] = 'N/A' transceiver_info_dict['cable_type'] = 'N/A' transceiver_info_dict['cable_length'] = 'N/A' transceiver_info_dict['specification_compliance'] = 'N/A' transceiver_info_dict['nominal_bit_rate'] = 'N/A' else: if port_num in self.qsfp_ports: offset = 128 vendor_rev_width = XCVR_HW_REV_WIDTH_QSFP interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_QSFP sfp_type = 'QSFP' sfpi_obj = sff8436InterfaceId() if sfpi_obj is None: print("Error: sfp_object open failed") return None else: offset = 0 vendor_rev_width = XCVR_HW_REV_WIDTH_SFP interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_SFP sfp_type = 'SFP' sfpi_obj = sff8472InterfaceId() if sfpi_obj is None: print("Error: sfp_object open failed") return None file_path = self._get_port_eeprom_path(port_num, self.IDENTITY_EEPROM_ADDR) if not self._sfp_eeprom_present(file_path, 0): print("Error, file not exist %s" % file_path) return None try: sysfsfile_eeprom = open(file_path, mode="rb", buffering=0) except IOError: print("Error: reading sysfs file %s" % file_path) return None sfp_interface_bulk_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + XCVR_INTFACE_BULK_OFFSET), interface_info_bulk_width) if sfp_interface_bulk_raw is not None: sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk(sfp_interface_bulk_raw, 0) else: return None sfp_vendor_name_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + XCVR_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) if sfp_vendor_name_raw is not None: sfp_vendor_name_data = sfpi_obj.parse_vendor_name(sfp_vendor_name_raw, 0) else: return None sfp_vendor_pn_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) if sfp_vendor_pn_raw is not None: sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_vendor_pn_raw, 0) else: return None sfp_vendor_rev_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + XCVR_HW_REV_OFFSET), vendor_rev_width) if sfp_vendor_rev_raw is not None: sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev(sfp_vendor_rev_raw, 0) else: return None sfp_vendor_sn_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + XCVR_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) if sfp_vendor_sn_raw is not None: sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn(sfp_vendor_sn_raw, 0) else: return None sfp_vendor_oui_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) if sfp_vendor_oui_raw is not None: sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui(sfp_vendor_oui_raw, 0) else: return None sfp_vendor_date_raw = self._read_eeprom_specific_bytes( sysfsfile_eeprom, (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) if sfp_vendor_date_raw is not None: sfp_vendor_date_data = sfpi_obj.parse_vendor_date(sfp_vendor_date_raw, 0) else: return None try: sysfsfile_eeprom.close() except IOError: print("Error: closing sysfs file %s" % file_path) return None transceiver_info_dict['type'] = sfp_interface_bulk_data['data']['type']['value'] transceiver_info_dict['type_abbrv_name'] = sfp_interface_bulk_data['data']['type_abbrv_name']['value'] transceiver_info_dict['manufacturer'] = sfp_vendor_name_data['data']['Vendor Name']['value'] transceiver_info_dict['model'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] transceiver_info_dict['hardware_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] transceiver_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] transceiver_info_dict['vendor_date'] = sfp_vendor_date_data[ 'data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] transceiver_info_dict['connector'] = sfp_interface_bulk_data['data']['Connector']['value'] transceiver_info_dict['encoding'] = sfp_interface_bulk_data['data']['EncodingCodes']['value'] transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data['data']['Extended Identifier']['value'] transceiver_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data['data']['RateIdentifier']['value'] if sfp_type == 'QSFP': for key in qfx5200_qsfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: transceiver_info_dict['cable_type'] = key transceiver_info_dict['cable_length'] = str(sfp_interface_bulk_data['data'][key]['value']) break else: transceiver_info_dict['cable_type'] = key transceiver_info_dict['cable_length'] = 'N/A' for key in qfx5200_qsfp_compliance_code_tup: if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value'] transceiver_info_dict['specification_compliance'] = str(compliance_code_dict) if 'Nominal Bit Rate(100Mbs)' in sfp_interface_bulk_data['data']: transceiver_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value']) else: transceiver_info_dict['nominal_bit_rate'] = 'N/A' else: for key in qfx5200_sfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: transceiver_info_dict['cable_type'] = key transceiver_info_dict['cable_length'] = str(sfp_interface_bulk_data['data'][key]['value']) else: transceiver_info_dict['cable_type'] = key transceiver_info_dict['cable_length'] = 'N/A' for key in qfx5200_sfp_compliance_code_tup: if key in sfp_interface_bulk_data['data']['Specification compliance']['value']: compliance_code_dict[key] = sfp_interface_bulk_data['data']['Specification compliance']['value'][key]['value'] transceiver_info_dict['specification_compliance'] = str(compliance_code_dict) if 'NominalSignallingRate(UnitsOf100Mbd)' in sfp_interface_bulk_data['data']: transceiver_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) else: transceiver_info_dict['nominal_bit_rate'] = 'N/A' logger.log_debug("QFX5200: get_transceiver_info_dict End") return transceiver_info_dict
def get_transceiver_info(self): """ Retrieves transceiver info of this SFP Returns: A dict which contains following keys/values : ======================================================================== keys |Value Format |Information ---------------------------|---------------|---------------------------- type |1*255VCHAR |type of SFP vendor_rev |1*255VCHAR |vendor revision of SFP serial |1*255VCHAR |serial number of the SFP manufacturer |1*255VCHAR |SFP vendor name model |1*255VCHAR |SFP model name connector |1*255VCHAR |connector information encoding |1*255VCHAR |encoding information ext_identifier |1*255VCHAR |extend identifier ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance cable_length |INT |cable length in m mominal_bit_rate |INT |nominal bit rate by 100Mbs specification_compliance |1*255VCHAR |specification compliance vendor_date |1*255VCHAR |vendor date vendor_oui |1*255VCHAR |vendor OUI ======================================================================== """ transceiver_info_dict_keys = [ 'type', 'vendor_rev', 'serial', 'manufacturer', 'model', 'connector', 'encoding', 'ext_identifier', 'ext_rateselect_compliance', 'cable_type', 'cable_length', 'nominal_bit_rate', 'specification_compliance', 'vendor_date', 'vendor_oui' ] sfp_cable_length_tup = ('LengthSMFkm-UnitsOfKm', 'LengthSMF(UnitsOf100m)', 'Length50um(UnitsOf10m)', 'Length62.5um(UnitsOfm)', 'LengthCable(UnitsOfm)', 'LengthOM3(UnitsOf10m)') sfp_compliance_code_tup = ( '10GEthernetComplianceCode', 'InfinibandComplianceCode', 'ESCONComplianceCodes', 'SONETComplianceCodes', 'EthernetComplianceCodes', 'FibreChannelLinkLength', 'FibreChannelTechnology', 'SFP+CableTechnology', 'FibreChannelTransmissionMedia', 'FibreChannelSpeed') sfpi_obj = sff8472InterfaceId() if not self.get_presence() or not sfpi_obj: return {} offset = INFO_OFFSET sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_INTFACE_BULK_OFFSET), XCVR_INTFACE_BULK_WIDTH_SFP) sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( sfp_interface_bulk_raw, 0) sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_NAME_OFFSET), XCVR_VENDOR_NAME_WIDTH) sfp_vendor_name_data = sfpi_obj.parse_vendor_name( sfp_vendor_name_raw, 0) sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_PN_OFFSET), XCVR_VENDOR_PN_WIDTH) sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_vendor_pn_raw, 0) sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_HW_REV_OFFSET), XCVR_HW_REV_WIDTH_SFP) sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev(sfp_vendor_rev_raw, 0) sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_SN_OFFSET), XCVR_VENDOR_SN_WIDTH) sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn(sfp_vendor_sn_raw, 0) sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) if sfp_vendor_oui_raw is not None: sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( sfp_vendor_oui_raw, 0) sfp_vendor_date_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) sfp_vendor_date_data = sfpi_obj.parse_vendor_date( sfp_vendor_date_raw, 0) transceiver_info_dict = dict.fromkeys(transceiver_info_dict_keys, 'N/A') if sfp_interface_bulk_data: transceiver_info_dict['type'] = sfp_interface_bulk_data['data'][ 'type']['value'] transceiver_info_dict['connector'] = sfp_interface_bulk_data[ 'data']['Connector']['value'] transceiver_info_dict['encoding'] = sfp_interface_bulk_data[ 'data']['EncodingCodes']['value'] transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data[ 'data']['Extended Identifier']['value'] transceiver_info_dict[ 'ext_rateselect_compliance'] = sfp_interface_bulk_data['data'][ 'RateIdentifier']['value'] transceiver_info_dict['type_abbrv_name'] = sfp_interface_bulk_data[ 'data']['type_abbrv_name']['value'] transceiver_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data'] ['NominalSignallingRate(UnitsOf100Mbd)']['value']) transceiver_info_dict['manufacturer'] = sfp_vendor_name_data['data'][ 'Vendor Name']['value'] if sfp_vendor_name_data else 'N/A' transceiver_info_dict['model'] = sfp_vendor_pn_data['data'][ 'Vendor PN']['value'] if sfp_vendor_pn_data else 'N/A' transceiver_info_dict['vendor_rev'] = sfp_vendor_rev_data['data'][ 'Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A' transceiver_info_dict['serial'] = sfp_vendor_sn_data['data'][ 'Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A' transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data['data'][ 'Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A' transceiver_info_dict['vendor_date'] = sfp_vendor_date_data['data'][ 'VendorDataCode(YYYY-MM-DD Lot)'][ 'value'] if sfp_vendor_date_data else 'N/A' transceiver_info_dict['cable_type'] = "Unknown" transceiver_info_dict['cable_length'] = "Unknown" for key in sfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: transceiver_info_dict['cable_type'] = key transceiver_info_dict['cable_length'] = str( sfp_interface_bulk_data['data'][key]['value']) compliance_code_dict = dict() for key in sfp_compliance_code_tup: if key in sfp_interface_bulk_data['data'][ 'Specification compliance']['value']: compliance_code_dict[key] = sfp_interface_bulk_data['data'][ 'Specification compliance']['value'][key]['value'] transceiver_info_dict['specification_compliance'] = str( compliance_code_dict) return transceiver_info_dict
def get_transceiver_info(self): """ Retrieves transceiver info of this SFP Returns: A dict which contains following keys/values : ======================================================================== keys |Value Format |Information ---------------------------|---------------|---------------------------- type |1*255VCHAR |type of SFP hardware_rev |1*255VCHAR |hardware version of SFP serial |1*255VCHAR |serial number of the SFP manufacturer |1*255VCHAR |SFP vendor name model |1*255VCHAR |SFP model name connector |1*255VCHAR |connector information encoding |1*255VCHAR |encoding information ext_identifier |1*255VCHAR |extend identifier ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance cable_length |INT |cable length in m nominal_bit_rate |INT |nominal bit rate by 100Mbs specification_compliance |1*255VCHAR |specification compliance type_abbrv_name |1*255VCHAR |type of SFP (abbreviated) vendor_date |1*255VCHAR |vendor date vendor_oui |1*255VCHAR |vendor OUI application_advertisement |1*255VCHAR |supported applications advertisement ======================================================================== """ if self.sfp_type == COPPER_TYPE: return None compliance_code_dict = {} transceiver_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') if not self.get_presence(): return transceiver_info_dict if self.sfp_type == SFP_TYPE: offset = 0 vendor_rev_width = XCVR_HW_REV_WIDTH_SFP interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_SFP sfpi_obj = sff8472InterfaceId() if sfpi_obj is None: print("Error: sfp_object open failed") return None sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( offset + XCVR_INTERFACE_DATA_START, XCVR_INTERFACE_DATA_SIZE) if sfp_interface_bulk_raw is None: return None start = XCVR_INTFACE_BULK_OFFSET - XCVR_INTERFACE_DATA_START end = start + interface_info_bulk_width sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( sfp_interface_bulk_raw[start:end], 0) start = XCVR_VENDOR_NAME_OFFSET - XCVR_INTERFACE_DATA_START end = start + XCVR_VENDOR_NAME_WIDTH sfp_vendor_name_data = sfpi_obj.parse_vendor_name( sfp_interface_bulk_raw[start:end], 0) start = XCVR_VENDOR_PN_OFFSET - XCVR_INTERFACE_DATA_START end = start + XCVR_VENDOR_PN_WIDTH sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn( sfp_interface_bulk_raw[start:end], 0) start = XCVR_HW_REV_OFFSET - XCVR_INTERFACE_DATA_START end = start + vendor_rev_width sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev( sfp_interface_bulk_raw[start:end], 0) start = XCVR_VENDOR_SN_OFFSET - XCVR_INTERFACE_DATA_START end = start + XCVR_VENDOR_SN_WIDTH sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn( sfp_interface_bulk_raw[start:end], 0) start = XCVR_VENDOR_OUI_OFFSET - XCVR_INTERFACE_DATA_START end = start + XCVR_VENDOR_OUI_WIDTH sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( sfp_interface_bulk_raw[start:end], 0) start = XCVR_VENDOR_DATE_OFFSET - XCVR_INTERFACE_DATA_START end = start + XCVR_VENDOR_DATE_WIDTH sfp_vendor_date_data = sfpi_obj.parse_vendor_date( sfp_interface_bulk_raw[start:end], 0) transceiver_info_dict['type'] = sfp_interface_bulk_data \ ['data']['type']['value'] transceiver_info_dict['manufacturer'] = sfp_vendor_name_data \ ['data']['Vendor Name']['value'] transceiver_info_dict['model'] = sfp_vendor_pn_data \ ['data']['Vendor PN']['value'] transceiver_info_dict['hardware_rev'] = sfp_vendor_rev_data \ ['data']['Vendor Rev']['value'] transceiver_info_dict['serial'] = sfp_vendor_sn_data \ ['data']['Vendor SN']['value'] transceiver_info_dict['vendor_oui'] = sfp_vendor_oui_data \ ['data']['Vendor OUI']['value'] transceiver_info_dict['vendor_date'] = sfp_vendor_date_data \ ['data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] transceiver_info_dict['connector'] = sfp_interface_bulk_data \ ['data']['Connector']['value'] transceiver_info_dict['encoding'] = sfp_interface_bulk_data \ ['data']['EncodingCodes']['value'] transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data \ ['data']['Extended Identifier']['value'] transceiver_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data \ ['data']['RateIdentifier']['value'] transceiver_info_dict['type_abbrv_name'] = sfp_interface_bulk_data \ ['data']['type_abbrv_name']['value'] for key in sfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: transceiver_info_dict['cable_type'] = key transceiver_info_dict['cable_length'] = \ str(sfp_interface_bulk_data['data'][key]['value']) for key in sfp_compliance_code_tup: if key in sfp_interface_bulk_data['data'][ 'Specification compliance']['value']: compliance_code_dict[key] = sfp_interface_bulk_data \ ['data']['Specification compliance']['value'][key]['value'] transceiver_info_dict['specification_compliance'] = \ str(compliance_code_dict) transceiver_info_dict['nominal_bit_rate'] = \ str(sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) transceiver_info_dict['application_advertisement'] = 'N/A' return transceiver_info_dict
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
def get_transceiver_info(self): """ Retrieves transceiver info of this SFP Returns: A dict which contains following keys/values : ======================================================================== keys |Value Format |Information ---------------------------|---------------|---------------------------- type |1*255VCHAR |type of SFP hardwarerev |1*255VCHAR |hardware version of SFP serialnum |1*255VCHAR |serial number of the SFP manufacturename |1*255VCHAR |SFP vendor name modelname |1*255VCHAR |SFP model name Connector |1*255VCHAR |connector information encoding |1*255VCHAR |encoding information ext_identifier |1*255VCHAR |extend identifier ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance cable_length |INT |cable length in m mominal_bit_rate |INT |nominal bit rate by 100Mbs specification_compliance |1*255VCHAR |specification compliance vendor_date |1*255VCHAR |vendor date vendor_oui |1*255VCHAR |vendor OUI ======================================================================== """ # check present status if not self.get_presence(): return None if self.is_osfp_port: sfpi_obj = inf8628InterfaceId() offset = 0 type_offset = OSFP_TYPE_OFFSET vendor_rev_width = XCVR_HW_REV_WIDTH_OSFP hw_rev_offset = OSFP_HW_REV_OFFSET vendor_name_offset = OSFP_VENDOR_NAME_OFFSET vendor_pn_offset = OSFP_VENDOR_PN_OFFSET vendor_sn_offset = OSFP_VENDOR_SN_OFFSET # cable_length_width = XCVR_CABLE_LENGTH_WIDTH_QSFP interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_QSFP sfp_type = 'OSFP' elif self.is_qsfp_port: sfpi_obj = sff8436InterfaceId() offset = 128 type_offset = XCVR_TYPE_OFFSET vendor_rev_width = XCVR_HW_REV_WIDTH_QSFP hw_rev_offset = XCVR_HW_REV_OFFSET vendor_name_offset = XCVR_VENDOR_NAME_OFFSET vendor_pn_offset = XCVR_VENDOR_PN_OFFSET vendor_sn_offset = XCVR_VENDOR_SN_OFFSET # cable_length_width = XCVR_CABLE_LENGTH_WIDTH_QSFP interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_QSFP sfp_type = 'QSFP' else: sfpi_obj = sff8472InterfaceId() offset = 0 type_offset = XCVR_TYPE_OFFSET vendor_rev_width = XCVR_HW_REV_WIDTH_SFP hw_rev_offset = XCVR_HW_REV_OFFSET vendor_name_offset = XCVR_VENDOR_NAME_OFFSET vendor_pn_offset = XCVR_VENDOR_PN_OFFSET vendor_sn_offset = XCVR_VENDOR_SN_OFFSET # cable_length_width = XCVR_CABLE_LENGTH_WIDTH_SFP interface_info_bulk_width = XCVR_INTFACE_BULK_WIDTH_SFP sfp_type = 'SFP' if sfpi_obj is None: return None if self.is_osfp_port: sfp_type_raw = self.__read_eeprom_specific_bytes( (offset + type_offset), XCVR_TYPE_WIDTH) if sfp_type_raw is not None: sfp_type_data = sfpi_obj.parse_sfp_type(sfp_type_raw, 0) sfp_type_abbrv_name = sfpi_obj.parse_sfp_type_abbrv_name( sfp_typ_raw, 0) else: sfp_interface_bulk_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_INTFACE_BULK_OFFSET), interface_info_bulk_width) if sfp_interface_bulk_raw is not None: sfp_interface_bulk_data = sfpi_obj.parse_sfp_info_bulk( sfp_interface_bulk_raw, 0) sfp_vendor_oui_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_OUI_OFFSET), XCVR_VENDOR_OUI_WIDTH) if sfp_vendor_oui_raw is not None: sfp_vendor_oui_data = sfpi_obj.parse_vendor_oui( sfp_vendor_oui_raw, 0) sfp_vendor_date_raw = self.__read_eeprom_specific_bytes( (offset + XCVR_VENDOR_DATE_OFFSET), XCVR_VENDOR_DATE_WIDTH) if sfp_vendor_date_raw is not None: sfp_vendor_date_data = sfpi_obj.parse_vendor_date( sfp_vendor_date_raw, 0) sfp_vendor_name_raw = self.__read_eeprom_specific_bytes( (offset + vendor_name_offset), XCVR_VENDOR_NAME_WIDTH) sfp_vendor_name_data = sfpi_obj.parse_vendor_name( sfp_vendor_name_raw, 0) sfp_vendor_pn_raw = self.__read_eeprom_specific_bytes( (offset + vendor_pn_offset), XCVR_VENDOR_PN_WIDTH) sfp_vendor_pn_data = sfpi_obj.parse_vendor_pn(sfp_vendor_pn_raw, 0) sfp_vendor_rev_raw = self.__read_eeprom_specific_bytes( (offset + hw_rev_offset), vendor_rev_width) sfp_vendor_rev_data = sfpi_obj.parse_vendor_rev(sfp_vendor_rev_raw, 0) sfp_vendor_sn_raw = self.__read_eeprom_specific_bytes( (offset + vendor_sn_offset), XCVR_VENDOR_SN_WIDTH) sfp_vendor_sn_data = sfpi_obj.parse_vendor_sn(sfp_vendor_sn_raw, 0) xcvr_info_dict = dict.fromkeys(self.info_dict_keys, 'N/A') compliance_code_dict = dict() if sfp_interface_bulk_data: xcvr_info_dict['type'] = sfp_interface_bulk_data['data']['type'][ 'value'] xcvr_info_dict['Connector'] = sfp_interface_bulk_data['data'][ 'Connector']['value'] xcvr_info_dict['encoding'] = sfp_interface_bulk_data['data'][ 'EncodingCodes']['value'] xcvr_info_dict['ext_identifier'] = sfp_interface_bulk_data['data'][ 'Extended Identifier']['value'] xcvr_info_dict[ 'ext_rateselect_compliance'] = sfp_interface_bulk_data['data'][ 'RateIdentifier']['value'] xcvr_info_dict['type_abbrv_name'] = sfp_interface_bulk_data[ 'data']['type_abbrv_name']['value'] else: xcvr_info_dict['type'] = sfp_type_data['data']['type'][ 'value'] if sfp_type_data else 'N/A' xcvr_info_dict['type_abbrv_name'] = sfp_type_abbrv_name['data'][ 'type_abbrv_name']['value'] if sfp_type_abbrv_name else 'N/A' xcvr_info_dict['manufacturename'] = sfp_vendor_name_data['data'][ 'Vendor Name']['value'] if sfp_vendor_name_data else 'N/A' xcvr_info_dict['modelname'] = sfp_vendor_pn_data['data']['Vendor PN'][ 'value'] if sfp_vendor_pn_data else 'N/A' xcvr_info_dict['hardwarerev'] = sfp_vendor_rev_data['data'][ 'Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A' xcvr_info_dict['serialnum'] = sfp_vendor_sn_data['data']['Vendor SN'][ 'value'] if sfp_vendor_sn_data else 'N/A' xcvr_info_dict['vendor_oui'] = sfp_vendor_oui_data['data'][ 'Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A' xcvr_info_dict['vendor_date'] = sfp_vendor_date_data['data'][ 'VendorDataCode(YYYY-MM-DD Lot)'][ 'value'] if sfp_vendor_date_data else 'N/A' xcvr_info_dict['cable_type'] = "Unknown" xcvr_info_dict['cable_length'] = "Unknown" if sfp_type == 'QSFP': for key in qsfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: xcvr_info_dict['cable_type'] = key xcvr_info_dict['cable_length'] = str( sfp_interface_bulk_data['data'][key]['value']) for key in qsfp_compliance_code_tup: if key in sfp_interface_bulk_data['data'][ 'Specification compliance']['value']: compliance_code_dict[key] = sfp_interface_bulk_data[ 'data']['Specification compliance']['value'][key][ 'value'] xcvr_info_dict['specification_compliance'] = str( compliance_code_dict) nkey = 'Nominal Bit Rate(100Mbs)' if nkey in sfp_interface_bulk_data['data']: xcvr_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)'] ['value']) else: xcvr_info_dict['nominal_bit_rate'] = 'N/A' else: for key in sfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: xcvr_info_dict['cable_type'] = key xcvr_info_dict['cable_length'] = str( sfp_interface_bulk_data['data'][key]['value']) for key in sfp_compliance_code_tup: if key in sfp_interface_bulk_data['data'][ 'Specification compliance']['value']: compliance_code_dict[key] = sfp_interface_bulk_data[ 'data']['Specification compliance']['value'][key][ 'value'] xcvr_info_dict['specification_compliance'] = str( compliance_code_dict) xcvr_info_dict['nominal_bit_rate'] = str( sfp_interface_bulk_data['data'] ['NominalSignallingRate(UnitsOf100Mbd)']['value']) return xcvr_info_dict
def __dom_capability_detect(self): self.dom_supported = False self.dom_temp_supported = False self.dom_volt_supported = False self.dom_rx_power_supported = False self.dom_tx_power_supported = False self.qsfp_page3_available = False self.calibration = 0 if not self.get_presence(): return if self.is_osfp_port: # Not implement return elif self.is_qsfp_port: self.calibration = 1 sfpi_obj = sff8436InterfaceId() if sfpi_obj is None: self.dom_supported = False offset = 128 # 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( (offset + XCVR_DOM_CAPABILITY_OFFSET), XCVR_DOM_CAPABILITY_WIDTH) if qsfp_dom_capability_raw is not None: qsfp_version_compliance_raw = self.__read_eeprom_specific_bytes( QSFP_VERSION_COMPLIANCE_OFFSET, QSFP_VERSION_COMPLIANCE_WIDTH) qsfp_version_compliance = int(qsfp_version_compliance_raw[0], 16) dom_capability = sfpi_obj.parse_dom_capability( qsfp_dom_capability_raw, 0) if qsfp_version_compliance >= 0x08: self.dom_temp_supported = dom_capability['data'][ 'Temp_support']['value'] == 'On' self.dom_volt_supported = dom_capability['data'][ 'Voltage_support']['value'] == 'On' self.dom_rx_power_supported = dom_capability['data'][ 'Rx_power_support']['value'] == 'On' self.dom_tx_power_supported = dom_capability['data'][ 'Tx_power_support']['value'] == 'On' else: self.dom_temp_supported = True self.dom_volt_supported = True self.dom_rx_power_supported = dom_capability['data'][ 'Rx_power_support']['value'] == 'On' self.dom_tx_power_supported = True self.dom_supported = True self.calibration = 1 sfpd_obj = sff8436Dom() if sfpd_obj is None: return None qsfp_option_value_raw = self.__read_eeprom_specific_bytes( QSFP_OPTION_VALUE_OFFSET, QSFP_OPTION_VALUE_WIDTH) if qsfp_option_value_raw is not None: optional_capability = sfpd_obj.parse_option_params( qsfp_option_value_raw, 0) self.dom_tx_disable_supported = optional_capability[ 'data']['TxDisable']['value'] == 'On' dom_status_indicator = sfpd_obj.parse_dom_status_indicator( qsfp_version_compliance_raw, 1) self.qsfp_page3_available = dom_status_indicator['data'][ 'FlatMem']['value'] == 'Off' else: self.dom_supported = False self.dom_temp_supported = False self.dom_volt_supported = False self.dom_rx_power_supported = False self.dom_tx_power_supported = False self.calibration = 0 self.qsfp_page3_available = False else: sfpi_obj = sff8472InterfaceId() if sfpi_obj is None: return None sfp_dom_capability_raw = self.__read_eeprom_specific_bytes( XCVR_DOM_CAPABILITY_OFFSET, XCVR_DOM_CAPABILITY_WIDTH) if sfp_dom_capability_raw is not None: sfp_dom_capability = int(sfp_dom_capability_raw[0], 16) self.dom_supported = (sfp_dom_capability & 0x40 != 0) if self.dom_supported: self.dom_temp_supported = True self.dom_volt_supported = True self.dom_rx_power_supported = True self.dom_tx_power_supported = True if sfp_dom_capability & 0x20 != 0: self.calibration = 1 elif sfp_dom_capability & 0x10 != 0: self.calibration = 2 else: self.calibration = 0 else: self.dom_temp_supported = False self.dom_volt_supported = False self.dom_rx_power_supported = False self.dom_tx_power_supported = False self.calibration = 0 self.dom_tx_disable_supported = ( int(sfp_dom_capability_raw[1], 16) & 0x40 != 0)