@@ -10,6 +10,8 @@ REBOOT_TYPE="${REBOOT_SCRIPT_NAME}"
10
10
VERBOSE=no
11
11
FORCE=no
12
12
REBOOT_METHOD=" /sbin/kexec -e"
13
+ ASSISTANT_IP_LIST=" "
14
+ ASSISTANT_SCRIPT=" /usr/bin/neighbor_advertiser"
13
15
14
16
EXIT_SUCCESS=0
15
17
EXIT_FAILURE=1
@@ -40,24 +42,22 @@ function debug()
40
42
function showHelpAndExit()
41
43
{
42
44
echo " Usage: ${REBOOT_SCRIPT_NAME} [options]"
43
- echo " -h -? : get this help"
45
+ echo " -h, -? : get this help"
44
46
echo " -v : turn on verbose"
45
47
echo " -f : force execution"
46
48
echo " -r : reboot with /sbin/reboot"
47
49
echo " -k : reboot with /sbin/kexec -e [default]"
48
50
echo " -x : execute script with -x flag"
51
+ echo " -c : specify control plane assistant IP list"
49
52
50
53
exit " ${EXIT_SUCCESS} "
51
54
}
52
55
53
56
function parseOptions()
54
57
{
55
- while getopts " vfh?rkx " opt; do
58
+ while getopts " vfh?rkxc: " opt; do
56
59
case ${opt} in
57
- h )
58
- showHelpAndExit
59
- ;;
60
- \? )
60
+ h|\? )
61
61
showHelpAndExit
62
62
;;
63
63
v )
@@ -75,18 +75,30 @@ function parseOptions()
75
75
x )
76
76
set -x
77
77
;;
78
+ c )
79
+ ASSISTANT_IP_LIST=${OPTARG}
80
+ ;;
78
81
esac
79
82
done
80
83
}
81
84
82
85
sonic_asic_type=$( sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type)
83
86
87
+ function clear_fast_boot()
88
+ {
89
+ debug " ${REBOOT_TYPE} failure ($? ) cleanup ..."
90
+
91
+ /sbin/kexec -u || /bin/true
92
+
93
+ teardown_control_plane_assistant
94
+ }
95
+
84
96
function clear_warm_boot()
85
97
{
86
- debug " Failure ($? ) cleanup ..."
98
+ clear_fast_boot
99
+
87
100
result=` timeout 10s config warm_restart disable; if [[ $? == 124 ]]; then echo timeout; else echo " code ($? )" ; fi` || /bin/true
88
101
debug " Cancel warm-reboot: ${result} "
89
- /sbin/kexec -u || /bin/true
90
102
91
103
TIMESTAMP=` date +%Y%m%d-%H%M%S`
92
104
if [[ -f ${WARM_DIR} /${REDIS_FILE} ]]; then
@@ -170,13 +182,30 @@ function backup_database()
170
182
docker exec -i database rm /var/lib/redis/$REDIS_FILE
171
183
}
172
184
185
+ function setup_control_plane_assistant()
186
+ {
187
+ if [[ -n " ${ASSISTANT_IP_LIST} " && -x ${ASSISTANT_SCRIPT} ]]; then
188
+ debug " Setting up control plane assistant: ${ASSISTANT_IP_LIST} ..."
189
+ ${ASSISTANT_SCRIPT} -s ${ASSISTANT_IP_LIST} -m set
190
+ fi
191
+ }
192
+
193
+ function teardown_control_plane_assistant()
194
+ {
195
+ if [[ -n " ${ASSISTANT_IP_LIST} " && -x ${ASSISTANT_SCRIPT} ]]; then
196
+ debug " Tearing down control plane assistant: ${ASSISTANT_IP_LIST} ..."
197
+ ${ASSISTANT_SCRIPT} -s ${ASSISTANT_IP_LIST} -m reset
198
+ fi
199
+ }
200
+
173
201
parseOptions $@
174
202
175
203
# Check reboot type supported
176
204
BOOT_TYPE_ARG=" cold"
177
205
case " $REBOOT_TYPE " in
178
206
" fast-reboot" )
179
207
BOOT_TYPE_ARG=$REBOOT_TYPE
208
+ trap clear_fast_boot EXIT HUP INT QUIT TERM KILL ABRT ALRM
180
209
;;
181
210
" warm-reboot" )
182
211
if [[ " $sonic_asic_type " == " mellanox" ]]; then
@@ -256,6 +285,8 @@ if [[ "$REBOOT_TYPE" = "fast-reboot" ]]; then
256
285
/usr/bin/fast-reboot-dump.py -t /host/fast-reboot
257
286
fi
258
287
288
+ setup_control_plane_assistant
289
+
259
290
if [[ " $REBOOT_TYPE " = " warm-reboot" || " $REBOOT_TYPE " = " fastfast-reboot" ]]; then
260
291
# Freeze orchagent for warm restart
261
292
# Try freeze 5 times, it is possible that the orchagent is in transient state and no opportunity to be freezed
0 commit comments