Exemple #1
0
    def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0):
        self.is_psu_eeprom = is_psu
        self.is_fan_eeprom = is_fan
        self.is_sys_eeprom = not (is_psu | is_fan)

        if self.is_sys_eeprom:
            self.start_offset = 0
            self.eeprom_path = self.I2C_DIR + "i2c-10/10-0053/eeprom"
            # System EEPROM is in ONIE TlvInfo EEPROM format
            super(Eeprom, self).__init__(self.eeprom_path,
                                         self.start_offset, '', True)
            self._load_system_eeprom()
        else:
            self.start_offset = 6
            if self.is_psu_eeprom:
                self.index = psu_index
                self.eeprom_path = self.I2C_DIR \
                    + "i2c-1/1-005{}/eeprom".format(2 - self.index)
                self.format = psu_eeprom_format
            else:
                self.index = fan_index
                self.eeprom_path = self.I2C_DIR \
                    + "i2c-11/11-005{}/eeprom".format(4 - self.index)
                self.format = fan_eeprom_format
            EepromDecoder.__init__(self, self.eeprom_path, self.format,
                                   self.start_offset, '', True)
            self._load_device_eeprom()
    def __init__(self, is_psu=False, psu_index=0, is_fan=False, fan_index=0):
        self.is_psu_eeprom = is_psu
        self.is_fan_eeprom = is_fan
        self.is_sys_eeprom = not (is_psu | is_fan)

        if self.is_sys_eeprom:
            self.start_offset = 0
            self.eeprom_path = self.I2C_DIR + "i2c-0/0-0053/eeprom"

            # System EEPROM is in ONIE TlvInfo EEPROM format
            super(Eeprom, self).__init__(self.eeprom_path,
                                         self.start_offset, '', True)
            self._load_system_eeprom()
        else:
            if self.is_psu_eeprom:
                self.index = psu_index
                self.start_offset = 18
                self.eeprom_path = self.I2C_DIR \
                    + "i2c-1/1-005{}/eeprom".format(self.index - 1)
                self.format = psu_eeprom_format

                # Decode device eeprom as per specified format
                EepromDecoder.__init__(self, self.eeprom_path, self.format,
                                       self.start_offset, '', True)
            else:
                self.index = fan_index
                self.start_offset = 0
                self.eeprom_path = self.I2C_DIR \
                    + "i2c-0/0-005{}/eeprom".format(self.index + 4)

                # Fan EEPROM is in ONIE TlvInfo EEPROM format
                super(Eeprom, self).__init__(self.eeprom_path,
                                             self.start_offset, '', True)

            self._load_device_eeprom()
Exemple #3
0
    def __init__(self, eeprom_path, device_format, start_offset):
        # Decode device eeprom as per specified format
        self.format = device_format
        self.start_offset = start_offset

        EepromDecoder.__init__(self, eeprom_path, self.format,
                               self.start_offset, '', True)
        self._load_device_eeprom()
Exemple #4
0
    def _load_device_eeprom(self):
        """
        Reads the Fan/PSU EEPROM and interprets as per the specified format
        """
        self.serial_number = 'NA'
        self.model_str = 'NA'

        # device eeproms use proprietary format
        try:
            # Read Fan/PSU EEPROM as per the specified format.
            self.eeprom_data = EepromDecoder.read_eeprom(self)
        except Exception as e:
            return

        if self.eeprom_data[0] == 255:
            return

        (valid, data) = self._get_eeprom_field("Model")
        if valid:
            self.model_str = data.decode()

        try:
            (valid, data) = self._get_eeprom_field("Serial Number")
            if valid:
                self.serial_number = data.decode()
        except Exception as e:
            return
Exemple #5
0
    def _load_device_eeprom(self):
        """
        Reads the Fan/PSU EEPROM and retrieves the serial number and
        model number of the device.
        """
        try:
            # Read Fan/PSU EEPROM as per the specified format.
            self.eeprom_data = EepromDecoder.read_eeprom(self)
        except:
            self.serial_number = 'NA'
            self.part_number = 'NA'
        else:
            (valid, data) = self._get_eeprom_field("PPID")
            if valid:
                ppid = data
                self.serial_number = (ppid[:2] + "-" + ppid[2:8] + "-" +
                                      ppid[8:13] + "-" + ppid[13:16] + "-" +
                                      ppid[16:])
                (valid, data) = self._get_eeprom_field("DPN Rev")
                if valid:
                    self.serial_number += "-" + data
            else:
                seld.serial_number = 'NA'

            (valid, data) = self._get_eeprom_field("Part Number")
            if valid:
                self.part_number = data
            else:
                self.part_number = 'NA'
