Handle dg-loader DGs approach with platform-logic
[appc/deployment.git] / platform-logic / installer / src / main / scripts / install-converted-dgs.sh
1 #!/bin/bash
2
3 ###
4 # ============LICENSE_START=======================================================
5 # APPC
6 # ================================================================================
7 # Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12
13 #      http://www.apache.org/licenses/LICENSE-2.0
14
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END=========================================================
21 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 ###
23
24 ###
25 ### Convert XML DGs to JSON DGs using dg-loader, then load/activate them in the MySQL DB. ###
26 ###
27
28 export APPC_HOME=${APPC_HOME:-/opt/openecomp/appc}
29
30 # SVCLOGIC_DIR env variable points to /opt/openecomp/appc/svclogic
31 export SVCLOGIC_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
32
33 # Check if the JSON Directory exists under the env. variable defined
34 export DG_JSON_DIR=${SVCLOGIC_DIR}/graphs/appc/json/dg-loader-dgs
35 echo "Processing DG JSON directory : ${DG_JSON_DIR}"
36 if [ ! -d "$DG_JSON_DIR" ] 
37 then
38     echo "DG-Loader JSON Directory is Missing"
39 exit 1
40 fi
41
42 # Temporarily use wget to download the JAR needed to execute the dg-loader actions below (NEEDS TO GET THE JAR WITH DEPENDENCIES)
43 wget -P ${SVCLOGIC_DIR}/lib https://nexus.onap.org/content/groups/staging/org/openecomp/appc/plugins/dg-loader-provider/1.1.0/dg-loader-provider-1.1.0.jar
44
45 cd ${DG_JSON_DIR}
46 mkdir -p ${DG_JSON_DIR}/converted-xml
47
48 # Generate XML DGs from JSON DGs
49 $JAVA_HOME/bin/java -cp ${SVCLOGIC_DIR}/lib/dg-loader-jar-with-dependencies.jar org.openecomp.sdnc.dg.loader.DGXMLGenerator ${DG_JSON_DIR} ${DG_JSON_DIR}/converted-xml
50
51 # Load converted XML DGs to the SVC_LOGIC DB in the MySQL Docker Container
52 $JAVA_HOME/bin/java -cp ${SVCLOGIC_DIR}/lib/dg-loader-jar-with-dependencies.jar org.openecomp.sdnc.dg.loader.DGXMLLoad ${DG_JSON_DIR}/converted-xml ${APPC_HOME}/data/properties/dblib.properties
53
54 # Activate converted XML DGs to the SVC_LOGIC DB in the MySQL Docker Container
55 $JAVA_HOME/bin/java -cp ${SVCLOGIC_DIR}/lib/dg-loader-jar-with-dependencies.jar org.openecomp.sdnc.dg.loader.DGXMLActivate ${DG_JSON_DIR}/dg_activate.txt ${APPC_HOME}/data/properties/dblib.properties
56
57 exit 0