be32e98f2be386abc4cf55f50b8a627e3cfa469d
[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 execute "create-jetty-modules" do
30   command "set -ex && tar -xvf normatives.tar.gz && cd /var/tmp/normatives/import/tosca && sdcinit #{param} #{basic_auth_config} > #{ENV['ONAP_LOG']}/init.log"
31   cwd "/var/tmp/"
32   action :run
33 end