OOM Alignment BE,FE,KBN
[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      if [ $resources_len -eq 0 ] ; then
23         python importONAPNormativeAll.py -i #{be_ip} > /var/lib/jetty/logs/importNormativeAll.log
24             rc=$?
25             if [[ $rc != 0 ]]; then exit $rc; fi
26      else
27         python upgradeONAPNormative.py -i #{be_ip} > /var/lib/jetty/logs/upgradeNormative.log
28             rc=$?
29             if [[ $rc != 0 ]]; then exit $rc; fi
30      fi
31    EOH
32 end