Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions sonic-thermalctld/scripts/thermalctld
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,22 @@ class TemperatureUpdater(logger.Logger):
state_db = daemon_base.db_connect("STATE_DB")
self.table = swsscommon.Table(state_db, TemperatureUpdater.TEMPER_INFO_TABLE_NAME)

self.is_chassis_system = chassis.is_modular_chassis()
if self.is_chassis_system:
my_slot = chassis.get_my_slot()
table_name = TemperatureUpdater.TEMPER_INFO_TABLE_NAME+'_'+str(my_slot)
global_state_db = daemon_base.db_connect("GLOBAL_STATE_DB")
self.global_table = swsscommon.Table(global_state_db, table_name)

def deinit(self):
"""
Destructor of TemperatureUpdater
:return:
"""
for name in self.temperature_status_dict.keys():
self.table._del(name)
if self.is_chassis_system:
self.global_table._del(name)

def _log_on_status_changed(self, normal_status, normal_log, abnormal_log):
"""
Expand Down Expand Up @@ -515,9 +524,13 @@ class TemperatureUpdater(logger.Logger):
low_threshold = NOT_AVAILABLE
high_critical_threshold = NOT_AVAILABLE
low_critical_threshold = NOT_AVAILABLE
maximum_temperature = NOT_AVAILABLE
minimum_temperature = NOT_AVAILABLE
temperature = try_get(thermal.get_temperature)
if temperature != NOT_AVAILABLE:
temperature_status.set_temperature(name, temperature)
minimum_temperature = try_get(thermal.get_minimum_recorded)
maximum_temperature = try_get(thermal.get_maximum_recorded)
high_threshold = try_get(thermal.get_high_threshold)
low_threshold = try_get(thermal.get_low_threshold)
high_critical_threshold = try_get(thermal.get_high_critical_threshold)
Expand All @@ -544,6 +557,8 @@ class TemperatureUpdater(logger.Logger):

fvs = swsscommon.FieldValuePairs(
[('temperature', str(temperature)),
('minimum_temperature', str(minimum_temperature)),
('maximum_temperature', str(maximum_temperature)),
('high_threshold', str(high_threshold)),
('low_threshold', str(low_threshold)),
('warning_status', str(warning)),
Expand All @@ -553,6 +568,8 @@ class TemperatureUpdater(logger.Logger):
])

self.table.set(name, fvs)
if self.is_chassis_system:
self.global_table.set(name, fvs)


class ThermalMonitor(ProcessTaskBase):
Expand Down
11 changes: 11 additions & 0 deletions sonic-thermalctld/tests/mock_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class MockThermal:
def __init__(self):
self.name = None
self.temperature = 2
self.minimum_temperature = 1
self.maximum_temperature = 5
self.high_threshold = 3
self.low_threshold = 1
self.high_critical_threshold = 4
Expand All @@ -115,6 +117,12 @@ def get_name(self):
def get_temperature(self):
return self.temperature

def get_minimum_recorded(self):
return self.minimum_temperature

def get_maximum_recorded(self):
return self.maximum_temperature

def get_high_threshold(self):
return self.high_threshold

Expand Down Expand Up @@ -155,6 +163,9 @@ def __init__(self):
self.thermal_list = []
self.fan_drawer_list = []

def is_modular_chassis(self):
return False

def get_all_fans(self):
return self.fan_list

Expand Down
2 changes: 1 addition & 1 deletion sonic-thermalctld/tests/mock_swsscommon.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
STATE_DB = ''

GLOBAL_STATE_DB = ''

class Table:
def __init__(self, db, table_name):
Expand Down