Esempio n. 1
0
class Thermal(ThermalBase):
    """DellEMC Platform-specific Thermal class"""

    # [ Sensor-Name, Sensor-ID ]
    SENSOR_MAPPING = [['CPU On-board', 0x6], ['ASIC On-board', 0x8],
                      ['System Front Left', 0x3], ['System Front Middle', 0x7],
                      ['System Front Right',
                       0x4], ['Inlet Airflow Sensor', 0x5],
                      ['PSU1 Airflow Sensor', 0x2],
                      ['PSU2 Airflow Sensor', 0x1]]

    def __init__(self, thermal_index):
        ThermalBase.__init__(self)
        self.index = thermal_index + 1
        self.sensor = IpmiSensor(self.SENSOR_MAPPING[self.index - 1][1])

    def get_name(self):
        """
        Retrieves the name of the thermal

        Returns:
            string: The name of the thermal
        """
        return self.SENSOR_MAPPING[self.index - 1][0]

    def get_presence(self):
        """
        Retrieves the presence of the thermal

        Returns:
            bool: True if thermal is present, False if not
        """
        return True

    def get_model(self):
        """
        Retrieves the model number (or part number) of the Thermal

        Returns:
            string: Model/part number of Thermal
        """
        return 'NA'

    def get_serial(self):
        """
        Retrieves the serial number of the Thermal

        Returns:
            string: Serial number of Thermal
        """
        return 'NA'

    def get_status(self):
        """
        Retrieves the operational status of the thermal

        Returns:
            A boolean value, True if thermal is operating properly,
            False if not
        """
        return True

    def get_temperature(self):
        """
        Retrieves current temperature reading from thermal

        Returns:
            A float number of current temperature in Celsius up to
            nearest thousandth of one degree Celsius, e.g. 30.125
        """
        is_valid, temperature = self.sensor.get_reading()
        if not is_valid:
            temperature = 0

        return float(temperature)

    def get_high_threshold(self):
        """
        Retrieves the high threshold temperature of thermal

        Returns:
            A float number, the high threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        is_valid, high_threshold = self.sensor.get_threshold(
            "UpperNonRecoverable")
        if not is_valid:
            high_threshold = 0

        return float(high_threshold)

    def get_low_threshold(self):
        """
        Retrieves the low threshold temperature of thermal

        Returns:
            A float number, the low threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        is_valid, low_threshold = self.sensor.get_threshold(
            "LowerNonRecoverable")
        if not is_valid:
            low_threshold = 0

        return float(low_threshold)

    def set_high_threshold(self, temperature):
        """
        Sets the high threshold temperature of thermal

        Args :
            temperature: A float number up to nearest thousandth of one
            degree Celsius, e.g. 30.125
        Returns:
            A boolean, True if threshold is set successfully, False if
            not
        """
        # Thermal threshold values are pre-defined based on HW.
        return False

    def set_low_threshold(self, temperature):
        """
        Sets the low threshold temperature of thermal

        Args :
            temperature: A float number up to nearest thousandth of one
            degree Celsius, e.g. 30.125
        Returns:
            A boolean, True if threshold is set successfully, False if
            not
        """
        # Thermal threshold values are pre-defined based on HW.
        return False
