File tree 2 files changed +37
-11
lines changed
2 files changed +37
-11
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ EXIT_FILE_SYSTEM_FULL=3
24
24
EXIT_NEXT_IMAGE_NOT_EXISTS=4
25
25
EXIT_ORCHAGENT_SHUTDOWN=10
26
26
EXIT_SYNCD_SHUTDOWN=11
27
+ EXIT_FAST_REBOOT_DUMP_FAILURE=12
27
28
28
29
function error()
29
30
{
@@ -251,6 +252,14 @@ function reboot_pre_check()
251
252
fi
252
253
}
253
254
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
+
254
263
# main starts here
255
264
parseOptions $@
256
265
@@ -292,11 +301,7 @@ case "$REBOOT_TYPE" in
292
301
;;
293
302
esac
294
303
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
300
305
301
306
setup_reboot_variables
302
307
@@ -336,7 +341,13 @@ if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
336
341
# Dump the ARP and FDB tables to files also as default routes for both IPv4 and IPv6
337
342
# into /host/fast-reboot
338
343
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
340
351
fi
341
352
342
353
init_warm_reboot_states
Original file line number Diff line number Diff line change 9
9
from fcntl import ioctl
10
10
import binascii
11
11
import argparse
12
+ import syslog
13
+ import traceback
12
14
13
15
14
16
ARP_CHUNK = binascii .unhexlify ('08060001080006040001' ) # defines a part of the packet for ARP Request
@@ -267,14 +269,27 @@ def main():
267
269
root_dir = args .target
268
270
if not os .path .isdir (root_dir ):
269
271
print "Target directory '%s' not found" % root_dir
270
- sys . exit ( 1 )
272
+ return 3
271
273
all_available_macs , map_mac_ip_per_vlan = generate_fdb_entries (root_dir + '/fdb.json' )
272
274
arp_entries = generate_arp_entries (root_dir + '/arp.json' , all_available_macs )
273
275
generate_default_route_entries (root_dir + '/default_routes.json' )
274
276
garp_send (arp_entries , map_mac_ip_per_vlan )
275
-
276
- return
277
-
277
+ return 0
278
278
279
279
if __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