diff options
author | Timoney, Daniel (dt5972) <dtimoney@att.com> | 2017-02-15 10:37:53 -0500 |
---|---|---|
committer | Timoney, Daniel (dt5972) <dtimoney@att.com> | 2017-02-15 10:40:37 -0500 |
commit | 324ee36fe31763e507b422ab0a88e4230045e205 (patch) | |
tree | d0b04520f6657601c918ce63fd27575977624187 /dgbuilder/tools/getRpcsClassFromYang.sh | |
parent | f0c97e8db427481e28c0a16b789bc73801b35e47 (diff) |
Initial commit for OpenECOMP SDN-C OA&M
Change-Id: I7ab579fd0d206bf356f36d52dcdf4f71f1fa2680
Signed-off-by: Timoney, Daniel (dt5972) <dtimoney@att.com>
Former-commit-id: 2a9f0edd09581f907e62ec4689b5ac94dd5382ba
Diffstat (limited to 'dgbuilder/tools/getRpcsClassFromYang.sh')
-rwxr-xr-x | dgbuilder/tools/getRpcsClassFromYang.sh | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/dgbuilder/tools/getRpcsClassFromYang.sh b/dgbuilder/tools/getRpcsClassFromYang.sh new file mode 100755 index 00000000..d7fc213e --- /dev/null +++ b/dgbuilder/tools/getRpcsClassFromYang.sh @@ -0,0 +1,85 @@ +toolsDir=$PROJECT_HOME/tools +. ${toolsDir}/setClasspath +if [ "$#" != "2" ] +then + echo "Usage $0 yang_file generated_jar_file" + echo "example $0 /home/users/sdnc/src/aic-homing/model/src/main/yang/AicHoming.yang /home/users/sdnc/src/aic-homing/model/target/aicHoming.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}') +#echo ${rpcs} +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) +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') +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 +#allProps=$(echo ${inputProps}${outputProps}|sed -e s/,$//g) +#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 "}" |