Skip to content

Commit

Permalink
Fixed review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Nazarii Hnydyn <[email protected]>
  • Loading branch information
nazariig committed Feb 27, 2019
1 parent 9ec1636 commit fd1e078
Showing 1 changed file with 33 additions and 12 deletions.
45 changes: 33 additions & 12 deletions sonic-xcvrd/scripts/xcvrd
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def del_port_sfp_dom_info_from_db(logical_port_name, int_tbl, dom_tbl):

# wait for port config is done
def wait_for_port_config_done():
# Connect to APPL_DB abd subscribe to PORT table notifications
# Connect to APPL_DB and subscribe to PORT table notifications
appl_db = swsscommon.DBConnector(swsscommon.APPL_DB,
REDIS_HOSTNAME,
REDIS_PORT,
Expand Down Expand Up @@ -383,12 +383,11 @@ class dom_info_update_task:
def task_worker(self):
log_info("Start DOM monitoring loop")

# Connect to STATE_DB and create transceiver dom/sfp info tables
# Connect to STATE_DB and create transceiver dom info table
state_db = swsscommon.DBConnector(swsscommon.STATE_DB,
REDIS_HOSTNAME,
REDIS_PORT,
REDIS_TIMEOUT_MSECS)
int_tbl = swsscommon.Table(state_db, "TRANSCEIVER_INFO")
dom_tbl = swsscommon.Table(state_db, "TRANSCEIVER_DOM_SENSOR")

# Start loop to update dom info in DB periodically
Expand All @@ -397,11 +396,6 @@ class dom_info_update_task:
for logical_port_name in logical_port_list:
post_port_dom_info_to_db(logical_port_name, dom_tbl)

# Delete all the information from DB and then exit
logical_port_list = platform_sfputil.logical
for logical_port_name in logical_port_list:
del_port_sfp_dom_info_from_db(logical_port_name, int_tbl, dom_tbl)

log_info("Stop DOM monitoring loop")

def task_run(self):
Expand Down Expand Up @@ -474,10 +468,9 @@ class sfp_state_update_task:
self.task_stopping_event.set()
os.kill(self.task_process.pid, signal.SIGKILL)

#=============================== Main ================================

def main():
log_info("Starting up...")
# initialize daemon
def daemon_init():
log_info("Start daemon init...")

# Register our signal handlers
signal.signal(signal.SIGHUP, signal_handler)
Expand Down Expand Up @@ -507,6 +500,31 @@ def main():
log_info("Post all port DOM/SFP info to DB")
post_port_sfp_dom_info_to_db()

# deinitialize daemon
def daemon_deinit():
log_info("Start daemon deinit...")

# Connect to STATE_DB and create transceiver dom/sfp info tables
state_db = swsscommon.DBConnector(swsscommon.STATE_DB,
REDIS_HOSTNAME,
REDIS_PORT,
REDIS_TIMEOUT_MSECS)
int_tbl = swsscommon.Table(state_db, "TRANSCEIVER_INFO")
dom_tbl = swsscommon.Table(state_db, "TRANSCEIVER_DOM_SENSOR")

# Delete all the information from DB and then exit
logical_port_list = platform_sfputil.logical
for logical_port_name in logical_port_list:
del_port_sfp_dom_info_from_db(logical_port_name, int_tbl, dom_tbl)

#=============================== Main ================================

def main():
log_info("Starting up...")

# Start daemon initialization sequence
daemon_init()

# Start the dom sensor info update thread
dom_info_update = dom_info_update_task()
dom_info_update.task_run()
Expand All @@ -529,6 +547,9 @@ def main():
# Stop the sfp state info update process
sfp_state_update.task_stop()

# Start daemon deinitialization sequence
daemon_deinit()

log_info("Shutting down...")

if __name__ == '__main__':
Expand Down

0 comments on commit fd1e078

Please sign in to comment.