File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ EXIT_FILE_SYSTEM_FULL=3
2424EXIT_NEXT_IMAGE_NOT_EXISTS=4
2525EXIT_ORCHAGENT_SHUTDOWN=10
2626EXIT_SYNCD_SHUTDOWN=11
27+ EXIT_FAST_REBOOT_DUMP_FAILURE=12
2728
2829function error()
2930{
@@ -251,6 +252,14 @@ function reboot_pre_check()
251252 fi
252253}
253254
255+ function unload_kernel()
256+ {
257+ # Unload the previously loaded kernel if any loaded
258+ if [[ " $( cat /sys/kernel/kexec_loaded) " -eq 1 ]]; then
259+ /sbin/kexec -u
260+ fi
261+ }
262+
254263# main starts here
255264parseOptions $@
256265
@@ -292,11 +301,7 @@ case "$REBOOT_TYPE" in
292301 ;;
293302esac
294303
295- # Unload the previously loaded kernel if any loaded
296- if [[ " $( cat /sys/kernel/kexec_loaded) " -eq 1 ]]
297- then
298- /sbin/kexec -u
299- fi
304+ unload_kernel
300305
301306setup_reboot_variables
302307
@@ -336,7 +341,13 @@ if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
336341 # Dump the ARP and FDB tables to files also as default routes for both IPv4 and IPv6
337342 # into /host/fast-reboot
338343 mkdir -p /host/fast-reboot
339- /usr/bin/fast-reboot-dump.py -t /host/fast-reboot
344+ FAST_REBOOT_DUMP_RC=0
345+ /usr/bin/fast-reboot-dump.py -t /host/fast-reboot || FAST_REBOOT_DUMP_RC=$?
346+ if [[ FAST_REBOOT_DUMP_RC -ne 0 ]]; then
347+ error " Failed to run fast-reboot-dump.py. Exit code: $FAST_REBOOT_DUMP_RC "
348+ unload_kernel
349+ exit " ${EXIT_FAST_REBOOT_DUMP_FAILURE} "
350+ fi
340351fi
341352
342353init_warm_reboot_states
Original file line number Diff line number Diff line change 99from fcntl import ioctl
1010import binascii
1111import argparse
12+ import syslog
13+ import traceback
1214
1315
1416ARP_CHUNK = binascii .unhexlify ('08060001080006040001' ) # defines a part of the packet for ARP Request
@@ -267,14 +269,27 @@ def main():
267269 root_dir = args .target
268270 if not os .path .isdir (root_dir ):
269271 print "Target directory '%s' not found" % root_dir
270- sys . exit ( 1 )
272+ return 3
271273 all_available_macs , map_mac_ip_per_vlan = generate_fdb_entries (root_dir + '/fdb.json' )
272274 arp_entries = generate_arp_entries (root_dir + '/arp.json' , all_available_macs )
273275 generate_default_route_entries (root_dir + '/default_routes.json' )
274276 garp_send (arp_entries , map_mac_ip_per_vlan )
275-
276- return
277-
277+ return 0
278278
279279if __name__ == '__main__' :
280- main ()
280+ res = 0
281+ try :
282+ syslog .openlog ('fast-reboot-dump' )
283+ res = main ()
284+ except KeyboardInterrupt :
285+ syslog .syslog (syslog .LOG_NOTICE , "SIGINT received. Quitting" )
286+ res = 1
287+ except Exception as e :
288+ syslog .syslog (syslog .LOG_ERR , "Got an exception %s: Traceback: %s" % (str (e ), traceback .format_exc ()))
289+ res = 2
290+ finally :
291+ syslog .closelog ()
292+ try :
293+ sys .exit (res )
294+ except SystemExit :
295+ os ._exit (res )
You can’t perform that action at this time.
0 commit comments