[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:
Blueve 2020-09-09 03:29:02 +08:00 committed by GitHub
parent 0b6fd70767
commit 01fb32fa08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 57 deletions

View File

@ -1,3 +1,3 @@
CONSOLE_PORT=0x2f8
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"

View File

@ -61,8 +61,8 @@ update_mgmt_interface_macaddr() {
fi
# 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_offset=$(grep "ethtool_offset" $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}')
if [ -z "$ethtool_magic" ] || [ -z "$ethtool_offset" ]; then
log_migration "Unable to retrieve ethtool params ($ethtool_magic,$ethtool_offset)"
return
@ -92,6 +92,69 @@ update_mgmt_interface_macaddr() {
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() {
rm -rf $FIRST_BOOT_FILE
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
# into SONiC from another NOS. Extract the machine.conf from ONIE.
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/:.*$//')
mkdir -p /mnt/onie-boot
mount $onie_dev /mnt/onie-boot
onie_grub_cfg=/mnt/onie-boot/onie/grub/grub-machine.cfg
if [ ! -e $onie_grub_cfg ]; then
log_migration "$onie_grub_cfg not found"
else
@ -154,60 +215,11 @@ if [ ! -e /host/machine.conf ]; then
done
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
fi
migrate_nos_configuration
. /host/machine.conf
program_console_speed