forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 6
/
config_sonic_otn_linecard.sh
executable file
·51 lines (36 loc) · 1.77 KB
/
config_sonic_otn_linecard.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/bin/bash
#./config_sonic_otn_linecard.sh 1 e110c
#./config_sonic_otn_linecard.sh 1 none
SLOT_ID=$1
LINECARD_TYPE=$2
TERMINAL_MODE=$3
LINECARD_TYPE_UPPERCASE=${LINECARD_TYPE^^}
ASIC_ID=$((SLOT_ID-1))
echo $SLOT_ID $LINECARD_TYPE $LINECARD_TYPE_UPPERCASE $TERMINAL_MODE $ASIC_ID
PLATFORM=${PLATFORM:-`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform`}
if [ $LINECARD_TYPE_UPPERCASE == NONE ]; then
echo "linecard type is none"
sudo systemctl stop otss@$ASIC_ID.service
sudo systemctl stop syncd-ot@$ASIC_ID.service
echo "flush all linedard $SLOT_ID in database"
sonic-db-cli -n asic$ASIC_ID STATE_DB flushall
sonic-db-cli -n asic$ASIC_ID CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
sudo rm /etc/sonic/config_db$ASIC_ID.json
sudo systemctl start syncd-ot@$ASIC_ID.service
sudo systemctl start otss@$ASIC_ID.service
else
echo "linecard type is $LINECARD_TYPE"
sudo cp -r /usr/share/sonic/device/$PLATFORM/linecards /etc/sonic
sudo sh -c "SLOT_ID=$SLOT_ID ASIC_ID=$ASIC_ID j2 /etc/sonic/linecards/$LINECARD_TYPE/config_db.json.j2 > /etc/sonic/config_db$ASIC_ID.json"
sudo systemctl stop otss@$ASIC_ID.service
sudo systemctl stop syncd-ot@$ASIC_ID.service
sudo /usr/local/bin/sonic-cfggen -j /etc/sonic/config_db$ASIC_ID.json -n asic$ASIC_ID --write-to-db
sudo systemctl start syncd-ot@$ASIC_ID.service
sudo systemctl start otss@$ASIC_ID.service
sleep 5
echo "plugin the linecard $SLOT_ID and power enabled..."
sonic-db-cli -n asic$ASIC_ID STATE_DB hset "LINECARD|LINECARD-1-$SLOT_ID" "power-admin-state" "POWER_ENABLED" "empty" "false" "linecard-type" "$LINECARD_TYPE_UPPERCASE"
sleep 5
echo "linecard otai library communication link status is up..."
docker exec syncd-ot$ASIC_ID touch /tmp/linkup
fi