summaryrefslogtreecommitdiffstats
path: root/dgbuilder/tools/generate_props_from_yang.sh
diff options
context:
space:
mode:
authorChinthakayala, Sheshashailavas <sc2914@att.com>2017-04-07 08:18:56 -0900
committerChinthakayala, Sheshashailavas <sc2914@att.com>2017-04-07 08:21:54 -0900
commit4cc1e4b946aedcf6c34550d1903e9bd13e6e160b (patch)
tree4f3369f83f381734fb9aebc3ae9d8ed026c21c99 /dgbuilder/tools/generate_props_from_yang.sh
parent76825594b6c95cf09d5142c0f9384a5b2bf9721e (diff)
[SDNC-5] added yang upload
and added break node Change-Id: I8d36b5d400a51a6ebc248b100f04284cf27abcad Signed-off-by: Chinthakayala, Sheshashailavas <sc2914@att.com> Former-commit-id: ae6804f3c5805f78198b26de88ceb6dfa9bb335b
Diffstat (limited to 'dgbuilder/tools/generate_props_from_yang.sh')
-rwxr-xr-xdgbuilder/tools/generate_props_from_yang.sh88
1 files changed, 78 insertions, 10 deletions
diff --git a/dgbuilder/tools/generate_props_from_yang.sh b/dgbuilder/tools/generate_props_from_yang.sh
index 4ce93af5..70162c6f 100755
--- a/dgbuilder/tools/generate_props_from_yang.sh
+++ b/dgbuilder/tools/generate_props_from_yang.sh
@@ -7,6 +7,8 @@ toolsDir=$PROJECT_HOME/tools
rm -rf ${toolsDir}/tmpws
mkdir ${toolsDir}/tmpws
mkdir ${toolsDir}/tmpws/logs
+mkdir ${toolsDir}/tmpws/jars
+mkdir ${toolsDir}/tmpws/tmp
if [ "$#" != "1" ]
then
echo "Command line:$0 $*" >${toolsDir}/tmpws/logs/err.log
@@ -14,15 +16,81 @@ then
exit
fi
-appName="yangApp"
-cd ${toolsDir}/tmpws
-mvn archetype:generate -DarchetypeGroupId=com.brocade.developer -DarchetypeArtifactId=brocade.dev.plugin.ext.archetype -DarchetypeVersion=1.2.0.100-SNAPSHOT >${toolsDir}/tmpws/logs/mvn_gen_archetype.log 2>&1 <<EOF
-org.openecomp.sdnc.app
-${appName}
-1.0.0-SNAPSHOT
-org.openecomp.sdnc.app
-Y
-EOF
-${toolsDir}/update_app_impl_yang.sh "${appName}" $1
+isZipFile="N"
+echo "$1" | grep "\.zip$" >/dev/null 2>&1
+if [ "$?" -eq "0" ]
+then
+ isZipFile="Y"
+fi
+
+if [ "$isZipFile" = "Y" ]
+then
+ #zip file of yangs provided
+ zipFile=$(basename $1)
+ unzip -o -d $PROJECT_HOME/tools/tmpws/tmp $1 >/dev/null 2>&1
+ rm $1 >/dev/null 2>&1
+ cd $PROJECT_HOME/tools/tmpws/tmp
+ fName="${zipFile}"
+ extension="${fName##*.}"
+ moduleName="${fName%.*}"
+ #echo "ModuleName is :$moduleName"
+ rm -rf $PROJECT_HOME/yangFiles/$moduleName
+ mkdir $PROJECT_HOME/yangFiles/$moduleName
+ mv *.yang $PROJECT_HOME/yangFiles/$moduleName
+ cd $PROJECT_HOME/tools
+ yangFilesFullPath=${PROJECT_HOME}/yangFiles/$moduleName
+ cd ${toolsDir}/tmpws
+ mkdir -p yangApp/model/src/main/yang
+ mkdir -p yangApp/model/src/main/yang-gen-sal
+ cp -r ${yangFilesFullPath}/* yangApp/model/src/main/yang
+ cp ${toolsDir}/pom.xml_base yangApp/model/pom.xml
+ cd ${toolsDir}/tmpws/yangApp/model
+
+ #Maven Compile
+ mvn clean install >${toolsDir}/tmpws/logs/mvn_install.log 2>${toolsDir}/tmpws/logs/err.log
+ yangApp_model_jar="yangApp-model-1.0.0-SNAPSHOT.jar"
+
+ #Copy the built jar to jars directory
+ cp ${toolsDir}/tmpws/yangApp/model/target/${yangApp_model_jar} ${toolsDir}/tmpws/jars
+ . ${toolsDir}/setClasspath
+
+ mv ${toolsDir}/output_js/${moduleName}_inputs.js ${toolsDir}/output_js/${moduleName}_inputs_prev.js >/dev/null 2>&1
+
+ ${toolsDir}/getRpcsClassFromYang.sh ${yangFilesFullPath}/${moduleName}.yang ${toolsDir}/tmpws/yangApp/model/target/${yangApp_model_jar} > ${toolsDir}/output_js/${moduleName}.js
+
+ node ${toolsDir}/dot_to_json.js ${toolsDir}/output_js/${moduleName}.js $moduleName >${toolsDir}/output_js/${moduleName}_inputs.js
+
+ cp ${toolsDir}/output_js/${moduleName}_inputs.js $PROJECT_HOME/generatedJS
+else
+ #Single yang provided
+ yangFileFullPath=$1
+ cd ${toolsDir}/tmpws
+ mkdir -p yangApp/model/src/main/yang
+ mkdir -p yangApp/model/src/main/yang-gen-sal
+ cp ${yangFileFullPath} yangApp/model/src/main/yang
+ cp ${toolsDir}/pom.xml_base yangApp/model/pom.xml
+ cd ${toolsDir}/tmpws/yangApp/model
+
+ #Maven Compile
+ mvn clean install >${toolsDir}/tmpws/logs/mvn_install.log 2>${toolsDir}/tmpws/logs/err.log
+ yangApp_model_jar="yangApp-model-1.0.0-SNAPSHOT.jar"
+
+ #Copy the built jar to jars directory
+ cp ${toolsDir}/tmpws/yangApp/model/target/${yangApp_model_jar} ${toolsDir}/tmpws/jars
+ . ${toolsDir}/setClasspath
+
+ moduleName=$(cat $yangFileFullPath|egrep "module .*{"|cut -d' ' -f2|cut -d'{' -f1)
+
+ mv ${toolsDir}/output_js/${moduleName}_inputs.js ${toolsDir}/output_js/${moduleName}_inputs_prev.js >/dev/null 2>&1
+
+ ${toolsDir}/getRpcsClassFromYang.sh ${yangFileFullPath} ${toolsDir}/tmpws/yangApp/model/target/${yangApp_model_jar} > ${toolsDir}/output_js/${moduleName}.js
+
+ node ${toolsDir}/dot_to_json.js ${toolsDir}/output_js/${moduleName}.js $moduleName >${toolsDir}/output_js/${moduleName}_inputs.js
+
+ cp ${toolsDir}/output_js/${moduleName}_inputs.js $PROJECT_HOME/generatedJS
+
+
+fi
+
echo "Done..."