Skip to content

Commit 893d1c7

Browse files
committed
Report ready status to Sysmonitor daemon
Signed-off-by: Yevhen Fastiuk <[email protected]>
1 parent 88bf8ec commit 893d1c7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

sonic-xcvrd/xcvrd/xcvrd.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,37 @@ def strip_unit_and_beautify(value, unit):
244244
return str(value)
245245

246246

247+
def notify_system_ready(fail_status=False, fail_reason='-'):
248+
key = 'FEATURE|pmon'
249+
statusvalue = {}
250+
251+
try:
252+
state_db = swsscommon.SonicV2Connector(host='127.0.0.1')
253+
state_db.connect(state_db.STATE_DB)
254+
except Exception:
255+
helper_logger.log_error('Failed to connect STATE_DB to report '
256+
f'{SYSLOG_IDENTIFIER} ready status')
257+
return
258+
259+
if fail_status:
260+
statusvalue['up_status'] = 'false'
261+
statusvalue['fail_reason'] = fail_reason
262+
else:
263+
statusvalue['up_status'] = 'true'
264+
265+
if getattr(notify_system_ready, 'reported', False):
266+
helper_logger.log_debug(
267+
f'{SYSLOG_IDENTIFIER} ready status already reported. Tried to '
268+
f'report status: {statusvalue}')
269+
return
270+
271+
state_db.delete(state_db.STATE_DB, key)
272+
state_db.hmset(state_db.STATE_DB, key, statusvalue)
273+
helper_logger.log_info(f'Report {SYSLOG_IDENTIFIER} ready status: '
274+
f'{statusvalue}')
275+
notify_system_ready.reported = True
276+
277+
247278
def _wrapper_get_presence(physical_port):
248279
if platform_chassis is not None:
249280
try:
@@ -2357,6 +2388,11 @@ def retry_eeprom_reading(self):
23572388
# Update retry EEPROM set
23582389
self.retry_eeprom_set -= retry_success_set
23592390

2391+
# If we were here and now retry_eeprom_set is empty, then we can state
2392+
# that all SFPs accessible
2393+
if not self.retry_eeprom_set:
2394+
notify_system_ready()
2395+
23602396

23612397
#
23622398
# Daemon =======================================================================

0 commit comments

Comments
 (0)