diff options
author | 2020-06-04 10:46:47 +0200 | |
---|---|---|
committer | 2020-06-24 11:16:53 +0200 | |
commit | fca8a0b1af32083b8ea025135b120091aec9714f (patch) | |
tree | 4bb568ca92ad037801937d1cf2264b4dff923c52 /catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/check_Backend_Health.py.erb | |
parent | 7027b33eb41947e6799392d392283b09110158d1 (diff) |
Refactoring the check backend, create consumers
Continue refactoring:
- added script for healthCheck, create new consumers
- also update chef recipes to use new script
Issue-ID: SDC-2784
Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
Change-Id: I158d816362f91f74b217fe85112cf7c14da8f1ec
Diffstat (limited to 'catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/check_Backend_Health.py.erb')
-rw-r--r-- | catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/check_Backend_Health.py.erb | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/check_Backend_Health.py.erb b/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/check_Backend_Health.py.erb deleted file mode 100644 index ebd8ea5c84..0000000000 --- a/catalog-be/sdc-backend-init/chef-repo/cookbooks/sdc-catalog-be-setup/templates/default/check_Backend_Health.py.erb +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -import subprocess -#from time import sleep -import time -from datetime import datetime -import sys - -beStat=0 -BE_IP="<%= @be_ip %>" -BE_PORT="<%= @be_port %>" -PROTOCOL="<%= @protocol %>" - -class bcolors: - HEADER = '\033[95m' - OKBLUE = '\033[94m' - OKGREEN = '\033[92m' - WARNING = '\033[93m' - FAIL = '\033[91m' - ENDC = '\033[0m' - BOLD = '\033[1m' - UNDERLINE = '\033[4m' - - -############################## -# Functions -############################## -def checkBackend(): - command="curl -k -s -o /dev/null -I -w \"%{http_code}\" -i "+PROTOCOL+"://" + BE_IP + ":" + BE_PORT + "/sdc2/rest/v1/user/jh0003" - - proc = subprocess.Popen( command , shell=True , stdout=subprocess.PIPE ) - (out, err) = proc.communicate() - result = out.strip() - return str(result, "UTF-8") - -############################## -# Main -############################## - -for i in range(1,10): - myResult = checkBackend() - if myResult == '200': - print('[INFO]: Backend is up and running') - beStat=1 - break - else: - currentTime = datetime.now() - print('[ERROR]: ' + currentTime.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + ' Backend not responding, try #' + str(i) + bcolors.ENDC) - time.sleep(10) - -if beStat == 0: - print '[ERROR]: ' + time.strftime('%Y/%m/%d %H:%M:%S') + bcolors.FAIL + 'Backend is DOWN :-(' + bcolors.ENDC - sys.exit(1)
\ No newline at end of file |