Skip to content

Commit

Permalink
[sonic_thermal]Add abstract class for thermal plugin (sonic-net#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenxs authored and jleveque committed Jan 21, 2020
1 parent 6f74dd3 commit 8678383
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 0 deletions.
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
'sonic_psu',
'sonic_fan',
'sonic_sfp',
'sonic_thermal',
],
classifiers=[
'Development Status :: 3 - Alpha',
Expand Down
Empty file added sonic_thermal/__init__.py
Empty file.
90 changes: 90 additions & 0 deletions sonic_thermal/thermal_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env python
#
# thermal_base.py
#
# Base class for implementing platform-specific
# Thermal functionality for SONiC

try:
import abc
except ImportError as e:
raise ImportError (str(e) + " - required module not found")

class ThermalBase(object):
__metaclass__ = abc.ABCMeta

def get_num_thermals(self):
"""
Retrieves the number of thermal sensors supported on the device
:return: An integer, the number of thermal sensors supported on the device
"""
return 0

def get_name(self, index):
"""
Retrieves the human-readable name of a thermal sensor by 1-based index
Returns:
:param index: An integer, 1-based index of the thermal sensor of which to query status
:return: String,
A string representing the name of the thermal sensor.
"""
return ""

def get_temperature(self, index):
"""
Retrieves current temperature reading from thermal sensor by 1-based index
:param index: An integer, 1-based index of the thermal sensor of which to query status
:return: Float,
A float number of current temperature in Celsius up to nearest thousandth
of one degree Celsius, e.g. 30.125
"""
return 0.0

def get_low_threshold(self, index):
"""
Retrieves the low threshold temperature of thermal sensor by 1-based index
Actions should be taken if the temperature becomes lower than the low threshold.
:param index: An integer, 1-based index of the thermal sensor of which to query status
:return: 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_low_critical_threshold(self, index):
"""
Retrieves the low critical threshold temperature of thermal by 1-based index
Actions should be taken immediately if the temperature becomes lower than the low critical
threshold otherwise the device will be damaged.
:param index: An integer, 1-based index of the thermal sensor of which to query status
:return: A float number, the low critical threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
return 0.0

def get_high_threshold(self, index):
"""
Retrieves the high threshold temperature of thermal by 1-based index
Actions should be taken if the temperature becomes higher than the threshold.
:param index: An integer, 1-based index of the thermal sensor of which to query status
:return: A float number, the high 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, index):
"""
Retrieves the high critical threshold temperature of thermal by 1-based index
Actions should be taken immediately if the temperature becomes higher than the high critical
threshold otherwise the device will be damaged.
:param index: An integer, 1-based index of the thermal sensor of which to query status
:return: A float number, the high critical threshold temperature of thermal in Celsius
up to nearest thousandth of one degree Celsius, e.g. 30.125
"""
return 0.0

0 comments on commit 8678383

Please sign in to comment.