From: Tomás Villaseca Date: Fri, 27 Dec 2019 17:15:21 +0000 (-0300) Subject: Add tool to measure usage of old descriptors X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=4f962b71b5432b2812c6d31ed3b37196ff80d73d;p=osm%2FIM.git Add tool to measure usage of old descriptors Change-Id: I491b78f91d3b8a8a78ba34d419d39e5451067a3b Signed-off-by: Tomás Villaseca --- diff --git a/tools/Dockerfile b/tools/Dockerfile new file mode 100644 index 0000000..c7fdce4 --- /dev/null +++ b/tools/Dockerfile @@ -0,0 +1,30 @@ +# Copyright 2019 Whitestack LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM alpine + +WORKDIR /src + +RUN apk update && apk add --update --no-cache git bash util-linux grep +RUN git clone https://osm.etsi.org/gerrit/osm/RO.git +RUN git clone https://osm.etsi.org/gerrit/osm/devops.git +RUN git clone https://osm.etsi.org/gerrit/osm/LCM.git +RUN git clone https://osm.etsi.org/gerrit/osm/NBI.git +RUN git clone https://osm.etsi.org/gerrit/osm/POL.git +RUN wget https://raw.githubusercontent.com/gdbtek/linux-cookbooks/master/libraries/util.bash + +COPY /src /src + +RUN /bin/bash scanModules.sh \ No newline at end of file diff --git a/tools/src/scanModules.sh b/tools/src/scanModules.sh new file mode 100644 index 0000000..200c63e --- /dev/null +++ b/tools/src/scanModules.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright 2019 Whitestack LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +. ./util.bash --source-only + +VNFD="vnfd-catalog" +NSD="nsd-catalog" + +> search_results.txt +> statistics.txt +echo "(pattern),(version),RO,devops,NBI,POL,LCM" &> statistics.txt + +MODULES=("RO" "devops" "NBI" "POL" "LCM") + +grep -r --exclude=*.txt $VNFD . &>> search_results.txt +grep -r --exclude=*.txt $NSD . &>> search_results.txt + +generateStatistics(){ #1: $VNFD or $NSD, 2: commit tag + STATISTICS="$1,$2" + for i in "${MODULES[@]}" + do + STATISTICS="$STATISTICS,$(grep -F ./$i/ search_results.txt | grep $1 | wc -l)" + done + echo $STATISTICS &>>statistics.txt +} + +generateStatistics $VNFD "latest" +generateStatistics $NSD "latest" + +COLOR='\033[0;31m' +echo -e "${COLOR}-- Number of ocurrences of a pattern in each module for a specific version --" + +printTable ',' "$(cat statistics.txt)" true