@@ -27,15 +27,19 @@ display_help() {
27
27
# Function to check if the user has root privileges
28
28
check_root_privileges () {
29
29
if [ " $EUID " -ne 0 ] ; then
30
- echo " Root privileges are needed for this operation"
30
+ echo " Root privileges are needed for this operation. " >&2
31
31
exit 1
32
32
fi
33
33
}
34
34
35
- # Function to check if the command is supported on spine routers
35
+ # Function to check if the device is supported device with type spine routers and subtype UpstreamLC
36
36
check_spine_router () {
37
- if [[ " $( sonic-cfggen -d -v DEVICE_METADATA.localhost.type) " != * " SpineRouter" * ]] ; then
38
- echo " Operation is not supported on this platform"
37
+ type=$( sonic-cfggen -d -v DEVICE_METADATA.localhost.type)
38
+ sub_type=$( sonic-cfggen -d -v DEVICE_METADATA.localhost.sub_type)
39
+
40
+ # only supported on spine routers and UpstreamLC
41
+ if [[ " $type " != " SpineRouter" || " $sub_type " != " UpstreamLC" ]]; then
42
+ echo " Operation is only supported on UpstreamLC of SpineRouter." >&2
39
43
exit 1
40
44
fi
41
45
}
@@ -61,10 +65,10 @@ validate_operation() {
61
65
done
62
66
63
67
if [ $valid_operation == false ]; then
64
- echo " Invalid parameter $1 , Operation not supported"
68
+ echo " Invalid parameter $1 , Operation not supported" >&2
65
69
echo " "
66
70
display_help
67
- exit 0
71
+ exit 1
68
72
fi
69
73
70
74
# Check if the prefix type is supported or not if the operation is not status
@@ -77,10 +81,10 @@ validate_operation() {
77
81
done
78
82
79
83
if [ $valid_prefix_type == false ]; then
80
- echo " Invalid parameter $2 , Prefix type not supported"
84
+ echo " Invalid parameter $2 , Prefix type not supported" >&2
81
85
echo " "
82
86
display_help
83
- exit 0
87
+ exit 1
84
88
fi
85
89
fi
86
90
}
@@ -160,19 +164,13 @@ if [[ ($NUM_ASIC -gt 1) ]]; then
160
164
while [ $asic -lt $NUM_ASIC ]
161
165
do
162
166
sub_role=` sonic-cfggen -d -v " DEVICE_METADATA['localhost']['sub_role']" -n asic$asic `
163
- subtype=` sonic-cfggen -d -v " DEVICE_METADATA['localhost']['subtype']" -n asic$asic `
164
- if [ $sub_role == ' FrontEnd' ] ; then
165
- if [ $subtype == ' UpstreamLC' ] ; then
166
- handle_prefix_list_asic $asic $1 $2 $3
167
- fi
167
+ if [ $sub_role == ' FrontEnd' ]; then
168
+ handle_prefix_list_asic $asic $1 $2 $3
168
169
fi
169
170
asic=$(( asic+ 1 ))
170
171
done
171
172
else
172
- subtype=` sonic-cfggen -d -v " DEVICE_METADATA['localhost']['subtype']" `
173
- if [ $subtype == ' UpstreamLC' ] ; then
174
173
handle_prefix_list_single $1 $2 $3
175
- fi
176
174
fi
177
175
178
176
if [ $1 != ' status' ]; then
0 commit comments