Skip to content

Commit b1aa104

Browse files
VadymYashchenkoYour Name
authored and
Your Name
committed
[Newport] Thermal manager (#23)
* Signed-off-by: Vadym Yashchenko <[email protected]>
1 parent 1e73127 commit b1aa104

File tree

3 files changed

+113
-15
lines changed

3 files changed

+113
-15
lines changed

device/barefoot/x86_64-accton_as9516_32d-r0/platform.json

+24-15
Original file line numberDiff line numberDiff line change
@@ -133,52 +133,61 @@
133133
],
134134
"thermals": [
135135
{
136-
"name": "tmp75-i2c-3-4b:switch-temp"
136+
"name": "com_e_driver-i2c-4-33:cpu-temp"
137137
},
138138
{
139139
"name": "com_e_driver-i2c-4-33:memory-temp"
140140
},
141141
{
142-
"name": "com_e_driver-i2c-4-33:cpu-temp"
142+
"name": "psu_driver-i2c-7-59:psu2-temp1"
143143
},
144144
{
145-
"name": "coretemp-isa-0000:core-0"
145+
"name": "psu_driver-i2c-7-59:psu2-temp2"
146146
},
147147
{
148-
"name": "coretemp-isa-0000:core-1"
148+
"name": "psu_driver-i2c-7-59:psu2-temp3"
149149
},
150150
{
151-
"name": "coretemp-isa-0000:core-2"
151+
"name": "psu_driver-i2c-7-5a:psu1-temp1"
152152
},
153153
{
154-
"name": "coretemp-isa-0000:core-3"
154+
"name": "psu_driver-i2c-7-5a:psu1-temp2"
155155
},
156156
{
157-
"name": "coretemp-isa-0000:package-id-0"
157+
"name": "psu_driver-i2c-7-5a:psu1-temp3"
158158
},
159159
{
160-
"name": "psu_driver-i2c-7-5a:psu1-temp1"
160+
"name": "tmp75-i2c-3-48:chip-temp"
161161
},
162162
{
163-
"name": "psu_driver-i2c-7-5a:psu1-temp2"
163+
"name": "tmp75-i2c-3-49:exhaust2-temp"
164164
},
165165
{
166-
"name": "psu_driver-i2c-7-5a:psu1-temp3"
166+
"name": "tmp75-i2c-3-4a:exhaust-temp"
167+
},
168+
{
169+
"name": "tmp75-i2c-3-4b:intake-temp"
170+
},
171+
{
172+
"name": "tmp75-i2c-3-4c:tofino-temp"
173+
},
174+
{
175+
"name": "tmp75-i2c-3-4d:intake2-temp"
167176
},
168177
{
169-
"name": "tmp75-i2c-3-4a:inlet-left-temp"
178+
"name": "coretemp-isa-0000:package-id-0"
170179
},
171180
{
172-
"name": "tmp75-i2c-3-4c:inlet-right-temp"
181+
"name": "coretemp-isa-0000:core-0"
173182
},
174183
{
175-
"name": "tmp75-i2c-3-4d:temp1"
184+
"name": "coretemp-isa-0000:core-1"
176185
},
177186
{
178-
"name": "tmp75-i2c-3-48:outlet-middle-temp"
187+
"name": "coretemp-isa-0000:core-2"
179188
},
180189
{
181-
"name": "tmp75-i2c-3-49:inlet-middle-temp"
190+
"name": "coretemp-isa-0000:core-3"
182191
}
183192
],
184193
"sfps": [

platform/barefoot/sonic-platform-modules-bfn-montara/sonic_platform/chassis.py

+20
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from sonic_platform.fan_drawer import fan_drawer_list_get
99
from sonic_platform.thermal import thermal_list_get
1010
from eeprom import Eeprom
11+
from sonic_platform.thermal_manager import ThermalManager
1112
except ImportError as e:
1213
raise ImportError(str(e) + "- required module not found")
1314

@@ -24,6 +25,8 @@ def __init__(self):
2425
self.__thermals = None
2526
self.__psu_list = None
2627
self.__sfp_list = None
28+
self.__thermal_mngr = None
29+
self.__polling_thermal_time = 30
2730

2831
@property
2932
def _eeprom(self):
@@ -87,6 +90,16 @@ def _sfp_list(self):
8790
def _sfp_list(self, value):
8891
pass
8992

93+
@property
94+
def _thermal_mngr(self):
95+
if self.__thermal_mngr is None:
96+
self.__thermal_mngr = ThermalManager(self.__polling_thermal_time)
97+
return self.__thermal_mngr
98+
99+
@_thermal_mngr.setter
100+
def _thermal_mngr(self, value):
101+
self.__thermal_mngr = ThermalManager(value)
102+
90103
def get_name(self):
91104
"""
92105
Retrieves the name of the chassis
@@ -240,3 +253,10 @@ def get_status_led(self):
240253
specified.
241254
"""
242255
return self.system_led
256+
257+
def get_thermal_manager(self):
258+
return self._thermal_mngr
259+
260+
def __del__(self):
261+
if self.__thermal_mngr is not None:
262+
self.__thermal_mngr.stop()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
try:
2+
from threading import Timer
3+
except ImportError as e:
4+
raise ImportError (str(e) + "- required module not found")
5+
6+
class ThermalManager():
7+
def __init__(self, polling_time = 30.0):
8+
self.__polling_thermal_time = polling_time
9+
self.__thermals = None
10+
self.__timer = None
11+
self.__chassis = None
12+
13+
def start(self):
14+
self.work()
15+
self.__timer = Timer(self.__polling_thermal_time, self.start)
16+
self.__timer.start()
17+
18+
def work(self):
19+
if self.__chassis is not None:
20+
self.__thermals = self.__chassis._thermal_list
21+
for term in self.__thermals:
22+
self.check(term)
23+
24+
def check(self, sensor):
25+
temperature = sensor.get_temperature()
26+
if temperature is not None:
27+
temp_high = sensor.get_high_threshold()
28+
temp_low = sensor.get_low_threshold()
29+
if temp_high > -999.0:
30+
if temperature > temp_high:
31+
print('Sensor ', sensor.get_name(), ' temperature more then', temp_high, '!!!')
32+
else:
33+
print('Sensor ', sensor.get_name(), ' has no high temperature threshold')
34+
35+
if temp_low > -999.0:
36+
if temperature < temp_low:
37+
print('Sensor ', sensor.get_name(), ' temperature less then', temp_low, '!!!')
38+
else:
39+
print('Sensor ', sensor.get_name(), ' has no low temperature threshold')
40+
41+
def stop(self):
42+
if self.__timer is not None:
43+
self.__timer.cancel()
44+
45+
def __del__(self):
46+
if self.__timer is not None:
47+
self.__timer.cancel()
48+
49+
# for compatibility with old version
50+
def run_policy(self, chassis_def):
51+
self.__chassis = chassis_def
52+
53+
def get_interval(self):
54+
return self.__polling_thermal_time
55+
56+
def initialize(self):
57+
pass
58+
59+
def load(self, json_file):
60+
pass
61+
62+
def init_thermal_algorithm(self, chassis_def):
63+
self.__chassis = chassis_def
64+
self.start()
65+
66+
def deinitialize(self):
67+
self.stop()
68+
del self
69+

0 commit comments

Comments
 (0)