d5f0ff40955c6d36970a8c6b09b7fdb4ad3112b7
[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
7 bash "excuting-import_Normatives" do
8    code <<-EOH
9      set -x
10      cd /tmp
11      tar xvfz /tmp/normatives.tar.gz
12      cd /tmp/normatives/scripts/import/tosca/
13      /bin/chmod +x *.py
14
15      # executing the normatives
16      # add --debug=true to the importNormativeAll.py arguments to enable debug
17
18      check_normative="/tmp/check_normative.out"
19      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}:8080/sdc2/rest/v1/screen" > ${check_normative}
20
21      resources_len=`cat ${check_normative}| jq '.["resources"]|length'`
22      mkdir -p /var/lib/jetty/logs
23      if [ $resources_len -eq 0 ] ; then
24         python importONAPNormativeAll.py -i #{be_ip} > /var/lib/jetty/logs/importNormativeAll.log
25             rc=$?
26             if [[ $rc != 0 ]]; then exit $rc; fi
27      else
28         python upgradeONAPNormative.py -i #{be_ip} > /var/lib/jetty/logs/upgradeNormative.log
29             rc=$?
30             if [[ $rc != 0 ]]; then exit $rc; fi
31      fi
32    EOH
33 end