|
3 | 3 | ################################################################################ |
4 | 4 | # Gets extra node info from an applications node list |
5 | 5 | # |
6 | | -# NB; review SOURCE_API_NODEINFO setup, for version of controller |
7 | | -# |
8 | 6 | # Useful output lines for debug; |
9 | 7 | # echo "lines: ${#app_list_array[@]} | entries: ${#app_array[@]}" |
10 | 8 | # for key in "${!app_array[@]}"; do echo "key : $key"; echo "value : ${app_array[$key]}"; done |
@@ -42,12 +40,6 @@ usage () { |
42 | 40 | ################################################################################ |
43 | 41 | # Setup Variables, etc |
44 | 42 | ################################################################################ |
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" |
51 | 43 |
|
52 | 44 | # Set default input params |
53 | 45 | LEVEL="0" #This means -A is mandatory unless -L is changed |
@@ -129,6 +121,19 @@ runChecks () { |
129 | 121 | if [[ ${LEVEL} == "0" && -z ${APP_ID} ]]; then echo "No -A param passed for -L=0."; usage; exit 1; fi |
130 | 122 | } |
131 | 123 |
|
| 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 | + |
132 | 137 | # Setup our data sources |
133 | 138 | setupSources () { |
134 | 139 | # Filenames for input, if SOURCE=1 |
@@ -348,6 +353,7 @@ getNodeInfo () { |
348 | 353 |
|
349 | 354 | # Lets get ready |
350 | 355 | runChecks |
| 356 | +getControllerVer |
351 | 357 | setupSources |
352 | 358 |
|
353 | 359 | # Output header line |
|
0 commit comments