Chinthakayala, Sheshashailavas (sc2914) | d156997 | 2017-08-28 05:25:46 -0900 | [diff] [blame] | 1 | toolsDir=$PROJECT_HOME/tools |
| 2 | . ${toolsDir}/setClasspath |
| 3 | if [ "$#" != "2" ] |
| 4 | then |
| 5 | echo "Usage $0 yang_file generated_jar_file" |
| 6 | echo "example $0 /home/users/sdnc/src/sample.yang /home/users/sdnc/target/sample.model-1.0.0.jar" |
| 7 | exit |
| 8 | fi |
| 9 | yangFile="$1" |
| 10 | jarFile="$2" |
| 11 | module=$(cat $yangFile|egrep "module .*{"|awk '{print $2}'|sed -e 's/{//g') |
| 12 | #echo " \"$module\" : [" |
| 13 | rpcs=$(grep rpc $yangFile|grep -v leaf|sed -e 's/^\s\+rpc//g'|awk '{print $1}') |
| 14 | #echo ${rpcs} |
| 15 | for i in `find ${PROJECT_HOME}/svclogic/lib -name "*.jar" -print` |
| 16 | do |
| 17 | #echo $i |
| 18 | export CLASSPATH=$CLASSPATH:$i |
| 19 | done |
Sheshi Chinthakayala | 52bb908 | 2017-10-18 16:56:52 -0500 | [diff] [blame] | 20 | export CLASSPATH=$CLASSPATH:. |
Chinthakayala, Sheshashailavas (sc2914) | d156997 | 2017-08-28 05:25:46 -0900 | [diff] [blame] | 21 | allProps="" |
| 22 | for rpc in $rpcs |
| 23 | do |
| 24 | rpcVal=$(echo $rpc|sed -e "s/\b\(.\)/\u\1/g"|sed s/\-//g) |
| 25 | 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') |
| 26 | inputProps="" |
| 27 | if [ "$className" != "" ] |
| 28 | then |
Sheshi Chinthakayala | 52bb908 | 2017-10-18 16:56:52 -0500 | [diff] [blame] | 29 | #java -cp $CLASSPATH org.onap.ccsdk.sli.core.sli.PrintYangToProp $className 2>/dev/null|grep '*' |cut -d'*' -f2|sed -e "s/^[ \t]*//g"|sed -e "s/^/\t\t\"/g"|sed -e "s/$/\",/g" |
| 30 | inputProps=$(java -cp $CLASSPATH org.onap.ccsdk.sli.core.sli.PrintYangToProp $className 2>${toolsDir}/tmpws/logs/err.log) |
Chinthakayala, Sheshashailavas (sc2914) | d156997 | 2017-08-28 05:25:46 -0900 | [diff] [blame] | 31 | fi |
| 32 | 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') |
| 33 | #echo $inputProps |
| 34 | #echo $className |
| 35 | outputProps="" |
| 36 | if [ "$className" != "" ] |
| 37 | then |
Sheshi Chinthakayala | 52bb908 | 2017-10-18 16:56:52 -0500 | [diff] [blame] | 38 | #java -cp $CLASSPATH org.onap.ccsdk.sli.core.sli.PrintYangToProp $className 2>/dev/null|grep '*' |cut -d'*' -f2|sed -e "s/^[ \t]*//g"|sed -e "s/^/\t\t\"/g"|sed -e "s/$/\",/g" |
| 39 | outputProps=$(java -cp $CLASSPATH org.onap.ccsdk.sli.core.sli.PrintYangToProp $className 2>${toolsDir}/tmpws/logs/err.log) |
Chinthakayala, Sheshashailavas (sc2914) | d156997 | 2017-08-28 05:25:46 -0900 | [diff] [blame] | 40 | fi |
| 41 | if [ -z "$allProps" ] |
| 42 | then |
| 43 | allProps=$(echo ${inputProps}${outputProps}|sed -e s/,$//g) |
| 44 | else |
| 45 | allProps=$(echo ${allProps},${inputProps}${outputProps}|sed -e s/,$//g) |
| 46 | fi |
| 47 | done |
| 48 | #allProps=$(echo ${inputProps}${outputProps}|sed -e s/,$//g) |
| 49 | #echo $allProps |
| 50 | #OIFS=$IFS |
| 51 | #IFS=',' |
| 52 | #arr2=$allProps |
| 53 | #for x in $arr2 |
| 54 | #do |
| 55 | # echo "$x" |
| 56 | #done |
| 57 | #IFS=$OIFS |
| 58 | #echo " ]" |
| 59 | echo "module.exports = {" |
| 60 | echo "\"moduleName\" : \"${module}\"," |
| 61 | echo "'${module}_VALUES' : " |
| 62 | echo "[ $allProps ]"|python -m json.tool |
| 63 | echo "," |
| 64 | echo "'${module}_RPCS' : [" |
| 65 | |
| 66 | cnt=0 |
| 67 | #numOfRpcs=${#rpcs[@]} |
| 68 | numOfRpcs=0; |
| 69 | for rpc in $rpcs |
| 70 | do |
| 71 | numOfRpcs=$((numOfRpcs+1)) |
| 72 | done |
| 73 | |
| 74 | for rpc in $rpcs |
| 75 | do |
| 76 | cnt=$((cnt+1)) |
| 77 | if [ $cnt -eq $numOfRpcs ] |
| 78 | then |
| 79 | echo " \"$rpc\"" |
| 80 | else |
| 81 | echo " \"$rpc\"," |
| 82 | fi |
| 83 | done |
| 84 | echo " ]" |
| 85 | echo "}" |