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][201911] Set led status after updating all other fan status #18

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
19 changes: 17 additions & 2 deletions sonic-thermalctld/scripts/thermalctld
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ class FanStatus(logger.Logger):
absence_fan_count = 0
fault_fan_count = 0

def __init__(self, log_identifier):
def __init__(self, log_identifier, fan=None):
"""
Constructor of FanStatus
"""
super(FanStatus, self).__init__(log_identifier)

self.fan = fan
self.presence = True
self.under_speed = False
self.over_speed = False
Expand Down Expand Up @@ -191,6 +192,7 @@ class FanUpdater(logger.Logger):
except Exception as e:
self.log_warning('Failed to update PSU FAN status - {}'.format(repr(e)))

self._update_led_color()
self.log_debug("End fan updating")

def _refresh_fan_status(self, fan, index, name_prefix='FAN'):
Expand All @@ -203,7 +205,7 @@ class FanUpdater(logger.Logger):
"""
fan_name = try_get(fan.get_name, '{} {}'.format(name_prefix, index + 1))
if fan_name not in self.fan_status_dict:
self.fan_status_dict[fan_name] = FanStatus(SYSLOG_IDENTIFIER)
self.fan_status_dict[fan_name] = FanStatus(SYSLOG_IDENTIFIER, fan)

fan_status = self.fan_status_dict[fan_name]

Expand Down Expand Up @@ -286,6 +288,19 @@ class FanUpdater(logger.Logger):
except NotImplementedError as e:
self.log_warning('Failed to set led to fan, set_status_led not implemented')

def _update_led_color(self):
for fan_name, fan_status in self.fan_status_dict.items():
try:
fvs = swsscommon.FieldValuePairs([
('led_status', str(try_get(fan_status.fan.get_status_led)))
])
except Exception as e:
self.log_warning('Failed to get led status for fan - {}'.format(repr(e)))
fvs = swsscommon.FieldValuePairs([
('led_status', NOT_AVAILABLE)
])
self.table.set(fan_name, fvs)


class TemperatureStatus(logger.Logger):
TEMPERATURE_DIFF_THRESHOLD = 10
Expand Down