Skip to content

Commit 64e04f8

Browse files
Bluevelguohanyxieca
authored andcommitted
[conf] append nos-config-part for s6100 (#5234)
* [conf] append nos-config-part for s6100 * modify rc.local Signed-off-by: Guohan Lu <[email protected]> * Update rc.local Co-authored-by: Blueve <[email protected]> Co-authored-by: Guohan Lu <[email protected]> Co-authored-by: Ying Xie <[email protected]>
1 parent c0b47ad commit 64e04f8

File tree

2 files changed

+69
-57
lines changed

2 files changed

+69
-57
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
CONSOLE_PORT=0x2f8
22
CONSOLE_DEV=1
3-
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich"
3+
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="module_blacklist=gpio_ich nos-config-part=/dev/sda12"

files/image_config/platform/rc.local

Lines changed: 68 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ update_mgmt_interface_macaddr() {
5353
fi
5454

5555
# Get the ethtool magic and offset for changing the mac address in the EEPROM
56-
ethtool_magic=$(grep "ethtool_magic" $mgmt_config | awk -F'=' '{print $2}')
57-
ethtool_offset=$(grep "ethtool_offset" $mgmt_config | awk -F'=' '{print $2}')
56+
ethtool_magic=$(grep "ethtool_magic" $mgmt_config | awk -F'=' '{print $2}')
57+
ethtool_offset=$(grep "ethtool_offset" $mgmt_config | awk -F'=' '{print $2}')
5858
if [ -z "$ethtool_magic" ] || [ -z "$ethtool_offset" ]; then
5959
log_migration "Unable to retrieve ethtool params ($ethtool_magic,$ethtool_offset)"
6060
return
@@ -84,6 +84,69 @@ update_mgmt_interface_macaddr() {
8484
ethtool -e eth0 offset $ethtool_offset length 6 >> /host/migration/migration.log
8585
}
8686

87+
migrate_nos_configuration()
88+
{
89+
rm -rf /host/migration
90+
mkdir -p /host/migration
91+
92+
# Extract the previous NOS's partition that contains the migration artifacts
93+
set -- $(cat /proc/cmdline)
94+
for x in "$@"; do
95+
case "$x" in
96+
nos-config-part=*)
97+
nos_dev="${x#nos-config-part=}"
98+
;;
99+
SONIC_BOOT_TYPE=fast*)
100+
sonic_fast_reboot=true
101+
;;
102+
esac
103+
done
104+
105+
if [ -n "$nos_dev" ]; then
106+
# remove nos-config-part from cmdline
107+
sed -r -i.bak "s/nos-config-part=[^[:space:]]+//" /host/grub/grub.cfg
108+
109+
# Mount the previous NOS's partition
110+
NOS_DIR=/mnt/nos_migration
111+
MG_GZFILE=$NOS_DIR/minigraph.xml.gz.base64.txt
112+
MG_FILE=$NOS_DIR/minigraph.xml
113+
ACL_GZFILE=$NOS_DIR/acl.json.gz.base64.txt
114+
ACL_FILE=$NOS_DIR/acl.json
115+
SNMP_FILE=$NOS_DIR/snmp.yml
116+
mkdir -p $NOS_DIR
117+
118+
mount $nos_dev $NOS_DIR
119+
if [ $? != 0 ]; then
120+
log_migration "ERROR: cannot mount $nos_dev"
121+
else
122+
123+
# decode & unzip minigraph.xml.gz.base64.txt
124+
[ -f $MG_GZFILE ] && /usr/bin/base64 -d $MG_GZFILE | /bin/gunzip > $MG_FILE
125+
[ -f $ACL_GZFILE ] && /usr/bin/base64 -d $ACL_GZFILE | /bin/gunzip > $ACL_FILE
126+
127+
# Copy relevant files
128+
nos_migration_import $NOS_DIR/mgmt_interface.cfg /host/migration
129+
nos_migration_import $MG_FILE /host/migration
130+
nos_migration_import $ACL_FILE /host/migration
131+
nos_migration_import $SNMP_FILE /host/migration
132+
133+
if [ "$sonic_fast_reboot" == true ]; then
134+
mkdir -p /host/fast-reboot
135+
nos_migration_import $NOS_DIR/arp.json /host/fast-reboot
136+
nos_migration_import $NOS_DIR/fdb.json /host/fast-reboot
137+
nos_migration_import $NOS_DIR/default_routes.json /host/fast-reboot
138+
fi
139+
140+
umount $NOS_DIR
141+
rmdir $NOS_DIR
142+
fi
143+
144+
[ -f /host/migration/mgmt_interface.cfg ] && update_mgmt_interface_macaddr /host/migration/mgmt_interface.cfg
145+
146+
migration="TRUE"
147+
fi
148+
}
149+
87150
firsttime_exit() {
88151
rm -rf $FIRST_BOOT_FILE
89152
exit 0
@@ -122,13 +185,11 @@ logger "SONiC version ${SONIC_VERSION} starting up..."
122185
# If the machine.conf is absent, it indicates that the unit booted
123186
# into SONiC from another NOS. Extract the machine.conf from ONIE.
124187
if [ ! -e /host/machine.conf ]; then
125-
mkdir -p /host/migration
126-
127188
onie_dev=$(blkid | grep ONIE-BOOT | head -n 1 | awk '{print $1}' | sed -e 's/:.*$//')
128189
mkdir -p /mnt/onie-boot
129190
mount $onie_dev /mnt/onie-boot
130191
onie_grub_cfg=/mnt/onie-boot/onie/grub/grub-machine.cfg
131-
192+
132193
if [ ! -e $onie_grub_cfg ]; then
133194
log_migration "$onie_grub_cfg not found"
134195
else
@@ -139,60 +200,11 @@ if [ ! -e /host/machine.conf ]; then
139200
done
140201
fi
141202

142-
# Extract the previous NOS's partition that contains the migration artifacts
143-
set -- $(cat /proc/cmdline)
144-
for x in "$@"; do
145-
case "$x" in
146-
nos-config-part=*)
147-
nos_val="${x#nos-config-part=}"
148-
;;
149-
esac
150-
done
151-
152-
if [ -n "$nos_val" ]; then
153-
nos_dev=$(findfs $nos_val)
154-
if [ $? != 0 ]; then
155-
log_migration "ERROR: nos_dev not found. Check grub parameters"
156-
fi
157-
else
158-
log_migration "ERROR: nos_val not found. Check grub parameters"
159-
fi
160-
161-
if [ -n "$nos_dev" ]; then
162-
# Mount the previous NOS's partition
163-
NOS_DIR=/mnt/nos_migration
164-
MG_GZFILE=$NOS_DIR/minigraph.xml.gz.base64.txt
165-
MG_FILE=$NOS_DIR/minigraph.xml
166-
ACL_GZFILE=$NOS_DIR/acl.json.gz.base64.txt
167-
ACL_FILE=$NOS_DIR/acl.json
168-
SNMP_FILE=$NOS_DIR/snmp.yml
169-
mkdir -p $NOS_DIR
170-
mount $nos_dev $NOS_DIR
171-
mkdir -p /host/fast-reboot
172-
173-
# decode & unzip minigraph.xml.gz.base64.txt
174-
[ -f $MG_GZFILE ] && /usr/bin/base64 -d $MG_GZFILE | /bin/gunzip > $MG_FILE
175-
[ -f $ACL_GZFILE ] && /usr/bin/base64 -d $ACL_GZFILE | /bin/gunzip > $ACL_FILE
176-
177-
# Copy relevant files
178-
nos_migration_import $NOS_DIR/mgmt_interface.cfg /host/migration
179-
nos_migration_import $MG_FILE /host/migration
180-
nos_migration_import $ACL_FILE /host/migration
181-
nos_migration_import $SNMP_FILE /host/migration
182-
nos_migration_import $NOS_DIR/arp.json /host/fast-reboot
183-
nos_migration_import $NOS_DIR/fdb.json /host/fast-reboot
184-
nos_migration_import $NOS_DIR/default_routes.json /host/fast-reboot
185-
186-
umount $NOS_DIR
187-
rmdir $NOS_DIR
188-
fi
189-
190-
update_mgmt_interface_macaddr /host/migration/mgmt_interface.cfg
191-
192-
migration="TRUE"
193203
umount /mnt/onie-boot
194204
fi
195205

206+
migrate_nos_configuration
207+
196208
. /host/machine.conf
197209

198210
program_console_speed

0 commit comments

Comments
 (0)