Exemple #6
0
    def _load_device_eeprom(self):
        """
        Reads the Fan/PSU EEPROM and retrieves the serial number and
        model number of the device.
        """
        try:
            # Read Fan/PSU EEPROM as per the specified format.
            self.eeprom_data = EepromDecoder.read_eeprom(self)
        except Exception as e:
            self.serial_number = 'NA'
            self.part_number = 'NA'
            self.model_str = 'NA'
            self.serial = 'NA'
        else:
            (valid, data) = self._get_eeprom_field("Model")
            if valid:
                self.model_str = data
            else:
                self.model_str = 'NA'

            (valid, data) = self._get_eeprom_field("Serial Number")
            if valid:
                self.serial_number = data
            else:
                self.serial_number = 'NA'

            if self.is_psu_eeprom:
                (valid, data) = self._get_eeprom_field("PSU Type")
                if valid:
                    self.psu_type = data
                else:
                    self.psu_type = 'NA'
            else:
                (valid, data) = self._get_eeprom_field("Fan Type")
                if valid:
                    self.fan_type = data
                else:
                    self.fan_type = 'NA'
Exemple #7
0
 def __init__(self, prefdl, **kwargs):
    EepromDecoder.__init__(self, path=None, format=None, start=0, status='',
                           readonly=True, **kwargs)
    self._prefdl = prefdl
Exemple #8
0
    def _load_device_eeprom(self):
        """
        Reads the Fan/PSU EEPROM and interprets as per the specified format
        """
        self.serial_number = 'NA'
        self.part_number = 'NA'
        self.model_str = 'NA'
        self.service_tag = 'NA'
        self.mfg_date = 'NA'

        # PSU device eeproms use proprietary format
        if self.is_psu_eeprom:
            try:
                # Read Fan/PSU EEPROM as per the specified format.
                self.eeprom_data = EepromDecoder.read_eeprom(self)
            except Exception as e:
                return

            # Bail out if PSU eeprom unavailable
            if self.eeprom_data[0] == 255:
                return

            (valid, data) = self._get_eeprom_field("Model")
            if valid:
                self.model_str = data.decode()

            (valid, data) = self._get_eeprom_field("Part Number")
            if valid:
                self.part_number = data.decode()

            # Early PSU device eeproms were not programmed with serial #
            try:
                (valid, data) = self._get_eeprom_field("Serial Number")
                if valid:
                    self.serial_number = data.decode()
            except Exception as e:
                return

        # Fan device eeproms use ONIE TLV format
        else:
            try:
                # Read Fan EEPROM as per ONIE TlvInfo EEPROM format.
                self.eeprom_data = self.read_eeprom()
            except Exception as e:
                return

            eeprom = self.eeprom_data
            if not self.is_valid_tlvinfo_header(eeprom):
                return

            total_length = (eeprom[9] << 8) | eeprom[10]
            tlv_index = self._TLV_INFO_HDR_LEN
            tlv_end = self._TLV_INFO_HDR_LEN + total_length

            # Construct dictionary of eeprom TLV entries
            self.eeprom_tlv_dict = dict()
            while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end:
                if not self.is_valid_tlv(eeprom[tlv_index:]):
                    break

                tlv = eeprom[tlv_index:tlv_index + 2
                             + eeprom[tlv_index + 1]]
                code = "0x%02X" % (tlv[0])

                name, value = self.decoder(None, tlv)

                self.eeprom_tlv_dict[code] = value
                if eeprom[tlv_index] == self._TLV_CODE_CRC_32:
                    break

                tlv_index += eeprom[tlv_index+1] + 2

            self.serial_number = self.eeprom_tlv_dict.get(
                "0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA')
            self.part_number = self.eeprom_tlv_dict.get(
                "0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA')
            self.model_str = self.eeprom_tlv_dict.get(
                "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA')
            self.service_tag = self.eeprom_tlv_dict.get(
                "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA')