Skip to content

Commit de33b65

Browse files
Retrieve DOM info using platform API 2.0 if implemented (sonic-net#48)
1 parent e198189 commit de33b65

File tree

4 files changed

+124
-0
lines changed

4 files changed

+124
-0
lines changed

Makefile.work

+1
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ showtag:
229229
init :
230230
@git submodule update --init --recursive
231231
@git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git'
232+
@sh inv_build/apply_patch.sh
232233

233234
.ONESHELL : reset
234235
reset :

inv_build/apply_patch.sh

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
## This script is to apply inventec own patch to SONiC
3+
4+
BASE_PATH=$(pwd)
5+
INV_PATCH_DIR=$BASE_PATH/inv_build/patch_files
6+
7+
if [ ! -d ${INV_PATCH_DIR}/* ]; then
8+
exit 0
9+
fi
10+
11+
# Find each submodule need to patch
12+
echo "[INFO] start to apply patch in different module"
13+
for entry in $INV_PATCH_DIR/*
14+
do
15+
if [ ! -d $entry ]; then
16+
continue
17+
fi
18+
19+
SUB_MODULE="$(basename $entry)"
20+
21+
if [ "$SUB_MODULE" = "README" ]; then
22+
continue
23+
elif [ "$SUB_MODULE" = "sonic-buildimage" ]; then
24+
echo
25+
echo "=== apply patch to $SUB_MODULE ==="
26+
seriesfile="${INV_PATCH_DIR}/${SUB_MODULE}/series"
27+
exec < ${seriesfile}
28+
29+
while read line
30+
do
31+
content=$(echo $line | awk /#/'{print $1}')
32+
if [ "$content" = "#" ]; then
33+
continue
34+
fi
35+
36+
content=$(echo $line | awk /CodeBase/'{print $1}')
37+
if [ "$content" = "[CodeBase]" ]; then
38+
content=$(echo $line | awk '{print $NF}')
39+
continue
40+
fi
41+
42+
content=$(echo $line | awk /order/'{print $1}')
43+
if [ "$content" = "[order]" ]; then
44+
continue
45+
fi
46+
47+
git am --whitespace=nowarn ${INV_PATCH_DIR}/${SUB_MODULE}/$line
48+
echo $line
49+
50+
done
51+
echo
52+
else
53+
cd src/$SUB_MODULE
54+
echo "=== apply patch to ${SUB_MODULE} ==="
55+
CURRENT_HEAD="$(git rev-parse HEAD)"
56+
seriesfile="${INV_PATCH_DIR}/${SUB_MODULE}/series"
57+
exec < ${seriesfile}
58+
59+
while read line
60+
do
61+
content=$(echo $line | awk /#/'{print $1}')
62+
if [ "$content" = "#" ]; then
63+
continue
64+
fi
65+
66+
content=$(echo $line | awk /CodeBase/'{print $1}')
67+
if [ "$content" = "[CodeBase]" ]; then
68+
TARGET_VERSION=$(echo $line | awk '{print $NF}')
69+
if [ "$CURRENT_HEAD" != "$TARGET_VERSION" ]; then
70+
echo "error --> $SUB_MODULE:Target version $TARGET_VERSION not match current $CURRENT_HEAD"
71+
break
72+
fi
73+
continue
74+
fi
75+
76+
content=$(echo $line | awk /order/'{print $1}')
77+
if [ "$content" = "[order]" ]; then
78+
continue
79+
fi
80+
81+
git am --whitespace=nowarn ${INV_PATCH_DIR}/${SUB_MODULE}/$line
82+
83+
done
84+
echo
85+
fi
86+
87+
cd $BASE_PATH
88+
echo "already executed make init and patched files" > ${INV_PATCH_DIR}/already_patched
89+
done
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From 8fcfd356b0bbfd81329e4b7a0aea5d6196cc4349 Mon Sep 17 00:00:00 2001
2+
From: James Huang <[email protected]>
3+
Date: Fri, 6 Mar 2020 15:27:00 +0800
4+
Subject: [PATCH] [xcvrd] Retrieve DOM info using platform API 2.0 if
5+
implemented #48
6+
7+
---
8+
sonic-xcvrd/scripts/xcvrd | 6 ++++--
9+
1 file changed, 4 insertions(+), 2 deletions(-)
10+
11+
diff --git a/sonic-xcvrd/scripts/xcvrd b/sonic-xcvrd/scripts/xcvrd
12+
index c491375..0347c65 100644
13+
--- a/sonic-xcvrd/scripts/xcvrd
14+
+++ b/sonic-xcvrd/scripts/xcvrd
15+
@@ -143,8 +143,10 @@ def _wrapper_get_transceiver_dom_info(physical_port):
16+
17+
def _wrapper_get_transceiver_dom_threshold_info(physical_port):
18+
if platform_chassis is not None:
19+
- return None
20+
-
21+
+ try:
22+
+ return platform_chassis.get_sfp(physical_port).get_transceiver_threshold_info()
23+
+ except NotImplementedError:
24+
+ pass
25+
return platform_sfputil.get_transceiver_dom_threshold_info_dict(physical_port)
26+
27+
def _wrapper_get_transceiver_change_event(timeout):
28+
--
29+
2.7.4
30+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This series applies to sonic-platform-daemons GIT commit
2+
[CodeBase] a34ba131f618a8df6beec1f548aa08f9cedc48db
3+
[order]
4+
[sonic-platform-daemons]xcvrd-retrieve-DOM-info-using-platform-API.patch

0 commit comments

Comments
 (0)