blob: 612f97d340d98b0939b95e7f5aa966e9879893b5 [file] [log] [blame]
Timoney, Daniel (dt5972)324ee362017-02-15 10:37:53 -05001toolsDir=$PROJECT_HOME/tools
2appRootDir=$1
3yangFilesDirFullPath=$2
4baseYangFile=$3
5
6#echo ${appRootDir}
7#echo ${yangFilesDirFullPath}
8#echo ${baseYangFile}
9if [ "$#" -lt "3" ]
10then
11 echo "Usage: $0 appRootDir yangFilesDirectoryFullPath baseYangFile example:$0 asdcApi /home/brocade/sdnc/asdcApi ASDC-API.yang"
12 exit
13fi
14cd ${toolsDir}/tmpws
15#cp ${toolsDir}/module-provider-impl.yang ${toolsDir}/tmpws
16
17if [ ! -e "${toolsDir}/module-provider-impl.yang" ]
18then
19 echo "module-provider-impl.yang should exist in the current directory"
20 exit
21fi
22
23#echo "appRootDir:$appRootDir"
24#echo "yangFileFullPath:$yangFileFullPath"
25#echo "yangFile:$yangFile"
26cp ${yangFilesDirFullPath}/*.yang ${appRootDir}/model/src/main/yang
27if [ "$?" != "0" ]
28then
29 echo "Could not copy the yang file. Exiting ..."
30 exit
31fi
32
33moduleName=$(cat ${yangFilesDirFullPath}/${baseYangFile}|egrep "module .*{"|cut -d' ' -f2|cut -d'{' -f1)
34sed -i.bak s/\$MODULE/$1/g ${toolsDir}/module-provider-impl.yang
35cp ${toolsDir}/module-provider-impl.yang ${appRootDir}/provider/src/main/yang/${appRootDir}-provider-impl.yang
36cd $appRootDir
37mvn clean install >${toolsDir}/tmpws/logs/mvn_install.log 2>&1
38if [ "$?" != "0" ]
39then
40 echo "mvn compile failed"
41 exit 1
42fi
43mkdir ${toolsDir}/tmpws/jars
44cp ./model/target/${appRootDir}.model-1.0.0-SNAPSHOT.jar ${toolsDir}/tmpws/jars
45
46mv ${toolsDir}/output_js/${moduleName}.js ${toolsDir}/output_js/${moduleName}.js_prev >/dev/null 2>&1
47${toolsDir}/getRpcsClassFromYangs.sh ${yangFilesDirFullPath}/${baseYangFile} ${toolsDir}/tmpws/${appRootDir}/model/target/${appRootDir}.model-1.0.0-SNAPSHOT.jar > ${toolsDir}/output_js/${moduleName}.js
48
49mv ${toolsDir}/output_js/${moduleName}_inputs.js ${toolsDir}/output_js/${moduleName}_inputs_prev.js >/dev/null 2>&1
50node ${toolsDir}/dot_to_json.js ${toolsDir}/output_js/${moduleName}.js $moduleName >>${toolsDir}/output_js/${moduleName}_inputs.js
51cp ${toolsDir}/output_js/${moduleName}_inputs.js $PROJECT_HOME/generatedJS