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

[rc.local]: Add chassis serial number to DEVICE_METADATA table. #1235

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions files/image_config/platform/rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ if [ -f /host/image-$sonic_version/platform/firsttime ]; then
# setup initial switch mac
SONIC_ASIC_TYPE=$(sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
CHASSIS_SERIAL_NUMBER=$(decode-syseeprom -s)

# Align last byte of MAC if necessary
if [ "$SONIC_ASIC_TYPE" = "mellanox" ] || [ "$SONIC_ASIC_TYPE" = "centec" ]; then
Expand All @@ -91,10 +92,10 @@ if [ -f /host/image-$sonic_version/platform/firsttime ]; then
fi

if [ -f /etc/sonic/init_cfg.json ]; then
sonic-cfggen -j /etc/sonic/init_cfg.json -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /tmp/init_cfg.json
sonic-cfggen -j /etc/sonic/init_cfg.json -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'", "chassis_serial_number": "'$CHASSIS_SERIAL_NUMBER'"}}}' --print-data > /tmp/init_cfg.json
mv /tmp/init_cfg.json /etc/sonic/init_cfg.json
else
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'"}}}' --print-data > /etc/sonic/init_cfg.json
sonic-cfggen -a '{"DEVICE_METADATA":{"localhost": {"mac": "'$SYSTEM_MAC_ADDRESS'", "chassis_serial_number": "'$CHASSIS_SERIAL_NUMBER'"}}}' --print-data > /etc/sonic/init_cfg.json
fi

# Try to take old configuration saved during installation
Expand Down