3cd536bb45
Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan arlakshm@microsoft.com - Why I did it This PR has the changes to support having different swss.rec and sairedis.rec for each asic. The logrotate script is updated as well - How I did it Update the orchagent.sh script to use the logfile name options in these PRs(Azure/sonic-swss#1546 and Azure/sonic-sairedis#747) In multi asic platforms the record files will be different for each asic, with the format swss.asic{x}.rec and sairedis.asic{x}.rec Update the logrotate script for multiasic platform .
75 lines
2.6 KiB
Bash
Executable File
75 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
EXIT_SWSS_VARS_FILE_NOT_FOUND=1
|
|
SWSS_VARS_FILE=/usr/share/sonic/templates/swss_vars.j2
|
|
|
|
if [ ! -f "$SWSS_VARS_FILE" ]; then
|
|
echo "SWSS vars template file not found"
|
|
exit $EXIT_SWSS_VARS_FILE_NOT_FOUND
|
|
fi
|
|
|
|
# Retrieve SWSS vars from sonic-cfggen
|
|
SWSS_VARS=$(sonic-cfggen -d -y /etc/sonic/sonic_version.yml -t $SWSS_VARS_FILE)
|
|
export platform=$(echo $SWSS_VARS | jq -r '.asic_type')
|
|
|
|
MAC_ADDRESS=$(echo $SWSS_VARS | jq -r '.mac')
|
|
if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then
|
|
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
|
|
logger "Mac address not found in Device Metadata, Falling back to eth0"
|
|
fi
|
|
|
|
# Create a folder for SwSS record files
|
|
mkdir -p /var/log/swss
|
|
ORCHAGENT_ARGS="-d /var/log/swss "
|
|
|
|
# Set orchagent pop batch size to 8192
|
|
ORCHAGENT_ARGS+="-b 8192 "
|
|
|
|
# Check if there is an "asic_id field" in the DEVICE_METADATA in configDB.
|
|
#"DEVICE_METADATA": {
|
|
# "localhost": {
|
|
# ....
|
|
# "asic_id": "0",
|
|
# }
|
|
#},
|
|
# ID field could be integers just to denote the asic instance like 0,1,2...
|
|
# OR could be PCI device ID's which will be strings like "03:00.0"
|
|
# depending on what the SAI/SDK expects.
|
|
asic_id=$(echo $SWSS_VARS | jq -r '.asic_id')
|
|
if [ -n "$asic_id" ]
|
|
then
|
|
ORCHAGENT_ARGS+="-i $asic_id "
|
|
fi
|
|
|
|
# for multi asic platforms add the asic name to the record file names
|
|
if [[ "$NAMESPACE_ID" ]]; then
|
|
ORCHAGENT_ARGS+="-f swss.asic$NAMESPACE_ID.rec -j sairedis.asic$NAMESPACE_ID.rec "
|
|
fi
|
|
|
|
# Add platform specific arguments if necessary
|
|
if [ "$platform" == "broadcom" ]; then
|
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
|
elif [ "$platform" == "cavium" ]; then
|
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
|
elif [ "$platform" == "nephos" ]; then
|
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
|
elif [ "$platform" == "centec" ]; then
|
|
last_byte=$(python -c "print '$MAC_ADDRESS'[-2:]")
|
|
aligned_last_byte=$(python -c "print format(int(int('$last_byte', 16) + 1), '02x')") # put mask and take away the 0x prefix
|
|
ALIGNED_MAC_ADDRESS=$(python -c "print '$MAC_ADDRESS'[:-2] + '$aligned_last_byte'") # put aligned byte into the end of MAC
|
|
ORCHAGENT_ARGS+="-m $ALIGNED_MAC_ADDRESS"
|
|
elif [ "$platform" == "barefoot" ]; then
|
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
|
elif [ "$platform" == "vs" ]; then
|
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
|
elif [ "$platform" == "mellanox" ]; then
|
|
ORCHAGENT_ARGS+=""
|
|
elif [ "$platform" == "innovium" ]; then
|
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
|
else
|
|
# Should we use the fallback MAC in case it is not found in Device.Metadata
|
|
ORCHAGENT_ARGS+="-m $MAC_ADDRESS"
|
|
fi
|
|
|
|
exec /usr/bin/orchagent ${ORCHAGENT_ARGS}
|