Fix build
[sdc.git] / catalog-be / sdc-backend-init / chef-repo / cookbooks / sdc-catalog-be-setup / recipes / 2_check_Backend.rb
1 require 'base64'
2 if node['disableHttp']
3   protocol = "https"
4   https_flag = "--https"
5   be_port = node['BE']['https_port']
6 else
7   protocol = "http"
8   https_flag = ""
9   be_port = node['BE']['http_port']
10 end
11
12 if node['basic_auth']
13   basic_auth_enabled = node['basic_auth']['enabled']
14   basic_auth_user = node['basic_auth']['user_name']
15   basic_auth_pass = node['basic_auth']['user_pass']
16   if basic_auth_enabled
17     basic_auth_config = "--header " + Base64.strict_encode64(basic_auth_user + ":" + basic_auth_pass)
18   else
19     # set default user configuration file
20     basic_auth_config = ""
21   end
22 end
23
24 bash "executing-check_backend_health" do
25    code <<-EOH
26      sdccheckbackend -i #{node['Nodes']['BE']} -p #{be_port} #{basic_auth_config} #{https_flag}
27      rc=$?
28      if [[ $rc != 0 ]]; then exit $rc; fi
29    EOH
30    returns [0]
31 end