Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Thermalctld] Update thermal info to CHASSIS_STATE_DB #101

Merged
merged 2 commits into from
Nov 11, 2020
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()
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
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")
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
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
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
high_critical_threshold = NOT_AVAILABLE
low_critical_threshold = NOT_AVAILABLE
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
maximum_temperature = NOT_AVAILABLE
minimum_temperature = NOT_AVAILABLE
temperature = try_get(thermal.get_temperature)
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
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)
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
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)),
mprabhu-nokia marked this conversation as resolved.
Show resolved Hide resolved
('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