[conf] append nos-config-part for s6100 (#5234)
* [conf] append nos-config-part for s6100 * modify rc.local Signed-off-by: Guohan Lu <lguohan@gmail.com> * Update rc.local Co-authored-by: Blueve <jika@microsoft.com> Co-authored-by: Guohan Lu <lguohan@gmail.com> Co-authored-by: Ying Xie <yxieca@users.noreply.github.com>
This commit is contained in:
parent
0b6fd70767
commit
01fb32fa08
@ -1,3 +1,3 @@
|
|||||||
CONSOLE_PORT=0x2f8
|
CONSOLE_PORT=0x2f8
|
||||||
CONSOLE_DEV=1
|
CONSOLE_DEV=1
|
||||||
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich"
|
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich nos-config-part=/dev/sda12"
|
||||||
|
@ -61,8 +61,8 @@ update_mgmt_interface_macaddr() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the ethtool magic and offset for changing the mac address in the EEPROM
|
# Get the ethtool magic and offset for changing the mac address in the EEPROM
|
||||||
ethtool_magic=$(grep "ethtool_magic" $mgmt_config | awk -F'=' '{print $2}')
|
ethtool_magic=$(grep "ethtool_magic" $mgmt_config | awk -F'=' '{print $2}')
|
||||||
ethtool_offset=$(grep "ethtool_offset" $mgmt_config | awk -F'=' '{print $2}')
|
ethtool_offset=$(grep "ethtool_offset" $mgmt_config | awk -F'=' '{print $2}')
|
||||||
if [ -z "$ethtool_magic" ] || [ -z "$ethtool_offset" ]; then
|
if [ -z "$ethtool_magic" ] || [ -z "$ethtool_offset" ]; then
|
||||||
log_migration "Unable to retrieve ethtool params ($ethtool_magic,$ethtool_offset)"
|
log_migration "Unable to retrieve ethtool params ($ethtool_magic,$ethtool_offset)"
|
||||||
return
|
return
|
||||||
@ -92,6 +92,69 @@ update_mgmt_interface_macaddr() {
|
|||||||
ethtool -e eth0 offset $ethtool_offset length 6 >> /host/migration/migration.log
|
ethtool -e eth0 offset $ethtool_offset length 6 >> /host/migration/migration.log
|
||||||
}
|
}
|
||||||
|
|
||||||
|
migrate_nos_configuration()
|
||||||
|
{
|
||||||
|
rm -rf /host/migration
|
||||||
|
mkdir -p /host/migration
|
||||||
|
|
||||||
|
# Extract the previous NOS's partition that contains the migration artifacts
|
||||||
|
set -- $(cat /proc/cmdline)
|
||||||
|
for x in "$@"; do
|
||||||
|
case "$x" in
|
||||||
|
nos-config-part=*)
|
||||||
|
nos_dev="${x#nos-config-part=}"
|
||||||
|
;;
|
||||||
|
SONIC_BOOT_TYPE=fast*)
|
||||||
|
sonic_fast_reboot=true
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -n "$nos_dev" ]; then
|
||||||
|
# remove nos-config-part from cmdline
|
||||||
|
sed -r -i.bak "s/nos-config-part=[^[:space:]]+//" /host/grub/grub.cfg
|
||||||
|
|
||||||
|
# Mount the previous NOS's partition
|
||||||
|
NOS_DIR=/mnt/nos_migration
|
||||||
|
MG_GZFILE=$NOS_DIR/minigraph.xml.gz.base64.txt
|
||||||
|
MG_FILE=$NOS_DIR/minigraph.xml
|
||||||
|
ACL_GZFILE=$NOS_DIR/acl.json.gz.base64.txt
|
||||||
|
ACL_FILE=$NOS_DIR/acl.json
|
||||||
|
SNMP_FILE=$NOS_DIR/snmp.yml
|
||||||
|
mkdir -p $NOS_DIR
|
||||||
|
|
||||||
|
mount $nos_dev $NOS_DIR
|
||||||
|
if [ $? != 0 ]; then
|
||||||
|
log_migration "ERROR: cannot mount $nos_dev"
|
||||||
|
else
|
||||||
|
|
||||||
|
# decode & unzip minigraph.xml.gz.base64.txt
|
||||||
|
[ -f $MG_GZFILE ] && /usr/bin/base64 -d $MG_GZFILE | /bin/gunzip > $MG_FILE
|
||||||
|
[ -f $ACL_GZFILE ] && /usr/bin/base64 -d $ACL_GZFILE | /bin/gunzip > $ACL_FILE
|
||||||
|
|
||||||
|
# Copy relevant files
|
||||||
|
nos_migration_import $NOS_DIR/mgmt_interface.cfg /host/migration
|
||||||
|
nos_migration_import $MG_FILE /host/migration
|
||||||
|
nos_migration_import $ACL_FILE /host/migration
|
||||||
|
nos_migration_import $SNMP_FILE /host/migration
|
||||||
|
|
||||||
|
if [ "$sonic_fast_reboot" == true ]; then
|
||||||
|
mkdir -p /host/fast-reboot
|
||||||
|
nos_migration_import $NOS_DIR/arp.json /host/fast-reboot
|
||||||
|
nos_migration_import $NOS_DIR/fdb.json /host/fast-reboot
|
||||||
|
nos_migration_import $NOS_DIR/default_routes.json /host/fast-reboot
|
||||||
|
fi
|
||||||
|
|
||||||
|
umount $NOS_DIR
|
||||||
|
rmdir $NOS_DIR
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ -f /host/migration/mgmt_interface.cfg ] && update_mgmt_interface_macaddr /host/migration/mgmt_interface.cfg
|
||||||
|
|
||||||
|
migration="TRUE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
firsttime_exit() {
|
firsttime_exit() {
|
||||||
rm -rf $FIRST_BOOT_FILE
|
rm -rf $FIRST_BOOT_FILE
|
||||||
exit 0
|
exit 0
|
||||||
@ -137,13 +200,11 @@ logger "SONiC version ${SONIC_VERSION} starting up..."
|
|||||||
# If the machine.conf is absent, it indicates that the unit booted
|
# If the machine.conf is absent, it indicates that the unit booted
|
||||||
# into SONiC from another NOS. Extract the machine.conf from ONIE.
|
# into SONiC from another NOS. Extract the machine.conf from ONIE.
|
||||||
if [ ! -e /host/machine.conf ]; then
|
if [ ! -e /host/machine.conf ]; then
|
||||||
mkdir -p /host/migration
|
|
||||||
|
|
||||||
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
|
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
|
||||||
mkdir -p /mnt/onie-boot
|
mkdir -p /mnt/onie-boot
|
||||||
mount $onie_dev /mnt/onie-boot
|
mount $onie_dev /mnt/onie-boot
|
||||||
onie_grub_cfg=/mnt/onie-boot/onie/grub/grub-machine.cfg
|
onie_grub_cfg=/mnt/onie-boot/onie/grub/grub-machine.cfg
|
||||||
|
|
||||||
if [ ! -e $onie_grub_cfg ]; then
|
if [ ! -e $onie_grub_cfg ]; then
|
||||||
log_migration "$onie_grub_cfg not found"
|
log_migration "$onie_grub_cfg not found"
|
||||||
else
|
else
|
||||||
@ -154,60 +215,11 @@ if [ ! -e /host/machine.conf ]; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extract the previous NOS's partition that contains the migration artifacts
|
|
||||||
set -- $(cat /proc/cmdline)
|
|
||||||
for x in "$@"; do
|
|
||||||
case "$x" in
|
|
||||||
nos-config-part=*)
|
|
||||||
nos_val="${x#nos-config-part=}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ -n "$nos_val" ]; then
|
|
||||||
nos_dev=$(findfs $nos_val)
|
|
||||||
if [ $? != 0 ]; then
|
|
||||||
log_migration "ERROR: nos_dev not found. Check grub parameters"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
log_migration "ERROR: nos_val not found. Check grub parameters"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$nos_dev" ]; then
|
|
||||||
# Mount the previous NOS's partition
|
|
||||||
NOS_DIR=/mnt/nos_migration
|
|
||||||
MG_GZFILE=$NOS_DIR/minigraph.xml.gz.base64.txt
|
|
||||||
MG_FILE=$NOS_DIR/minigraph.xml
|
|
||||||
ACL_GZFILE=$NOS_DIR/acl.json.gz.base64.txt
|
|
||||||
ACL_FILE=$NOS_DIR/acl.json
|
|
||||||
SNMP_FILE=$NOS_DIR/snmp.yml
|
|
||||||
mkdir -p $NOS_DIR
|
|
||||||
mount $nos_dev $NOS_DIR
|
|
||||||
mkdir -p /host/fast-reboot
|
|
||||||
|
|
||||||
# decode & unzip minigraph.xml.gz.base64.txt
|
|
||||||
[ -f $MG_GZFILE ] && /usr/bin/base64 -d $MG_GZFILE | /bin/gunzip > $MG_FILE
|
|
||||||
[ -f $ACL_GZFILE ] && /usr/bin/base64 -d $ACL_GZFILE | /bin/gunzip > $ACL_FILE
|
|
||||||
|
|
||||||
# Copy relevant files
|
|
||||||
nos_migration_import $NOS_DIR/mgmt_interface.cfg /host/migration
|
|
||||||
nos_migration_import $MG_FILE /host/migration
|
|
||||||
nos_migration_import $ACL_FILE /host/migration
|
|
||||||
nos_migration_import $SNMP_FILE /host/migration
|
|
||||||
nos_migration_import $NOS_DIR/arp.json /host/fast-reboot
|
|
||||||
nos_migration_import $NOS_DIR/fdb.json /host/fast-reboot
|
|
||||||
nos_migration_import $NOS_DIR/default_routes.json /host/fast-reboot
|
|
||||||
|
|
||||||
umount $NOS_DIR
|
|
||||||
rmdir $NOS_DIR
|
|
||||||
fi
|
|
||||||
|
|
||||||
update_mgmt_interface_macaddr /host/migration/mgmt_interface.cfg
|
|
||||||
|
|
||||||
migration="TRUE"
|
|
||||||
umount /mnt/onie-boot
|
umount /mnt/onie-boot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
migrate_nos_configuration
|
||||||
|
|
||||||
. /host/machine.conf
|
. /host/machine.conf
|
||||||
|
|
||||||
program_console_speed
|
program_console_speed
|
||||||
|
Reference in New Issue
Block a user