Esempio n. 2
0
class Psu(PsuBase):
    """DellEMC Platform-specific PSU class"""

    # { PSU-ID: { Sensor-Name: Sensor-ID } }
    SENSOR_MAPPING = {
        1: {
            "State": 0x2f,
            "Current": 0x37,
            "Power": 0x38,
            "Voltage": 0x36,
            "Temperature": 0x35
        },
        2: {
            "State": 0x39,
            "Current": 0x41,
            "Power": 0x42,
            "Voltage": 0x40,
            "Temperature": 0x3F
        }
    }

    # ( PSU-ID: FRU-ID }
    FRU_MAPPING = {1: 3, 2: 4}

    def __init__(self, psu_index):
        PsuBase.__init__(self)
        # PSU is 1-based in DellEMC platforms
        self.index = psu_index + 1
        self.state_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["State"], is_discrete=True)
        self.voltage_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Voltage"])
        self.current_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Current"])
        self.power_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Power"])
        self.temp_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Temperature"])
        self.fru = IpmiFru(self.FRU_MAPPING[self.index])
        self.psu_type_raw_cmd = "0x3A 0x0B {}".format(psu_index + 1)

        self._fan_list.append(
            Fan(fan_index=self.index, psu_fan=True, dependency=self))

    def get_name(self):
        """
        Retrieves the name of the device

        Returns:
            string: The name of the device
        """
        return "PSU{}".format(self.index)

    def get_presence(self):
        """
        Retrieves the presence of the Power Supply Unit (PSU)

        Returns:
            bool: True if PSU is present, False if not
        """
        presence = False
        is_valid, state = self.state_sensor.get_reading()
        if is_valid:
            if state & 0b1:
                presence = True

        return presence

    def get_model(self):
        """
        Retrieves the part number of the PSU

        Returns:
            string: Part number of PSU
        """
        return self.fru.get_board_part_number()

    def get_serial(self):
        """
        Retrieves the serial number of the PSU

        Returns:
            string: Serial number of PSU
        """
        return self.fru.get_board_serial()

    def get_status(self):
        """
        Retrieves the operational status of the PSU

        Returns:
            bool: True if PSU is operating properly, False if not
        """
        status = False
        is_valid, state = self.state_sensor.get_reading()
        if is_valid:
            if (state & 0b1010) == 0:
                status = True

        return status

    def get_voltage(self):
        """
        Retrieves current PSU voltage output

        Returns:
            A float number, the output voltage in volts,
            e.g. 12.1
        """
        is_valid, voltage = self.voltage_sensor.get_reading()
        if not is_valid:
            return None

        return float(voltage)

    def get_voltage_low_threshold(self):
        """
        Returns PSU low threshold in Volts
        """
        is_valid, low_threshold = self.voltage_sensor.get_threshold(
            "LowerCritical")
        if not is_valid:
            low_threshold = 11.4
        low_threshold = "{:.2f}".format(low_threshold)

        return float(low_threshold)

    def get_voltage_high_threshold(self):
        """
        Returns PSU high threshold in Volts
        """
        is_valid, high_threshold = self.voltage_sensor.get_threshold(
            "UpperCritical")
        if not is_valid:
            high_threshold = 12.6
        high_threshold = "{:.2f}".format(high_threshold)

        return float(high_threshold)

    def get_temperature(self):
        """
        Retrieves current temperature reading from thermal

        Returns:
            A float number of current temperature in Celsius up to
            nearest thousandth of one degree Celsius, e.g. 30.125
        """
        is_valid, temperature = self.temp_sensor.get_reading()
        if not is_valid:
            temperature = 0

        return float(temperature)

    def get_temperature_high_threshold(self):
        """
        Returns the high temperature threshold for PSU in Celsius
        """
        is_valid, high_threshold = self.temp_sensor.get_threshold(
            "UpperCritical")
        if not is_valid:
            high_threshold = 113
        high_threshold = "{:.2f}".format(high_threshold)

        return float(high_threshold)

    def get_current(self):
        """
        Retrieves present electric current supplied by PSU

        Returns:
            A float number, electric current in amperes,
            e.g. 15.4
        """
        is_valid, current = self.current_sensor.get_reading()
        if not is_valid:
            return None

        return float(current)

    def get_power(self):
        """
        Retrieves current energy supplied by PSU

        Returns:
            A float number, the power in watts,
            e.g. 302.6
        """
        is_valid, power = self.power_sensor.get_reading()
        if not is_valid:
            return None

        return float(power)

    def get_powergood_status(self):
        """
        Retrieves the powergood status of PSU

        Returns:
            A boolean, True if PSU has stablized its output voltages and
            passed all its internal self-tests, False if not.
        """
        status = False
        is_valid, state = self.state_sensor.get_reading()
        if is_valid:
            if (state & 0b1010) == 0:
                status = True

        return status

    def get_mfr_id(self):
        """
        Retrives the Manufacturer Id of PSU

        Returns:
            A string, the manunfacturer id.
        """
        return self.fru.get_board_mfr_id()

    def get_type(self):
        """
        Retrives the Power Type of PSU

        Returns :
            A string, PSU power type
        """
        psu_type = [None, 'AC', 'AC', 'DC']
        type_res = get_ipmitool_raw_output(self.psu_type_raw_cmd)
        if type_res is not None and len(type_res) == 1:
            return psu_type[type_res[0]]
        return None

    def get_position_in_parent(self):
        """
        Retrieves 1-based relative physical position in parent device.
        Returns:
            integer: The 1-based relative physical position in parent
            device or -1 if cannot determine the position
        """
        return self.index

    def is_replaceable(self):
        """
        Indicate whether this PSU is replaceable.
        Returns:
            bool: True if it is replaceable.
        """
        return True
