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