Ejemplo n.º 1
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
Ejemplo n.º 2
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'
Ejemplo n.º 3
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'
Ejemplo n.º 4
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')