Esempio n. 3
0
class Psu(PsuBase):
    """DellEMC Platform-specific PSU class"""

    # { PSU-ID: { Sensor-Name: Sensor-ID } }
    SENSOR_MAPPING = {
        1: {
            "State": 0x31,
            "Current": 0x39,
            "Power": 0x37,
            "Voltage": 0x38,
            "InCurrent": 0x36,
            "InPower": 0x34,
            "InVoltage": 0x35,
            "Temperature": 0xc
        },
        2: {
            "State": 0x32,
            "Current": 0x3F,
            "Power": 0x3D,
            "Voltage": 0x3E,
            "InCurrent": 0x3C,
            "InPower": 0x3A,
            "InVoltage": 0x3B,
            "Temperature": 0xd
        }
    }
    # ( PSU-ID: FRU-ID }
    FRU_MAPPING = {1: 1, 2: 2}

    def __init__(self, psu_index):
        PsuBase.__init__(self)
        # PSU is 1-based in DellEMC platforms
        self.index = psu_index + 1
        self.state_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["State"], is_discrete=True)
        self.voltage_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Voltage"])
        self.current_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Current"])
        self.power_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Power"])
        self.input_voltage_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["InVoltage"])
        self.input_current_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["InCurrent"])
        self.input_power_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["InPower"])
        self.temp_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Temperature"])
        self.fru = IpmiFru(self.FRU_MAPPING[self.index])

        self._fan_list.append(
            Fan(fan_index=self.index, psu_fan=True, dependency=self))

    def get_name(self):
        """
        Retrieves the name of the device

        Returns:
            string: The name of the device
        """
        return "PSU{}".format(self.index)

    def get_presence(self):
        """
        Retrieves the presence of the Power Supply Unit (PSU)

        Returns:
            bool: True if PSU is present, False if not
        """
        presence = False
        is_valid, state = self.state_sensor.get_reading()
        if is_valid:
            if (state == 0x01):
                presence = True

        return presence

    def get_temperature(self):
        """
        Retrieves current temperature reading from thermal
        Returns:
           A float number of current temperature in Celcius up to
           nearest thousandth of one degree celcius, e.g. 30.125
        """
        is_valid, temperature = self.temp_sensor.get_reading()
        if not is_valid:
            temperature = 0

        return float(temperature)

    def get_temperature_high_threshold(self):
        """
        Returns the high temperature threshold for PSU in Celsius
        """

        is_valid, high_threshold = self.temp_sensor.get_threshold(
            "UpperCritical")
        if not is_valid:
            high_threshold = 105
        high_threshold = "{:.2f}".format(high_threshold)

        return float(high_threshold)

    def get_model(self):
        """
        Retrieves the part number of the PSU

        Returns:
            string: Part number of PSU
        """
        return self.fru.get_board_part_number()

    def get_serial(self):
        """
        Retrieves the serial number of the PSU

        Returns:
            string: Serial number of PSU
        """
        return self.fru.get_board_serial()

    def get_revision(self):
        """
        Retrives thehardware revision of the device
        Returns:
            String: revision value of device
        """
        serial = self.fru.get_board_serial()
        if serial != "NA" and len(serial) == 23:
            return serial[-3:]
        else:
            return "NA"

    def is_replaceable(self):
        """
        Indicate whether this PSU is replaceable.
        Returns:
            bool: True if it is replaceable.
        """
        return True

    def get_status(self):
        """
        Retrieves the operational status of the PSU

        Returns:
            bool: True if PSU is operating properly, False if not
        """
        status = False
        is_valid, state = self.state_sensor.get_reading()
        if is_valid:
            if (state == 0x01):
                status = True

        return status

    def get_voltage(self):
        """
        Retrieves current PSU voltage output

        Returns:
            A float number, the output voltage in volts,
            e.g. 12.1
        """
        is_valid, voltage = self.voltage_sensor.get_reading()
        if not is_valid:
            return 0.0

        return float(voltage)

    def get_voltage_low_threshold(self):
        """
        Returns PSU low threshold in Volts
        """

        is_valid, low_threshold = self.voltage_sensor.get_threshold(
            "LowerCritical")
        if not is_valid:
            low_threshold = 11.6
        low_threshold = "{:.2f}".format(low_threshold)

        return float(low_threshold)

    def get_voltage_high_threshold(self):
        """
        Returns PSU high threshold in Volts
        """

        is_valid, high_threshold = self.voltage_sensor.get_threshold(
            "UpperCritical")
        if not is_valid:
            high_threshold = 12.8
        high_threshold = "{:.2f}".format(high_threshold)

        return float(high_threshold)

    def get_current(self):
        """
        Retrieves present electric current supplied by PSU

        Returns:
            A float number, electric current in amperes,
            e.g. 15.4
        """
        is_valid, current = self.current_sensor.get_reading()
        if not is_valid:
            return 0.0

        return float(current)

    def get_power(self):
        """
        Retrieves current energy supplied by PSU

        Returns:
            A float number, the power in watts,
            e.g. 302.6
        """
        is_valid, power = self.power_sensor.get_reading()
        if not is_valid:
            return 0.0

        return float(power)

    def get_input_voltage(self):
        """
        Retrieves current PSU voltage input

        Returns:
            A float number, the input voltage in volts,
            e.g. 12.1
        """
        is_valid, input_voltage = self.input_voltage_sensor.get_reading()
        if not is_valid:
            return 0.0

        return float(input_voltage)

    def get_input_current(self):
        """
        Retrieves present electric current supplied to PSU

        Returns:
            A float number, electric current in amperes,
            e.g. 15.4
        """
        is_valid, input_current = self.input_current_sensor.get_reading()
        if not is_valid:
            return 0.0

        return float(input_current)

    def get_input_power(self):
        """
        Retrieves current energy supplied to PSU

        Returns:
            A float number, the power in watts,
            e.g. 302.6
        """
        is_valid, input_power = self.input_power_sensor.get_reading()
        if not is_valid:
            return None

        return float(input_power)

    def get_powergood_status(self):
        """
        Retrieves the powergood status of PSU

        Returns:
            A boolean, True if PSU has stablized its output voltages and
            passed all its internal self-tests, False if not.
        """
        status = False
        is_valid, state = self.state_sensor.get_reading()
        if is_valid:
            if (state == 0x01):
                status = True

        return status

    def get_mfr_id(self):
        """
        Retrives the Manufacturer Id of PSU

        Returns:
            A string, the manunfacturer id.
        """
        return self.fru.get_board_mfr_id()

    def get_type(self):
        """
        Retrives the Power Type of PSU

        Returns :
            A string, PSU power type
        """
        board_product = self.fru.get_board_product()
        if board_product is not None:
            info = board_product.split(',')
            if 'AC' in info: return 'AC'
            if 'DC' in info: return 'DC'
        return None

    def get_position_in_parent(self):
        """
        Retrieves 1-based relative physical position in parent device.
        Returns:
            integer: The 1-based relative physical position in parent
            device or -1 if cannot determine the position
        """
        return self.index

    def get_maximum_supplied_power(self):
        """
        Retrieves the maximum supplied power by PSU
        Returns:
            A float number, the maximum power output in Watts.
            e.g. 1200.1
        """
        return float(750)

    def set_status_led(self, color):
        """
        Sets the state of the PSU status LED
        Args:
            color: A string representing the color with which to set the PSU status LED
                   Note: Only support green and off
        Returns:
            bool: True if status LED state is set successfully, False if not
        """
        # Hardware not supported
        return False
