Fixes to docker run
[sdc.git] / catalog-be / sdc-backend-init / chef-repo / cookbooks / sdc-catalog-be-setup / recipes / 3_import_Normatives.rb
1 cookbook_file "/tmp/normatives.tar.gz" do
2       source "normatives.tar.gz"
3    end
4
5 be_ip=node['Nodes'][:BE]
6 be_port=node['BE']['http_port']
7
8 bash "excuting-import_Normatives" do
9    code <<-EOH
10      set -x
11      cd /tmp
12      tar xvfz /tmp/normatives.tar.gz
13      cd /tmp/normatives/scripts/import/tosca/
14      /bin/chmod +x *.py
15
16      # executing the normatives
17      # add --debug=true to the importNormativeAll.py arguments to enable debug
18
19      check_normative="/tmp/check_normative.out"
20      status_code=$(curl -s -o ${check_normative} -w "%{http_code}\\n" -X GET -H 'Content-Type: application/json;charset=UTF-8' -H 'USER_ID: jh0003' -H 'X-ECOMP-RequestID: cbe744a0-037b-458f-aab5-df6e543c4090' "http://#{be_ip}:#{be_port}/sdc2/rest/v1/screen")
21      if [ "$status_code" != 200 ] ; then
22         exit "$status_code"
23      fi
24
25      #curl -s -X GET -H "Content-Type: application/json;charset=UTF-8" -H "USER_ID: jh0003" -H "X-ECOMP-RequestID: cbe744a0-037b-458f-aab5-df6e543c4090" "http://#{be_ip}:#{be_port}/sdc2/rest/v1/screen" > ${check_normative}
26
27      resources_len=`cat ${check_normative}| jq '.["resources"]|length'`
28      mkdir -p /var/lib/jetty/logs
29      if [ $resources_len -eq 0 ] ; then
30         python importONAPNormativeAll.py -i #{be_ip} -p #{be_port} > /var/lib/jetty/logs/importNormativeAll.log
31             rc=$?
32             if [[ $rc != 0 ]]; then exit $rc; fi
33      else
34         python upgradeONAPNormative.py -i #{be_ip}  -p #{be_port} > /var/lib/jetty/logs/upgradeNormative.log
35             rc=$?
36             if [[ $rc != 0 ]]; then exit $rc; fi
37      fi
38    EOH
39 end