Updates sol006 branch with master
[osm/IM.git] / tools / src / scanModules.sh
1 #!/bin/bash
2 # Copyright 2019 Whitestack LLC
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 . ./util.bash --source-only
18
19 VNFD="vnfd-catalog"
20 NSD="nsd-catalog"
21
22 > search_results.txt
23 > statistics.txt
24 echo "(pattern),(version),RO,devops,NBI,POL,LCM" &> statistics.txt
25
26 MODULES=("RO" "devops" "NBI" "POL" "LCM")
27
28 grep -r --exclude=*.txt $VNFD . &>> search_results.txt
29 grep -r --exclude=*.txt $NSD . &>> search_results.txt
30
31 generateStatistics(){ #1: $VNFD or $NSD, 2: commit tag
32 STATISTICS="$1,$2"
33 for i in "${MODULES[@]}"
34 do
35 STATISTICS="$STATISTICS,$(grep -F ./$i/ search_results.txt | grep $1 | wc -l)"
36 done
37 echo $STATISTICS &>>statistics.txt
38 }
39
40 generateStatistics $VNFD "latest"
41 generateStatistics $NSD "latest"
42
43 COLOR='\033[0;31m'
44 echo -e "${COLOR}-- Number of ocurrences of a pattern in each module for a specific version --"
45
46 printTable ',' "$(cat statistics.txt)" true