Esempio n. 4
0
class Thermal(ThermalBase):
    """DellEMC Platform-specific Thermal class"""

    # [ Sensor-Name, Sensor-ID ]
    SENSOR_MAPPING = [['CPU On-board', 0x5], ['Baseboard U3', 0x4],
                      ['SW Internal', 0x61], ['Fan U52', 0x0],
                      ['Fan U17', 0x1], ['SW U52', 0x2], ['SW U16', 0x3],
                      ['PSU1 Inlet', 0x34], ['PSU1 Hotspot', 0x35],
                      ['PSU2 Inlet', 0x3E], ['PSU2 Hotspot', 0x3F],
                      ['SW U04', 0x4F], ['SW U14', 0x56], ['SW U4403', 0x5D]]

    def __init__(self, thermal_index=0):
        ThermalBase.__init__(self)
        self.index = thermal_index + 1
        self.sensor = IpmiSensor(self.SENSOR_MAPPING[self.index - 1][1])

    def get_name(self):
        """
        Retrieves the name of the thermal

        Returns:
            string: The name of the thermal
        """
        return self.SENSOR_MAPPING[self.index - 1][0]

    def get_presence(self):
        """
        Retrieves the presence of the thermal

        Returns:
            bool: True if thermal is present, False if not
        """
        return True

    def get_model(self):
        """
        Retrieves the model number (or part number) of the Thermal

        Returns:
            string: Model/part number of Thermal
        """
        return 'NA'

    def get_serial(self):
        """
        Retrieves the serial number of the Thermal

        Returns:
            string: Serial number of Thermal
        """
        return 'NA'

    def get_status(self):
        """
        Retrieves the operational status of the thermal

        Returns:
            A boolean value, True if thermal is operating properly,
            False if not
        """
        return True

    def get_temperature(self):
        """
        Retrieves current temperature reading from thermal

        Returns:
            A float number of current temperature in Celsius up to
            nearest thousandth of one degree Celsius, e.g. 30.125
        """
        is_valid, temperature = self.sensor.get_reading()
        if not is_valid:
            temperature = 0

        return float(temperature)

    def get_high_threshold(self):
        """
        Retrieves the high threshold temperature of thermal

        Returns:
            A float number, the high threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        is_valid, high_threshold = self.sensor.get_threshold(
            "UpperNonCritical")
        if not is_valid:
            return super(Thermal, self).get_high_threshold()

        return float(high_threshold)

    def get_low_threshold(self):
        """
        Retrieves the low threshold temperature of thermal

        Returns:
            A float number, the low threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        is_valid, low_threshold = self.sensor.get_threshold(
            "LowerNonRecoverable")
        if not is_valid:
            low_threshold = 0

        return float(low_threshold)

    def get_high_critical_threshold(self):
        """
        Retrieves the high critical threshold temperature of thermal
        Returns:
            A float number, the high critical threshold temperature of
            thermal in Celsius up to nearest thousandth of one degree
            Celsius, e.g. 30.125
        """
        is_valid, high_crit_threshold = self.sensor.get_threshold(
            "UpperCritical")
        if not is_valid:
            return super(Thermal, self).get_high_critical_threshold()

        return float(high_crit_threshold)

    def set_high_threshold(self, temperature):
        """
        Sets the high threshold temperature of thermal

        Args :
            temperature: A float number up to nearest thousandth of one
            degree Celsius, e.g. 30.125
        Returns:
            A boolean, True if threshold is set successfully, False if
            not
        """
        # Thermal threshold values are pre-defined based on HW.
        return False

    def set_low_threshold(self, temperature):
        """
        Sets the low threshold temperature of thermal

        Args :
            temperature: A float number up to nearest thousandth of one
            degree Celsius, e.g. 30.125
        Returns:
            A boolean, True if threshold is set successfully, False if
            not
        """
        # Thermal threshold values are pre-defined based on HW.
        return False
