Skip to content

Commit

Permalink
Retrieve DOM info using platform API 2.0 if implemented (sonic-net#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
InventecJamesHuang committed Mar 8, 2020
1 parent e198189 commit de33b65
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ showtag:
init :
@git submodule update --init --recursive
@git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git'
@sh inv_build/apply_patch.sh

.ONESHELL : reset
reset :
Expand Down
89 changes: 89 additions & 0 deletions inv_build/apply_patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
#!/bin/bash
## This script is to apply inventec own patch to SONiC

BASE_PATH=$(pwd)
INV_PATCH_DIR=$BASE_PATH/inv_build/patch_files

if [ ! -d ${INV_PATCH_DIR}/* ]; then
exit 0
fi

# Find each submodule need to patch
echo "[INFO] start to apply patch in different module"
for entry in $INV_PATCH_DIR/*
do
if [ ! -d $entry ]; then
continue
fi

SUB_MODULE="$(basename $entry)"

if [ "$SUB_MODULE" = "README" ]; then
continue
elif [ "$SUB_MODULE" = "sonic-buildimage" ]; then
echo
echo "=== apply patch to $SUB_MODULE ==="
seriesfile="${INV_PATCH_DIR}/${SUB_MODULE}/series"
exec < ${seriesfile}

while read line
do
content=$(echo $line | awk /#/'{print $1}')
if [ "$content" = "#" ]; then
continue
fi
content=$(echo $line | awk /CodeBase/'{print $1}')
if [ "$content" = "[CodeBase]" ]; then
content=$(echo $line | awk '{print $NF}')
continue
fi
content=$(echo $line | awk /order/'{print $1}')
if [ "$content" = "[order]" ]; then
continue
fi
git am --whitespace=nowarn ${INV_PATCH_DIR}/${SUB_MODULE}/$line
echo $line
done
echo
else
cd src/$SUB_MODULE
echo "=== apply patch to ${SUB_MODULE} ==="
CURRENT_HEAD="$(git rev-parse HEAD)"
seriesfile="${INV_PATCH_DIR}/${SUB_MODULE}/series"
exec < ${seriesfile}
while read line
do
content=$(echo $line | awk /#/'{print $1}')
if [ "$content" = "#" ]; then
continue
fi
content=$(echo $line | awk /CodeBase/'{print $1}')
if [ "$content" = "[CodeBase]" ]; then
TARGET_VERSION=$(echo $line | awk '{print $NF}')
if [ "$CURRENT_HEAD" != "$TARGET_VERSION" ]; then
echo "error --> $SUB_MODULE:Target version $TARGET_VERSION not match current $CURRENT_HEAD"
break
fi
continue
fi
content=$(echo $line | awk /order/'{print $1}')
if [ "$content" = "[order]" ]; then
continue
fi
git am --whitespace=nowarn ${INV_PATCH_DIR}/${SUB_MODULE}/$line
done
echo
fi
cd $BASE_PATH
echo "already executed make init and patched files" > ${INV_PATCH_DIR}/already_patched
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
From 8fcfd356b0bbfd81329e4b7a0aea5d6196cc4349 Mon Sep 17 00:00:00 2001
From: James Huang <huang.james@inventec.com>
Date: Fri, 6 Mar 2020 15:27:00 +0800
Subject: [PATCH] [xcvrd] Retrieve DOM info using platform API 2.0 if
implemented #48

---
sonic-xcvrd/scripts/xcvrd | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sonic-xcvrd/scripts/xcvrd b/sonic-xcvrd/scripts/xcvrd
index c491375..0347c65 100644
--- a/sonic-xcvrd/scripts/xcvrd
+++ b/sonic-xcvrd/scripts/xcvrd
@@ -143,8 +143,10 @@ def _wrapper_get_transceiver_dom_info(physical_port):

def _wrapper_get_transceiver_dom_threshold_info(physical_port):
if platform_chassis is not None:
- return None
-
+ try:
+ return platform_chassis.get_sfp(physical_port).get_transceiver_threshold_info()
+ except NotImplementedError:
+ pass
return platform_sfputil.get_transceiver_dom_threshold_info_dict(physical_port)

def _wrapper_get_transceiver_change_event(timeout):
--
2.7.4

4 changes: 4 additions & 0 deletions inv_build/patch_files/sonic-platform-daemons/series
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This series applies to sonic-platform-daemons GIT commit
[CodeBase] a34ba131f618a8df6beec1f548aa08f9cedc48db
[order]
[sonic-platform-daemons]xcvrd-retrieve-DOM-info-using-platform-API.patch

0 comments on commit de33b65

Please sign in to comment.