From 4cc1e4b946aedcf6c34550d1903e9bd13e6e160b Mon Sep 17 00:00:00 2001 From: "Chinthakayala, Sheshashailavas" Date: Fri, 7 Apr 2017 08:18:56 -0900 Subject: [SDNC-5] added yang upload and added break node Change-Id: I8d36b5d400a51a6ebc248b100f04284cf27abcad Signed-off-by: Chinthakayala, Sheshashailavas Former-commit-id: ae6804f3c5805f78198b26de88ceb6dfa9bb335b --- dgbuilder/tools/auto_app.sh | 24 ------- dgbuilder/tools/generate_props_from_yang.sh | 88 +++++++++++++++++++++--- dgbuilder/tools/generate_props_from_yangs.sh | 28 -------- dgbuilder/tools/generate_props_from_yangs_zip.sh | 36 ---------- dgbuilder/tools/getRpcsClassFromYang.sh | 4 +- dgbuilder/tools/getRpcsClassFromYangs.sh | 85 ----------------------- dgbuilder/tools/module-provider-impl.yang | 61 ---------------- dgbuilder/tools/module-provider-impl.yang.bak | 0 dgbuilder/tools/update_app_impl_yang.sh | 45 ------------ dgbuilder/tools/update_app_impl_yangs.sh | 51 -------------- 10 files changed, 80 insertions(+), 342 deletions(-) delete mode 100755 dgbuilder/tools/auto_app.sh delete mode 100755 dgbuilder/tools/generate_props_from_yangs.sh delete mode 100755 dgbuilder/tools/generate_props_from_yangs_zip.sh delete mode 100755 dgbuilder/tools/getRpcsClassFromYangs.sh delete mode 100644 dgbuilder/tools/module-provider-impl.yang delete mode 100644 dgbuilder/tools/module-provider-impl.yang.bak delete mode 100755 dgbuilder/tools/update_app_impl_yang.sh delete mode 100755 dgbuilder/tools/update_app_impl_yangs.sh (limited to 'dgbuilder/tools') diff --git a/dgbuilder/tools/auto_app.sh b/dgbuilder/tools/auto_app.sh deleted file mode 100755 index a3e0f2e9..00000000 --- a/dgbuilder/tools/auto_app.sh +++ /dev/null @@ -1,24 +0,0 @@ -toolsDir=$PROJECT_HOME/tools -if [ "$#" != "1" ] -then - echo "Usage: $0 appName" - exit -fi -appName="$1" -mkdir tmpws -cd tmpws -mkdir logs -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 <${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 </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..." diff --git a/dgbuilder/tools/generate_props_from_yangs.sh b/dgbuilder/tools/generate_props_from_yangs.sh deleted file mode 100755 index 8867cea3..00000000 --- a/dgbuilder/tools/generate_props_from_yangs.sh +++ /dev/null @@ -1,28 +0,0 @@ -if [ -z "$PROJECT_HOME" ] -then - export PROJECT_HOME=$(pwd)/.. -fi - -toolsDir=$PROJECT_HOME/tools -rm -rf ${toolsDir}/tmpws -mkdir ${toolsDir}/tmpws -mkdir ${toolsDir}/tmpws/logs -if [ "$#" != "2" ] -then - echo "Command line:$0 $*" >${toolsDir}/tmpws/logs/err.log - echo "Usage: $0 yangFilesdirectoryFullPath baseYangFile" >>${toolsDir}/tmpws/logs/err.log - 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 </dev/null|grep '*' |cut -d'*' -f2|sed -e "s/^[ \t]*//g"|sed -e "s/^/\t\t\"/g"|sed -e "s/$/\",/g" - inputProps=$(java -cp $CLASSPATH PrintYangToProp $className 2>${toolsDir}/tmpws/logs/err.log) -fi -className=$(jar -tvf ${jarFile}|grep "org/opendaylight/yang/gen/"|grep -w "${rpcVal}Output"|grep -v grep|awk '{print $NF}'|sed -e 's/\//./g'|sed -e 's/.class$//g') -#echo $inputProps -#echo $className -outputProps="" -if [ "$className" != "" ] -then - #java -cp $CLASSPATH PrintYangToProp $className 2>/dev/null|grep '*' |cut -d'*' -f2|sed -e "s/^[ \t]*//g"|sed -e "s/^/\t\t\"/g"|sed -e "s/$/\",/g" - outputProps=$(java -cp $CLASSPATH PrintYangToProp $className 2>${toolsDir}/tmpws/logs/err.log) -fi -if [ -z "$allProps" ] -then - allProps=$(echo ${inputProps}${outputProps}|sed -e s/,$//g) -else - allProps=$(echo ${allProps},${inputProps}${outputProps}|sed -e s/,$//g) -fi -done -#echo $allProps -#OIFS=$IFS -#IFS=',' -#arr2=$allProps -#for x in $arr2 -#do -# echo "$x" -#done -#IFS=$OIFS -#echo " ]" -echo "module.exports = {" -echo "\"moduleName\" : \"${module}\"," -echo "'${module}_VALUES' : " -echo "[ $allProps ]"|python -m json.tool -echo "," -echo "'${module}_RPCS' : [" - -cnt=0 -#numOfRpcs=${#rpcs[@]} -numOfRpcs=0; -for rpc in $rpcs -do - numOfRpcs=$((numOfRpcs+1)) -done - -for rpc in $rpcs -do - cnt=$((cnt+1)) - if [ $cnt -eq $numOfRpcs ] - then - echo " \"$rpc\"" - else - echo " \"$rpc\"," - fi -done -echo " ]" -echo "}" diff --git a/dgbuilder/tools/module-provider-impl.yang b/dgbuilder/tools/module-provider-impl.yang deleted file mode 100644 index 62059104..00000000 --- a/dgbuilder/tools/module-provider-impl.yang +++ /dev/null @@ -1,61 +0,0 @@ -module yangApp-provider-impl { - - yang-version 1; - namespace "brocade:training:yangApp:provider:impl"; - prefix "yangApp-provider-impl"; - - import config { prefix config; revision-date 2013-04-05; } - import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; } - - description - "This module contains the base YANG definitions for - yangApp-provider impl implementation."; - - revision "2014-05-23" { - description - "Initial revision."; - } - - // This is the definition of the service implementation as a module identity. - identity yangApp-provider-impl { - base config:module-type; - - // Specifies the prefix for generated java classes. - config:java-name-prefix yangAppProvider; - } - - // Augments the 'configuration' choice node under modules/module. - // We consume the three main services, RPCs, DataStore, and Notifications - augment "/config:modules/config:module/config:configuration" { - case yangApp-provider-impl { - when "/config:modules/config:module/config:type = 'yangApp-provider-impl'"; - - container rpc-registry { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-rpc-registry; - } - } - } - - container notification-service { - uses config:service-ref { - refine type { - mandatory true; - config:required-identity mdsal:binding-notification-service; - } - } - } - - container data-broker { - uses config:service-ref { - refine type { - mandatory false; - config:required-identity mdsal:binding-async-data-broker; - } - } - } - } - } -} diff --git a/dgbuilder/tools/module-provider-impl.yang.bak b/dgbuilder/tools/module-provider-impl.yang.bak deleted file mode 100644 index e69de29b..00000000 diff --git a/dgbuilder/tools/update_app_impl_yang.sh b/dgbuilder/tools/update_app_impl_yang.sh deleted file mode 100755 index 9ae5610b..00000000 --- a/dgbuilder/tools/update_app_impl_yang.sh +++ /dev/null @@ -1,45 +0,0 @@ -toolsDir=$PROJECT_HOME/tools -appRootDir=$1 -yangFileFullPath=$2 -yangFile=$(basename $yangFileFullPath) - -if [ "$#" != "2" ] -then - echo "Usage: $0 appRootDir yangModuleName example:$0 bwcal bwcal" - exit -fi -cd ${toolsDir}/tmpws -#cp ${toolsDir}/module-provider-impl.yang ${toolsDir}/tmpws - -if [ ! -e "${toolsDir}/module-provider-impl.yang" ] -then - echo "${toolsDir}/module-provider-impl.yang should exist" - exit -fi - -#echo "appRootDir:$appRootDir" -#echo "yangFileFullPath:$yangFileFullPath" -#echo "yangFile:$yangFile" - -cp ${yangFileFullPath} ${appRootDir}/model/src/main/yang/${yangFile} -if [ "$?" != "0" ] -then - echo "Could not copy the yang file. Exiting ..." - exit -fi - -moduleName=$(cat $yangFileFullPath|egrep "module .*{"|cut -d' ' -f2|cut -d'{' -f1) -#echo $moduleName -sed -i.bak s/\$MODULE/$1/g ${toolsDir}/module-provider-impl.yang -cp ${toolsDir}/module-provider-impl.yang ${appRootDir}/provider/src/main/yang/${appRootDir}-provider-impl.yang -cd $appRootDir -mvn clean install >${toolsDir}/tmpws/logs/mvn_install.log 2>&1 -mkdir ${toolsDir}/tmpws/jars -cp ./model/target/${appRootDir}.model-1.0.0-SNAPSHOT.jar ${toolsDir}/tmpws/jars - -mv ${toolsDir}/output_js/${moduleName}_inputs.js ${toolsDir}/output_js/${moduleName}_inputs_prev.js >/dev/null 2>&1 - -${toolsDir}/getRpcsClassFromYang.sh ${yangFileFullPath} ${toolsDir}/tmpws/${appRootDir}/model/target/${appRootDir}.model-1.0.0-SNAPSHOT.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 diff --git a/dgbuilder/tools/update_app_impl_yangs.sh b/dgbuilder/tools/update_app_impl_yangs.sh deleted file mode 100755 index 612f97d3..00000000 --- a/dgbuilder/tools/update_app_impl_yangs.sh +++ /dev/null @@ -1,51 +0,0 @@ -toolsDir=$PROJECT_HOME/tools -appRootDir=$1 -yangFilesDirFullPath=$2 -baseYangFile=$3 - -#echo ${appRootDir} -#echo ${yangFilesDirFullPath} -#echo ${baseYangFile} -if [ "$#" -lt "3" ] -then - echo "Usage: $0 appRootDir yangFilesDirectoryFullPath baseYangFile example:$0 asdcApi /home/brocade/sdnc/asdcApi ASDC-API.yang" - exit -fi -cd ${toolsDir}/tmpws -#cp ${toolsDir}/module-provider-impl.yang ${toolsDir}/tmpws - -if [ ! -e "${toolsDir}/module-provider-impl.yang" ] -then - echo "module-provider-impl.yang should exist in the current directory" - exit -fi - -#echo "appRootDir:$appRootDir" -#echo "yangFileFullPath:$yangFileFullPath" -#echo "yangFile:$yangFile" -cp ${yangFilesDirFullPath}/*.yang ${appRootDir}/model/src/main/yang -if [ "$?" != "0" ] -then - echo "Could not copy the yang file. Exiting ..." - exit -fi - -moduleName=$(cat ${yangFilesDirFullPath}/${baseYangFile}|egrep "module .*{"|cut -d' ' -f2|cut -d'{' -f1) -sed -i.bak s/\$MODULE/$1/g ${toolsDir}/module-provider-impl.yang -cp ${toolsDir}/module-provider-impl.yang ${appRootDir}/provider/src/main/yang/${appRootDir}-provider-impl.yang -cd $appRootDir -mvn clean install >${toolsDir}/tmpws/logs/mvn_install.log 2>&1 -if [ "$?" != "0" ] -then - echo "mvn compile failed" - exit 1 -fi -mkdir ${toolsDir}/tmpws/jars -cp ./model/target/${appRootDir}.model-1.0.0-SNAPSHOT.jar ${toolsDir}/tmpws/jars - -mv ${toolsDir}/output_js/${moduleName}.js ${toolsDir}/output_js/${moduleName}.js_prev >/dev/null 2>&1 -${toolsDir}/getRpcsClassFromYangs.sh ${yangFilesDirFullPath}/${baseYangFile} ${toolsDir}/tmpws/${appRootDir}/model/target/${appRootDir}.model-1.0.0-SNAPSHOT.jar > ${toolsDir}/output_js/${moduleName}.js - -mv ${toolsDir}/output_js/${moduleName}_inputs.js ${toolsDir}/output_js/${moduleName}_inputs_prev.js >/dev/null 2>&1 -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 -- cgit 1.2.3-korg