Fix build
[sdc.git] / catalog-be / sdc-backend-init / chef-repo / cookbooks / sdc-catalog-be-setup / recipes / 3_import_Normatives.rb
1 require 'base64'
2 be_ip=node['Nodes'][:BE]
3
4 if node['disableHttp']
5   protocol = "https"
6   be_port = node['BE']['https_port']
7   param="-i #{be_ip} -p #{be_port} --https"
8 else
9   protocol = "http"
10   be_port = node['BE']['http_port']
11   param="-i #{be_ip} -p #{be_port}"
12 end
13
14 if node['basic_auth']
15   basic_auth_enabled = node['basic_auth']['enabled']
16   basic_auth_user = node['basic_auth']['user_name']
17   basic_auth_pass = node['basic_auth']['user_pass']
18   if basic_auth_enabled
19     basic_auth_config = "--header " + Base64.strict_encode64(basic_auth_user + ":" + basic_auth_pass)
20   else
21     # set default user configuration file
22     basic_auth_config = ""
23   end
24 end
25 cookbook_file "/var/tmp/normatives.tar.gz" do
26   source "normatives.tar.gz"
27 end
28
29 bash "executing-import_Normatives" do
30   code <<-EOH
31     set -ex
32
33     cd /var/tmp/
34     tar -xvf normatives.tar.gz
35     
36     # executing the normatives
37     # add --debug to the sdcinit command to enable debug
38
39     cd /var/tmp/normatives/import/tosca
40     sdcinit #{param} #{basic_auth_config} > /var/lib/jetty/logs/init.log
41     rc=$?
42     if [[ $rc != 0 ]]; then exit $rc; fi
43
44   EOH
45   returns [0]
46 end