Esempio n. 5
0
class Thermal(ThermalBase):
    """DellEMC Platform-specific Thermal class"""

    # [ Sensor-Name, Sensor-ID, high threshold, high critical_threshold ]
    SENSOR_MAPPING = [
        ['CPU On-board', 0x5, False, True],
        ['Baseboard U3', 0x4, False, False],
        ['SW Internal', 0x61, True, True],
        ['Fan U52', 0x0, True, True],
        ['Fan U17', 0x1, False, False],
        ['SW U52', 0x2, False, False],
        ['SW U16', 0x3, True, True],
        ['PSU1 Inlet', 0x34, False, False],
        ['PSU1 Hotspot', 0x35, False, False],
        ['PSU2 Inlet',  0x3E, False, False],
        ['PSU2 Hotspot', 0x3F, False, False],
        ['SW U04', 0x4F, False, False],
        ['SW U14', 0x56, False, False],
        ['SW U4403', 0x5D, False, False]
    ]

    def __init__(self, thermal_index=0):
        ThermalBase.__init__(self)
        self.index = thermal_index + 1
        self.sensor = IpmiSensor(self.SENSOR_MAPPING[self.index - 1][1])
        self.has_high_threshold = self.SENSOR_MAPPING[self.index - 1][2]
        self.has_high_crit_threshold = self.SENSOR_MAPPING[self.index - 1][3]

    def get_name(self):
        """
        Retrieves the name of the thermal

        Returns:
            string: The name of the thermal
        """
        return self.SENSOR_MAPPING[self.index - 1][0]

    def get_presence(self):
        """
        Retrieves the presence of the thermal

        Returns:
            bool: True if thermal is present, False if not
        """
        return True

    def get_model(self):
        """
        Retrieves the model number (or part number) of the Thermal

        Returns:
            string: Model/part number of Thermal
        """
        return 'NA'

    def get_serial(self):
        """
        Retrieves the serial number of the Thermal

        Returns:
            string: Serial number of Thermal
        """
        return 'NA'

    def get_status(self):
        """
        Retrieves the operational status of the thermal

        Returns:
            A boolean value, True if thermal is operating properly,
            False if not
        """
        return True

    def get_temperature(self):
        """
        Retrieves current temperature reading from thermal

        Returns:
            A float number of current temperature in Celsius up to
            nearest thousandth of one degree Celsius, e.g. 30.125
        """
        is_valid, temperature = self.sensor.get_reading()
        if not is_valid:
            temperature = 0

        return float(temperature)

    def get_high_threshold(self):
        """
        Retrieves the high threshold temperature of thermal

        Returns:
            A float number, the high threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        if self.has_high_threshold:
            is_valid, high_threshold = self.sensor.get_threshold("UpperNonCritical")
            if is_valid:
                return float(high_threshold)

        return super(Thermal, self).get_high_threshold()

    def get_low_threshold(self):
        """
        Retrieves the low threshold temperature of thermal

        Returns:
            A float number, the low threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        return 0.0

    def get_high_critical_threshold(self):
        """
        Retrieves the high critical threshold temperature of thermal
        Returns:
            A float number, the high critical threshold temperature of
            thermal in Celsius up to nearest thousandth of one degree
            Celsius, e.g. 30.125
        """
        if self.has_high_crit_threshold:
            is_valid, high_crit_threshold = self.sensor.get_threshold("UpperCritical")
            if is_valid:
                return float(high_crit_threshold)

        return super(Thermal, self).get_high_critical_threshold()

    def set_high_threshold(self, temperature):
        """
        Sets the high threshold temperature of thermal

        Args :
            temperature: A float number up to nearest thousandth of one
            degree Celsius, e.g. 30.125
        Returns:
            A boolean, True if threshold is set successfully, False if
            not
        """
        # Thermal threshold values are pre-defined based on HW.
        return False

    def set_low_threshold(self, temperature):
        """
        Sets the low threshold temperature of thermal

        Args :
            temperature: A float number up to nearest thousandth of one
            degree Celsius, e.g. 30.125
        Returns:
            A boolean, True if threshold is set successfully, False if
            not
        """
        # Thermal threshold values are pre-defined based on HW.
        return False

    def get_position_in_parent(self):
        """
        Retrieves 1-based relative physical position in parent device.
        Returns:
            integer: The 1-based relative physical position in parent
            device or -1 if cannot determine the position
        """
        return self.index

    def is_replaceable(self):
        """
        Indicate whether this Thermal is replaceable.
        Returns:
            bool: True if it is replaceable.
        """
        return False
