Skip to content

Commit c7044b7

Browse files
committed
Multi-asic changes commit (PR sonic-net#64 ) into 201911
1 parent 29fc800 commit c7044b7

File tree

2 files changed

+170
-69
lines changed
  • sonic-ledd/scripts
  • sonic-xcvrd/scripts

2 files changed

+170
-69
lines changed

sonic-ledd/scripts/ledd

+31-14
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ try:
1414
import sys
1515

1616
from sonic_py_common import daemon_base
17+
from sonic_py_common import multi_asic
18+
from sonic_py_common.interface import backplane_prefix
1719
from swsscommon import swsscommon
1820
except ImportError, e:
1921
raise ImportError (str(e) + " - required module not found")
@@ -39,6 +41,9 @@ SELECT_TIMEOUT = 1000
3941

4042
LEDUTIL_LOAD_ERROR = 1
4143

44+
# The empty namespace refers to linux host namespace.
45+
EMPTY_NAMESPACE = ''
46+
4247
class DaemonLedd(daemon_base.DaemonBase):
4348

4449
# Run daemon
@@ -69,15 +74,24 @@ class DaemonLedd(daemon_base.DaemonBase):
6974
self.log_error("Failed to load ledutil: %s" % (str(e)), True)
7075
sys.exit(LEDUTIL_LOAD_ERROR)
7176

72-
# Open a handle to the Application database
73-
appl_db = daemon_base.db_connect("APPL_DB")
77+
# Load the namespace details first from the database_global.json file.
78+
swsscommon.SonicDBConfig.initializeGlobalConfig()
79+
80+
# Get the namespaces in the platform. For multi-asic devices we get the namespaces
81+
# of front-end ascis which have front-panel interfaces.
82+
namespaces = multi_asic.get_front_end_namespaces()
7483

7584
# Subscribe to PORT table notifications in the Application DB
85+
appl_db, sst = {}, {}
7686
sel = swsscommon.Select()
77-
sst = swsscommon.SubscriberStateTable(appl_db, swsscommon.APP_PORT_TABLE_NAME)
78-
sel.addSelectable(sst)
7987

80-
# Listen indefinitely for changes to the PORT table in the Application DB
88+
for namespace in namespaces:
89+
# Open a handle to the Application database, in all namespaces
90+
appl_db[namespace] = daemon_base.db_connect("APPL_DB", namespace=namespace)
91+
sst[namespace] = swsscommon.SubscriberStateTable(appl_db[namespace], swsscommon.APP_PORT_TABLE_NAME)
92+
sel.addSelectable(sst[namespace])
93+
94+
# Listen indefinitely for changes to the PORT table in the Application DB's
8195
while True:
8296
# Use timeout to prevent ignoring the signals we want to handle
8397
# in signal_handler() (e.g. SIGTERM for graceful shutdown)
@@ -90,17 +104,20 @@ class DaemonLedd(daemon_base.DaemonBase):
90104
self.log_warning("sel.select() did not return swsscommon.Select.OBJECT")
91105
continue
92106

93-
(key, op, fvp) = sst.pop()
94-
95-
# TODO: Once these flag entries have been removed from the DB,
96-
# we can remove this check
97-
if key in ["PortConfigDone", "PortInitDone"]:
98-
continue
107+
# Get the namespace from the selectable object and use it to index the SubscriberStateTable handle.
108+
ns=c.getDbNamespace()
109+
(key, op, fvp) = sst[ns].pop()
110+
if fvp:
111+
# TODO: Once these flag entries have been removed from the DB,
112+
# we can remove this check
113+
if key in ["PortConfigDone", "PortInitDone"]:
114+
continue
99115

100-
fvp_dict = dict(fvp)
116+
fvp_dict = dict(fvp)
101117

102-
if op == "SET" and "oper_status" in fvp_dict:
103-
led_control.port_link_state_change(key, fvp_dict["oper_status"])
118+
if op == "SET" and "oper_status" in fvp_dict:
119+
if not key.startswith(backplane_prefix()):
120+
led_control.port_link_state_change(key, fvp_dict["oper_status"])
104121

105122
return 1
106123

0 commit comments

Comments
 (0)