@@ -53,8 +53,8 @@ update_mgmt_interface_macaddr() {
53
53
fi
54
54
55
55
# 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}' )
58
58
if [ -z " $ethtool_magic " ] || [ -z " $ethtool_offset " ]; then
59
59
log_migration " Unable to retrieve ethtool params ($ethtool_magic ,$ethtool_offset )"
60
60
return
@@ -84,6 +84,69 @@ update_mgmt_interface_macaddr() {
84
84
ethtool -e eth0 offset $ethtool_offset length 6 >> /host/migration/migration.log
85
85
}
86
86
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
+
87
150
firsttime_exit () {
88
151
rm -rf $FIRST_BOOT_FILE
89
152
exit 0
@@ -122,13 +185,11 @@ logger "SONiC version ${SONIC_VERSION} starting up..."
122
185
# If the machine.conf is absent, it indicates that the unit booted
123
186
# into SONiC from another NOS. Extract the machine.conf from ONIE.
124
187
if [ ! -e /host/machine.conf ]; then
125
- mkdir -p /host/migration
126
-
127
188
onie_dev=$( blkid | grep ONIE-BOOT | head -n 1 | awk ' {print $1}' | sed -e ' s/:.*$//' )
128
189
mkdir -p /mnt/onie-boot
129
190
mount $onie_dev /mnt/onie-boot
130
191
onie_grub_cfg=/mnt/onie-boot/onie/grub/grub-machine.cfg
131
-
192
+
132
193
if [ ! -e $onie_grub_cfg ]; then
133
194
log_migration " $onie_grub_cfg not found"
134
195
else
@@ -139,60 +200,11 @@ if [ ! -e /host/machine.conf ]; then
139
200
done
140
201
fi
141
202
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"
193
203
umount /mnt/onie-boot
194
204
fi
195
205
206
+ migrate_nos_configuration
207
+
196
208
. /host/machine.conf
197
209
198
210
program_console_speed
0 commit comments