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

[sonic-platform-daemons] Add more physical entity information to DB for physical entity mib #13

Closed
wants to merge 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4097a18
platform daemon changes for multi asic platform
judyjoseph Jul 9, 2020
3d3c9ed
Updates to initial commit
judyjoseph Jul 10, 2020
81dddf1
Updates for review comments.
judyjoseph Jul 14, 2020
0e70e2f
Updates in ledd daemon to get the namespace from selector object.
judyjoseph Jul 21, 2020
332dfff
Updated based on sonic-py-common
judyjoseph Aug 9, 2020
37cec19
Invoke initializeGlobalConfig() in the SfpUpdate/DomInfoUpdate proces…
judyjoseph Aug 14, 2020
9323fa0
Fixes in xcvrd.
judyjoseph Aug 19, 2020
17572de
Use common API's to get asic index and get namespaces with front-pane…
judyjoseph Aug 21, 2020
710689f
Fix the space in initialization.
judyjoseph Aug 24, 2020
e9628b6
Merge pull request #64 from judyjoseph/multi_asic_ledd_xcvr
judyjoseph Aug 25, 2020
fb86bc2
Update pmon daemons for SONiC Physical Entity MIB feature
Junchao-Mellanox Aug 26, 2020
068d09b
Fix unit test failures
Junchao-Mellanox Aug 28, 2020
e057e35
Fix issues found in manual test
Junchao-Mellanox Aug 31, 2020
1d77bc9
remove sonic-utilities dependency from pcied (#88)
sujinmkang Sep 3, 2020
e4ee852
[ledd][multi-ASIC] Update to ledd based on sonic-swss-common updates …
judyjoseph Sep 3, 2020
1893c40
Fix the xcvrd theowing error on sfprecover function
abdosi Sep 8, 2020
65fa443
Merge pull request #90 from abdosi/multiasic-fix
abdosi Sep 8, 2020
ca414df
Put PSU thermal to PHYSICAL_ENTITY_INFO table
Junchao-Mellanox Sep 9, 2020
7f812c9
[xcvrd] Don't log unnecessary messages upon empty transceiver change …
chiourung Sep 9, 2020
0969202
Fix pcied daemon failure (#91)
bratashX Sep 9, 2020
a6c0071
[thermalctld] Fix issue: fan status should not be True when fan is ab…
Junchao-Mellanox Sep 15, 2020
e1842b2
Change STATE_DB key (PCIE_STATUS|PCIE_DEVICES -> PCIE_DEVICES) (#93)
bratashX Sep 15, 2020
4fdf975
[thermalctld] Fix issue: thermalctld should be auto restarted when be…
Junchao-Mellanox Sep 18, 2020
1aaffcc
Add 'wheel' package to 'setup_requires' list (#95)
jleveque Sep 22, 2020
8507085
[psud] Fix psud logging (#98)
vboykox Oct 5, 2020
a11bf5c
Merge branch 'master' into phy-mibs
Junchao-Mellanox Oct 16, 2020
8ae63a7
Fix LGTM warning
Junchao-Mellanox Oct 16, 2020
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
48 changes: 34 additions & 14 deletions sonic-ledd/scripts/ledd
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ try:
import sys

from sonic_py_common import daemon_base
from sonic_py_common import multi_asic
from sonic_py_common.interface import backplane_prefix
from swsscommon import swsscommon
except ImportError as e:
raise ImportError (str(e) + " - required module not found")
Expand All @@ -35,6 +37,9 @@ SELECT_TIMEOUT = 1000

LEDUTIL_LOAD_ERROR = 1

# The empty namespace refers to linux host namespace.
EMPTY_NAMESPACE = ''

class DaemonLedd(daemon_base.DaemonBase):

# Run daemon
Expand Down Expand Up @@ -65,19 +70,28 @@ class DaemonLedd(daemon_base.DaemonBase):
self.log_error("Failed to load ledutil: %s" % (str(e)), True)
sys.exit(LEDUTIL_LOAD_ERROR)

# Open a handle to the Application database
appl_db = daemon_base.db_connect("APPL_DB")
# Load the namespace details first from the database_global.json file.
swsscommon.SonicDBConfig.initializeGlobalConfig()

# Get the namespaces in the platform. For multi-asic devices we get the namespaces
# of front-end ascis which have front-panel interfaces.
namespaces = multi_asic.get_front_end_namespaces()

# Subscribe to PORT table notifications in the Application DB
appl_db, sst = {}, {}
sel = swsscommon.Select()
sst = swsscommon.SubscriberStateTable(appl_db, swsscommon.APP_PORT_TABLE_NAME)
sel.addSelectable(sst)

# Listen indefinitely for changes to the PORT table in the Application DB
for namespace in namespaces:
# Open a handle to the Application database, in all namespaces
appl_db[namespace] = daemon_base.db_connect("APPL_DB", namespace=namespace)
sst[namespace] = swsscommon.SubscriberStateTable(appl_db[namespace], swsscommon.APP_PORT_TABLE_NAME)
sel.addSelectable(sst[namespace])

# Listen indefinitely for changes to the PORT table in the Application DB's
while True:
# Use timeout to prevent ignoring the signals we want to handle
# in signal_handler() (e.g. SIGTERM for graceful shutdown)
(state, c) = sel.select(SELECT_TIMEOUT)
(state, selectableObj) = sel.select(SELECT_TIMEOUT)

if state == swsscommon.Select.TIMEOUT:
# Do not flood log when select times out
Expand All @@ -86,17 +100,23 @@ class DaemonLedd(daemon_base.DaemonBase):
self.log_warning("sel.select() did not return swsscommon.Select.OBJECT")
continue

(key, op, fvp) = sst.pop()
# Get the redisselect object from selectable object
redisSelectObj = swsscommon.CastSelectableToRedisSelectObj(selectableObj)
# Get the corresponding namespace from redisselect db connector object
namespace = redisSelectObj.getDbConnector().getNamespace()

# TODO: Once these flag entries have been removed from the DB,
# we can remove this check
if key in ["PortConfigDone", "PortInitDone"]:
continue
(key, op, fvp) = sst[namespace].pop()
if fvp:
# TODO: Once these flag entries have been removed from the DB,
# we can remove this check
if key in ["PortConfigDone", "PortInitDone"]:
continue

fvp_dict = dict(fvp)
fvp_dict = dict(fvp)

if op == "SET" and "oper_status" in fvp_dict:
led_control.port_link_state_change(key, fvp_dict["oper_status"])
if op == "SET" and "oper_status" in fvp_dict:
if not key.startswith(backplane_prefix()):
led_control.port_link_state_change(key, fvp_dict["oper_status"])

return 1

Expand Down
3 changes: 3 additions & 0 deletions sonic-ledd/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
scripts=[
'scripts/ledd',
],
setup_requires= [
'wheel'
],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: No Input/Output (Daemon)',
Expand Down
42 changes: 29 additions & 13 deletions sonic-pcied/scripts/pcied
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,36 @@ class DaemonPcied(DaemonBase):
self.state_db = swsssdk.SonicV2Connector(host=REDIS_HOSTIP)
self.state_db.connect("STATE_DB")

# Check the PCIe devices
def check_pcie_devices(self):
cmd = [ 'sudo', 'pcieutil', 'pcie-check' ]
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
resultInfo, err = p.communicate()
pcie_db_state = self.read_state_db("PCIE_STATUS|", "PCIE_DEVICES")

for line in resultInfo.splitlines():
if PCIE_RESULT_REGEX in line:
if "PASSED" in line and "PASSED" not in pcie_db_state:
self.update_state_db("PCIE_STATUS|", "PCIE_DEVICES", "PASSED")
self.log_info("PCIe device status check : PASSED")
elif "FAILED" in line and "PASSED" in pcie_db_state:
self.update_state_db("PCIE_STATUS|", "PCIE_DEVICES", "FAILED")
self.log_info("PCIe device status check : FAILED")
try:
platform_path, _ = device_info.get_paths_to_platform_and_hwsku_dirs()
platform_plugins_path = os.path.join(platform_path, "plugins")
sys.path.append(os.path.abspath(platform_plugins_path))
from pcieutil import PcieUtil
except ImportError as e:
self.log_warning("Failed to load platform-specific PcieUtil module. Falling back to the common implementation")
try:
from sonic_platform_base.sonic_pcie.pcie_common import PcieUtil
platform_pcieutil = PcieUtil(platform_plugins_path)
except ImportError as e:
self.log_error("Failed to load default PcieUtil module. Error : {}".format(str(e)), True)
raise e

resultInfo = platform_pcieutil.get_pcie_check()
err = 0

for item in resultInfo:
if item["result"] == "Failed":
self.log_warning("PCIe Device: " + item["name"] + " Not Found")
err += 1

if err:
self.update_state_db("PCIE_DEVICES", "status", "FAILED")
self.log_error("PCIe device status check : FAILED")
else:
self.update_state_db("PCIE_DEVICES", "status", "PASSED")
self.log_info("PCIe device status check : PASSED")

def read_state_db(self, key1, key2):
return self.state_db.get('STATE_DB', key1, key2)
Expand Down
3 changes: 3 additions & 0 deletions sonic-pcied/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
scripts=[
'scripts/pcied',
],
setup_requires= [
'wheel'
],
classifiers=[
'Development Status :: 4 - Beta',
'Environment :: No Input/Output (Daemon)',
Expand Down
Loading