diff options
Diffstat (limited to 'dgbuilder/tools')
-rwxr-xr-x | dgbuilder/tools/auto_app.sh | 24 | ||||
-rwxr-xr-x | dgbuilder/tools/generate_props_from_yang.sh | 88 | ||||
-rwxr-xr-x | dgbuilder/tools/generate_props_from_yangs.sh | 28 | ||||
-rwxr-xr-x | dgbuilder/tools/generate_props_from_yangs_zip.sh | 36 | ||||
-rwxr-xr-x | dgbuilder/tools/getRpcsClassFromYang.sh | 4 | ||||
-rwxr-xr-x | dgbuilder/tools/getRpcsClassFromYangs.sh | 85 | ||||
-rw-r--r-- | dgbuilder/tools/module-provider-impl.yang | 61 | ||||
-rw-r--r-- | dgbuilder/tools/module-provider-impl.yang.bak | 0 | ||||
-rwxr-xr-x | dgbuilder/tools/update_app_impl_yang.sh | 45 | ||||
-rwxr-xr-x | dgbuilder/tools/update_app_impl_yangs.sh | 51 |
10 files changed, 80 insertions, 342 deletions
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 <<EOF -org.openecomp.sdnc.app -${appName} -1.0.0-SNAPSHOT -org.openecomp.sdnc.app -Y -EOF -if [ "$?" == "0" ] -then - echo "App created successfully" -else - echo "App creation failed" -fi -${toolsDir}/update_app_impl_yang.sh "${appName}" $1 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..." 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 <<EOF -org.openecomp.sdnc.app -${appName} -1.0.0-SNAPSHOT -org.openecomp.sdnc.app -Y -EOF -${toolsDir}/update_app_impl_yangs.sh "${appName}" $1 $2 -echo "Done..." - diff --git a/dgbuilder/tools/generate_props_from_yangs_zip.sh b/dgbuilder/tools/generate_props_from_yangs_zip.sh deleted file mode 100755 index 39607110..00000000 --- a/dgbuilder/tools/generate_props_from_yangs_zip.sh +++ /dev/null @@ -1,36 +0,0 @@ -if [ "$PROJECT_HOME" == "" ] -then - export PROJECT_HOME=$(pwd)/.. -fi - -toolsDir=$PROJECT_HOME/tools -if [ "$#" != "1" ] -then - echo "Usage: $0 yangFilesZipFullPath" - exit -fi -yangFilesZipFullPath="$1" -rm -rf $PROJECT_HOME/tools/tmp -mkdir $PROJECT_HOME/tools/tmp -mv ${yangFilesZipFullPath} $PROJECT_HOME/tools/tmp -cd $PROJECT_HOME/tools/tmp -zipFile=$(basename $yangFilesZipFullPath) -unzip $PROJECT_HOME/tools/tmp/$zipFile -rm ${zipFile} -for i in $(ls *.yang) -do - fName="$i" - extension="${fName##*.}" - moduleName="${fName%.*}" - count=$(grep -w "import $moduleName" *.yang|wc -l) - if [ "$count" -eq "0" ] - then - rm -rf $PROJECT_HOME/yangFiles/$moduleName - mkdir $PROJECT_HOME/yangFiles/$moduleName - mv *.yang $PROJECT_HOME/yangFiles/$moduleName - cd $PROJECT_HOME/tools - echo ./generate_props_from_yangs.sh "$PROJECT_HOME/yangFiles/$moduleName" "$fName" - ./generate_props_from_yangs.sh "$PROJECT_HOME/yangFiles/$moduleName" "$fName" - exit - fi -done diff --git a/dgbuilder/tools/getRpcsClassFromYang.sh b/dgbuilder/tools/getRpcsClassFromYang.sh index 91d95f02..b0703152 100755 --- a/dgbuilder/tools/getRpcsClassFromYang.sh +++ b/dgbuilder/tools/getRpcsClassFromYang.sh @@ -12,12 +12,12 @@ module=$(cat $yangFile|egrep "module .*{"|awk '{print $2}'|sed -e 's/{//g') #echo " \"$module\" : [" rpcs=$(grep rpc $yangFile|grep -v leaf|sed -e 's/^\s\+rpc//g'|awk '{print $1}') #echo ${rpcs} -for i in `find ${toolsDir}/yangToolsJars -name "*.jar" -print` +for i in `find ${PROJECT_HOME}/svclogic/lib -name "*.jar" -print` do #echo $i export CLASSPATH=$CLASSPATH:$i done -export CLASSPATH=$2:$CLASSPATH:.:${toolsDir}/slf4j-api-1.7.2.jar:${toolsDir}/guava-14.0.1.jar:${toolsDir}/printYangToProp.jar +export CLASSPATH=$CLASSPATH:${toolsDir}/printYangToProp.jar:. allProps="" for rpc in $rpcs do diff --git a/dgbuilder/tools/getRpcsClassFromYangs.sh b/dgbuilder/tools/getRpcsClassFromYangs.sh deleted file mode 100755 index f3ce4c81..00000000 --- a/dgbuilder/tools/getRpcsClassFromYangs.sh +++ /dev/null @@ -1,85 +0,0 @@ -toolsDir=$PROJECT_HOME/tools -. ${toolsDir}/setClasspath -if [ "$#" != "2" ] -then - echo "Usage $0 yang_file generated_jar_file" - echo "example $0 /home/users/sdnc/src/appName/model/src/main/yang/app.yang /home/users/sdnc/src/appName/model/target/appName.model-2.0.0.jar" - exit -fi -yangFile="$1" -jarFile="$2" -module=$(cat $yangFile|egrep "module .*{"|awk '{print $2}'|sed -e 's/{//g') -#echo " \"$module\" : [" -rpcs=$(grep rpc $yangFile|grep -v leaf|sed -e 's/^\s\+rpc//g'|awk '{print $1}') -for i in `find ${toolsDir}/yangToolsJars -name "*.jar" -print` -do -#echo $i -export CLASSPATH=$CLASSPATH:$i -done -export CLASSPATH=$2:$CLASSPATH:.:${toolsDir}/slf4j-api-1.7.2.jar:${toolsDir}/guava-14.0.1.jar:${toolsDir}/printYangToProp.jar -allProps="" -for rpc in $rpcs -do -rpcVal=$(echo $rpc|sed -e "s/\b\(.\)/\u\1/g"|sed s/\-//g) -#echo $rpcVal -className=$(jar -tvf ${jarFile}|grep "org/opendaylight/yang/gen/"|grep -w "${rpcVal}Input.class"|grep -v grep|awk '{print $NF}'|sed -e 's/\//./g'|sed -e 's/.class$//g') -#echo $className -inputProps="" -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" - 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 --- a/dgbuilder/tools/module-provider-impl.yang.bak +++ /dev/null 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 |