Skip to content

Commit dc9c98e

Browse files
committed
Added auto-detect feature for controller version
This enables auto-switch of restui call format
1 parent 9e8b1d5 commit dc9c98e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

recipes/get_node_extrainfo.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
################################################################################
44
# Gets extra node info from an applications node list
55
#
6-
# NB; review SOURCE_API_NODEINFO setup, for version of controller
7-
#
86
# Useful output lines for debug;
97
# echo "lines: ${#app_list_array[@]} | entries: ${#app_array[@]}"
108
# for key in "${!app_array[@]}"; do echo "key : $key"; echo "value : ${app_array[$key]}"; done
@@ -42,12 +40,6 @@ usage () {
4240
################################################################################
4341
# Setup Variables, etc
4442
################################################################################
45-
# RESTUI API call
46-
# TODO: Find exact version api calls changed
47-
# NB; this api call is valid on > mid-4.5 controller...
48-
SOURCE_API_NODEINFO="/controller/restui/v1/nodes/list/health/ids"
49-
# ...before which it was
50-
#SOURCE_API_NODEINFO="/controller/restui/nodes/list/health/ids"
5143

5244
# Set default input params
5345
LEVEL="0" #This means -A is mandatory unless -L is changed
@@ -129,6 +121,19 @@ runChecks () {
129121
if [[ ${LEVEL} == "0" && -z ${APP_ID} ]]; then echo "No -A param passed for -L=0."; usage; exit 1; fi
130122
}
131123

124+
# Gets the controllers version, to switch the restui API format
125+
# TODO: Find exact version api calls changed, assumed 4.5.15 at present
126+
getControllerVer () {
127+
VER=$(../act.sh -E ${ENVIRONMENT} controller version)
128+
if [[ -z ${VER} ]]; then echo "Unable to get controllers version."; exit 1; fi
129+
# If controller version is less than 4.5.15, then use old restui API format
130+
if [[ ${VER} =~ ^4.5.([0-9]*) && ${BASH_REMATCH[1]} -lt 15 ]]; then
131+
SOURCE_API_NODEINFO="/controller/restui/nodes/list/health/ids"
132+
else
133+
SOURCE_API_NODEINFO="/controller/restui/v1/nodes/list/health/ids"
134+
fi
135+
}
136+
132137
# Setup our data sources
133138
setupSources () {
134139
# Filenames for input, if SOURCE=1
@@ -348,6 +353,7 @@ getNodeInfo () {
348353

349354
# Lets get ready
350355
runChecks
356+
getControllerVer
351357
setupSources
352358

353359
# Output header line

0 commit comments

Comments
 (0)