blob: 15b74dfa3ebab06002a64649ddcaf7bc99d9d059 [file] [log] [blame]
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -09001toolsDir=$PROJECT_HOME/tools
2. ${toolsDir}/setClasspath
3if [ "$#" != "2" ]
4then
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
8fi
9yangFile="$1"
10jarFile="$2"
11module=$(cat $yangFile|egrep "module .*{"|awk '{print $2}'|sed -e 's/{//g')
12#echo " \"$module\" : ["
13rpcs=$(grep rpc $yangFile|grep -v leaf|sed -e 's/^\s\+rpc//g'|awk '{print $1}')
14#echo ${rpcs}
15for i in `find ${PROJECT_HOME}/svclogic/lib -name "*.jar" -print`
16do
17#echo $i
18export CLASSPATH=$CLASSPATH:$i
19done
Sheshi Chinthakayala52bb9082017-10-18 16:56:52 -050020export CLASSPATH=$CLASSPATH:.
Chinthakayala, Sheshashailavas (sc2914)d1569972017-08-28 05:25:46 -090021allProps=""
22for rpc in $rpcs
23do
24rpcVal=$(echo $rpc|sed -e "s/\b\(.\)/\u\1/g"|sed s/\-//g)
25className=$(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')
26inputProps=""
27if [ "$className" != "" ]
28then
Sheshi Chinthakayala52bb9082017-10-18 16:56:52 -050029 #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)d1569972017-08-28 05:25:46 -090031fi
32className=$(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
35outputProps=""
36if [ "$className" != "" ]
37then
Sheshi Chinthakayala52bb9082017-10-18 16:56:52 -050038 #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)d1569972017-08-28 05:25:46 -090040fi
41if [ -z "$allProps" ]
42then
43 allProps=$(echo ${inputProps}${outputProps}|sed -e s/,$//g)
44else
45 allProps=$(echo ${allProps},${inputProps}${outputProps}|sed -e s/,$//g)
46fi
47done
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 " ]"
59echo "module.exports = {"
60echo "\"moduleName\" : \"${module}\","
61echo "'${module}_VALUES' : "
62echo "[ $allProps ]"|python -m json.tool
63echo ","
64echo "'${module}_RPCS' : ["
65
66cnt=0
67#numOfRpcs=${#rpcs[@]}
68numOfRpcs=0;
69for rpc in $rpcs
70do
71 numOfRpcs=$((numOfRpcs+1))
72done
73
74for rpc in $rpcs
75do
76 cnt=$((cnt+1))
77 if [ $cnt -eq $numOfRpcs ]
78 then
79 echo " \"$rpc\""
80 else
81 echo " \"$rpc\","
82 fi
83done
84echo " ]"
85echo "}"