Loading install_requirements.sh +16 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,22 @@ ALL_COMPONENTS="${ALL_COMPONENTS} dbscanserving opticalattackmitigator opticalat ALL_COMPONENTS="${ALL_COMPONENTS} l3_attackmitigator l3_centralizedattackdetector l3_distributedattackdetector" TFS_COMPONENTS=${TFS_COMPONENTS:-$ALL_COMPONENTS} # Some components require libyang built from source code # - Ref: https://github.com/CESNET/libyang # - Ref: https://github.com/CESNET/libyang-python/ echo "Installing libyang..." sudo apt-get --yes --quiet --quiet update sudo apt-get --yes --quiet --quiet install build-essential cmake libpcre2-dev python3-dev python3-cffi mkdir libyang git clone https://github.com/CESNET/libyang.git libyang mkdir libyang/build cd libyang/build cmake -D CMAKE_BUILD_TYPE:String="Release" .. make sudo make install sudo ldconfig cd ../.. echo "Updating PIP, SetupTools and Wheel..." pip install --upgrade pip # ensure next packages get the latest versions pip install --upgrade setuptools wheel # bring basic tooling for other requirements Loading scripts/run_tests_locally-nbi-ietf-l3vpn.sh 0 → 100755 +25 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) # # 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. PROJECTDIR=`pwd` cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time # helpful pytest flags: --log-level=INFO -o log_cli=true --verbose --maxfail=1 --durations=0 coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ nbi/tests/test_ietf_l3vpn.py src/nbi/.gitlab-ci.yml +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ unit_test nbi: - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_ietf_l2vpn.py --junitxml=/opt/results/${IMAGE_NAME}_report_ietf_l2vpn.xml" - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_ietf_network.py --junitxml=/opt/results/${IMAGE_NAME}_report_ietf_network.xml" - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_ietf_l3vpn.py --junitxml=/opt/results/${IMAGE_NAME}_report_ietf_l3vpn.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: Loading src/nbi/Dockerfile +15 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,21 @@ RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto RUN rm *.proto RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \; # Download, build and install libyang. Note that APT package is outdated # - Ref: https://github.com/CESNET/libyang # - Ref: https://github.com/CESNET/libyang-python/ RUN apt-get --yes --quiet --quiet update && \ apt-get --yes --quiet --quiet install build-essential cmake libpcre2-dev python3-dev python3-cffi && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/libyang RUN git clone https://github.com/CESNET/libyang.git /var/libyang RUN mkdir -p /var/libyang/build WORKDIR /var/libyang/build RUN cmake -D CMAKE_BUILD_TYPE:String="Release" .. RUN make RUN make install RUN ldconfig # Create component sub-folders, get specific Python packages RUN mkdir -p /var/teraflow/nbi WORKDIR /var/teraflow/nbi Loading src/nbi/README.md 0 → 100644 +32 −0 Original line number Diff line number Diff line # NBI Component The NBI component uses libyang to validate and process messages. Follow instructions below to install it. ## Install libyang - Ref: https://github.com/CESNET/libyang - Ref: https://github.com/CESNET/libyang-python/ __NOTE__: APT package is extremely outdated and does not work for our purposes. ### Build Requisites ```bash sudo apt-get install build-essential cmake libpcre2-dev sudo apt-get install python3-dev gcc python3-cffi ``` ### Build from source ```bash mkdir ~/tfs-ctrl/libyang git clone https://github.com/CESNET/libyang.git ~/tfs-ctrl/libyang mkdir ~/tfs-ctrl/libyang/build cd ~/tfs-ctrl/libyang/build cmake -D CMAKE_BUILD_TYPE:String="Release" .. make sudo make install sudo ldconfig ``` ### Install Python bindings ```bash pip install libyang==2.8.0 ``` Loading
install_requirements.sh +16 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,22 @@ ALL_COMPONENTS="${ALL_COMPONENTS} dbscanserving opticalattackmitigator opticalat ALL_COMPONENTS="${ALL_COMPONENTS} l3_attackmitigator l3_centralizedattackdetector l3_distributedattackdetector" TFS_COMPONENTS=${TFS_COMPONENTS:-$ALL_COMPONENTS} # Some components require libyang built from source code # - Ref: https://github.com/CESNET/libyang # - Ref: https://github.com/CESNET/libyang-python/ echo "Installing libyang..." sudo apt-get --yes --quiet --quiet update sudo apt-get --yes --quiet --quiet install build-essential cmake libpcre2-dev python3-dev python3-cffi mkdir libyang git clone https://github.com/CESNET/libyang.git libyang mkdir libyang/build cd libyang/build cmake -D CMAKE_BUILD_TYPE:String="Release" .. make sudo make install sudo ldconfig cd ../.. echo "Updating PIP, SetupTools and Wheel..." pip install --upgrade pip # ensure next packages get the latest versions pip install --upgrade setuptools wheel # bring basic tooling for other requirements Loading
scripts/run_tests_locally-nbi-ietf-l3vpn.sh 0 → 100755 +25 −0 Original line number Diff line number Diff line #!/bin/bash # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) # # 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. PROJECTDIR=`pwd` cd $PROJECTDIR/src RCFILE=$PROJECTDIR/coverage/.coveragerc # Run unitary tests and analyze coverage of code at same time # helpful pytest flags: --log-level=INFO -o log_cli=true --verbose --maxfail=1 --durations=0 coverage run --rcfile=$RCFILE --append -m pytest --log-level=INFO --verbose \ nbi/tests/test_ietf_l3vpn.py
src/nbi/.gitlab-ci.yml +1 −0 Original line number Diff line number Diff line Loading @@ -68,6 +68,7 @@ unit_test nbi: - docker logs $IMAGE_NAME - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_ietf_l2vpn.py --junitxml=/opt/results/${IMAGE_NAME}_report_ietf_l2vpn.xml" - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_ietf_network.py --junitxml=/opt/results/${IMAGE_NAME}_report_ietf_network.xml" - docker exec -i $IMAGE_NAME bash -c "coverage run --append -m pytest --log-level=INFO --verbose $IMAGE_NAME/tests/test_ietf_l3vpn.py --junitxml=/opt/results/${IMAGE_NAME}_report_ietf_l3vpn.xml" - docker exec -i $IMAGE_NAME bash -c "coverage report --include='${IMAGE_NAME}/*' --show-missing" coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' after_script: Loading
src/nbi/Dockerfile +15 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,21 @@ RUN python3 -m grpc_tools.protoc -I=. --python_out=. --grpc_python_out=. *.proto RUN rm *.proto RUN find . -type f -exec sed -i -E 's/(import\ .*)_pb2/from . \1_pb2/g' {} \; # Download, build and install libyang. Note that APT package is outdated # - Ref: https://github.com/CESNET/libyang # - Ref: https://github.com/CESNET/libyang-python/ RUN apt-get --yes --quiet --quiet update && \ apt-get --yes --quiet --quiet install build-essential cmake libpcre2-dev python3-dev python3-cffi && \ rm -rf /var/lib/apt/lists/* RUN mkdir -p /var/libyang RUN git clone https://github.com/CESNET/libyang.git /var/libyang RUN mkdir -p /var/libyang/build WORKDIR /var/libyang/build RUN cmake -D CMAKE_BUILD_TYPE:String="Release" .. RUN make RUN make install RUN ldconfig # Create component sub-folders, get specific Python packages RUN mkdir -p /var/teraflow/nbi WORKDIR /var/teraflow/nbi Loading
src/nbi/README.md 0 → 100644 +32 −0 Original line number Diff line number Diff line # NBI Component The NBI component uses libyang to validate and process messages. Follow instructions below to install it. ## Install libyang - Ref: https://github.com/CESNET/libyang - Ref: https://github.com/CESNET/libyang-python/ __NOTE__: APT package is extremely outdated and does not work for our purposes. ### Build Requisites ```bash sudo apt-get install build-essential cmake libpcre2-dev sudo apt-get install python3-dev gcc python3-cffi ``` ### Build from source ```bash mkdir ~/tfs-ctrl/libyang git clone https://github.com/CESNET/libyang.git ~/tfs-ctrl/libyang mkdir ~/tfs-ctrl/libyang/build cd ~/tfs-ctrl/libyang/build cmake -D CMAKE_BUILD_TYPE:String="Release" .. make sudo make install sudo ldconfig ``` ### Install Python bindings ```bash pip install libyang==2.8.0 ```