Skip to content

Commit

Permalink
Remove redundancy in ledd (sonic-net#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhiyuan authored and jleveque committed Feb 26, 2018
1 parent 920f29b commit 31c007e
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions sonic-ledd/scripts/ledd
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ def load_platform_led_control_module():
#=============================== Main ================================

def main():
port_status_dict = {}

log_info("Starting up...")

if not os.geteuid() == 0:
Expand Down Expand Up @@ -201,8 +199,7 @@ def main():

# Loop forever
while True:
# TODO: Move dictionary creation and population out of while loop. Do it only once
# and subscribe for notifications from DB when ports come or go. Add/remove
# TODO: Subscribe for notifications from DB when ports come or go. Add/remove
# dictionary entries as necessary.

# Get a list of all ports from the database
Expand All @@ -219,16 +216,8 @@ def main():
if port_name in ["PortConfigDone", "PortInitDone"]:
continue

port_status_dict[port_name] = 'down'
led_control.port_link_state_change(port_name, port_status_dict[port_name])

for (key, value) in port_status_dict.iteritems():
status = swss.get(swss.APPL_DB, PORT_TABLE_PREFIX + key, 'oper_status')

# If the status has changed, update it in our dictionary and report to our plugin
if value != status:
port_status_dict[key] = status
led_control.port_link_state_change(key, status)
status = swss.get(swss.APPL_DB, PORT_TABLE_PREFIX + port_name, 'oper_status')
led_control.port_link_state_change(key, status)

time.sleep(1)

Expand Down

0 comments on commit 31c007e

Please sign in to comment.