From d58edf68ab4e22a9b06178df1b77c3b318c53d8e Mon Sep 17 00:00:00 2001 From: Alarig Le Lay Date: Sun, 1 Nov 2020 15:18:31 +0100 Subject: [PATCH] creationRoutesVM.sh: Handeling API token failure --- creationRoutesVM.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/creationRoutesVM.sh b/creationRoutesVM.sh index b145ab6..e1fef28 100755 --- a/creationRoutesVM.sh +++ b/creationRoutesVM.sh @@ -131,6 +131,11 @@ write_log DEBUG 'Connecting to API' RES_AUTHENT=$(${CURL} -X POST --user ${USER_IPAM}:${PASSWORD_IPAM} ${URL}/user/) CODE_RETOUR_RES_AUTHENT=$(echo ${RES_AUTHENT} | jq '.code') +if [ $? != 0 ]; then + # The IPAM is probably down, simulating 503 HTTP code + CODE_RETOUR_RES_AUTHENT=503 +fi + # Si OK, on utilise l'IPAM, sinon on passe par le fichier de cache if [ ${CODE_RETOUR_RES_AUTHENT} != 200 ]; then write_log ERROR "Wrong HTTP code from the API: ${CODE_RETOUR_RES_AUTHENT}"