Esempio n. 6
0
class Thermal(ThermalBase):
    """DellEMC Platform-specific Thermal class"""

    # [ Sensor-Name, Sensor-ID, high threshold, high critical_threshold ]
    # TBD :
    #       high thershold/hich crit threshold
    #       need to be modified as True in case if it is supported
    #
    SENSOR_MAPPING = [['CPU Temp', 0xd, True, True],
                      ['FAN Right Temp', 0x0, True, True],
                      ['NPU Front Temp', 0x1, True, True],
                      ['NPU Rear Temp', 0x3, True, True],
                      ['NPU Temp', 0x8, True, True],
                      ['PSU1 AF Temp', 0x46, False, True],
                      ['PSU1 Mid Temp', 0x47, False, True],
                      ['PSU1 Rear Temp', 0x48, False, True],
                      ['PSU2 AF Temp', 0x36, False, True],
                      ['PSU2 Mid Temp', 0x37, False, True],
                      ['PSU2 Rear Temp', 0x38, False, True],
                      ['PT Left Temp', 0x2, True, True],
                      ['PT Right Temp', 0x4, True, True]]

    def __init__(self, thermal_index=0):
        ThermalBase.__init__(self)
        self.index = thermal_index + 1
        self.sensor = IpmiSensor(self.SENSOR_MAPPING[self.index - 1][1])
        self.has_high_threshold = self.SENSOR_MAPPING[self.index - 1][2]
        self.has_high_crit_threshold = self.SENSOR_MAPPING[self.index - 1][3]

    def get_name(self):
        """
        Retrieves the name of the thermal

        Returns:
            string: The name of the thermal
        """
        return self.SENSOR_MAPPING[self.index - 1][0]

    def get_presence(self):
        """
        Retrieves the presence of the thermal

        Returns:
            bool: True if thermal is present, False if not
        """
        return True

    def get_model(self):
        """
        Retrieves the model number (or part number) of the Thermal

        Returns:
            string: Model/part number of Thermal
        """
        return 'NA'

    def get_serial(self):
        """
        Retrieves the serial number of the Thermal

        Returns:
            string: Serial number of Thermal
        """
        return 'NA'

    def get_status(self):
        """
        Retrieves the operational status of the thermal

        Returns:
            A boolean value, True if thermal is operating properly,
            False if not
        """
        return True

    def get_temperature(self):
        """
        Retrieves current temperature reading from thermal

        Returns:
            A float number of current temperature in Celsius up to
            nearest thousandth of one degree Celsius, e.g. 30.125
        """
        is_valid, temperature = self.sensor.get_reading()
        if not is_valid:
            temperature = 0

        return float(temperature)

    def get_high_threshold(self):
        """
        Retrieves the high threshold temperature of thermal

        Returns:
            A float number, the high threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        if self.has_high_threshold:
            is_valid, high_threshold = self.sensor.get_threshold(
                "UpperNonCritical")
            if is_valid:
                return float(high_threshold)

        return super(Thermal, self).get_high_threshold()

    def get_low_threshold(self):
        """
        Retrieves the low threshold temperature of thermal

        Returns:
            A float number, the low threshold temperature of thermal in
            Celsius up to nearest thousandth of one degree Celsius,
            e.g. 30.125
        """
        return 0.0

    def get_high_critical_threshold(self):
        """
        Retrieves the high critical threshold temperature of thermal
        Returns:
            A float number, the high critical threshold temperature of
            thermal in Celsius up to nearest thousandth of one degree
            Celsius, e.g. 30.125
        """
        if self.has_high_crit_threshold:
            is_valid, high_crit_threshold = self.sensor.get_threshold(
                "UpperCritical")
            if is_valid:
                return float(high_crit_threshold)

        return super(Thermal, self).get_high_critical_threshold()

    def set_high_threshold(self, temperature):
        """
        Sets the high threshold temperature of thermal

        Args :
            temperature: A float number up to nearest thousandth of one
            degree Celsius, e.g. 30.125
        Returns:
            A boolean, True if threshold is set successfully, False if
            not
        """
        # Thermal threshold values are pre-defined based on HW.
        return False

    def set_low_threshold(self, temperature):
        """
        Sets the low threshold temperature of thermal

        Args :
            temperature: A float number up to nearest thousandth of one
            degree Celsius, e.g. 30.125
        Returns:
            A boolean, True if threshold is set successfully, False if
            not
        """
        # Thermal threshold values are pre-defined based on HW.
        return False

    def get_position_in_parent(self):
        """
        Retrieves 1-based relative physical position in parent device.
        Returns:
            integer: The 1-based relative physical position in parent
            device or -1 if cannot determine the position
        """
        return self.index

    def is_replaceable(self):
        """
        Indicate whether this Thermal is replaceable.
        Returns:
            bool: True if it is replaceable.
        """
        return False