Commit 45eb72da authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Merge branch 'feat/89-cttc-extend-gnmi-openconfig-sbi-driver' into 'develop'

Resolve "(CTTC) Extend gNMI-OpenConfig SBI driver"

See merge request !172
parents 2e9f9cb2 e6fd2fe1
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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 \
    device/tests/gnmi_openconfig/test_unitary_gnmi_openconfig.py
+25 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2024 ETSI OSG/SDG TeraFlowSDN (TFS) (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 -o log_cli=true --verbose \
    device/tests/test_unitary_openconfig_arista_l2vpn.py
+2 −1
Original line number Diff line number Diff line
@@ -43,13 +43,14 @@ def json_endpoint_ids(

def json_endpoint(
        device_id : Dict, endpoint_uuid : str, endpoint_type : str, topology_id : Optional[Dict] = None,
        kpi_sample_types : List[int] = [], location : Optional[Dict] = None
        name : Optional[str] = None, kpi_sample_types : List[int] = [], location : Optional[Dict] = None
    ):

    result = {
        'endpoint_id': json_endpoint_id(device_id, endpoint_uuid, topology_id=topology_id),
        'endpoint_type': endpoint_type,
    }
    if name is not None: result['name'] = name
    if kpi_sample_types is not None and len(kpi_sample_types) > 0:
        result['kpi_sample_types'] = copy.deepcopy(kpi_sample_types)
    if location is not None:
+30 −2
Original line number Diff line number Diff line
@@ -16,9 +16,24 @@ FROM python:3.9-slim

# Install dependencies
RUN apt-get --yes --quiet --quiet update && \
    apt-get --yes --quiet --quiet install wget g++ git && \
    apt-get --yes --quiet --quiet install wget g++ git build-essential cmake libpcre2-dev python3-dev python3-cffi && \
    rm -rf /var/lib/apt/lists/*

# 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 mkdir -p /var/libyang
RUN git clone https://github.com/CESNET/libyang.git /var/libyang
WORKDIR /var/libyang
RUN git fetch
RUN git checkout v2.1.148
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

# Set Python to show logs as they occur
ENV PYTHONUNBUFFERED=0

@@ -62,17 +77,30 @@ RUN python3 -m pip install -r requirements.txt

# Add component files into working directory
WORKDIR /var/teraflow
COPY src/device/. device/
COPY src/context/__init__.py context/__init__.py
COPY src/context/client/. context/client/
COPY src/monitoring/__init__.py monitoring/__init__.py
COPY src/monitoring/client/. monitoring/client/
COPY src/device/. device/

# Clone test mock tools
RUN mkdir -p tests/tools/mock_ietf_actn_sdn_ctrl
RUN touch tests/__init__.py
RUN touch tests/tools/__init__.py
RUN touch tests/tools/mock_ietf_actn_sdn_ctrl/__init__.py
COPY src/tests/tools/mock_ietf_actn_sdn_ctrl/. tests/tools/mock_ietf_actn_sdn_ctrl/

# Clone OpenConfig YANG models
RUN mkdir -p /var/teraflow/device/service/drivers/gnmi_openconfig/git/openconfig/public
RUN mkdir -p /tmp/openconfig
RUN git clone https://github.com/openconfig/public.git /tmp/openconfig
WORKDIR /tmp/openconfig
RUN git fetch
RUN git checkout v4.4.0
RUN mv /tmp/openconfig/release /var/teraflow/device/service/drivers/gnmi_openconfig/git/openconfig/public
RUN mv /tmp/openconfig/third_party /var/teraflow/device/service/drivers/gnmi_openconfig/git/openconfig/public
RUN rm -rf /tmp/openconfig
WORKDIR /var/teraflow

# Start the service
ENTRYPOINT ["python", "-m", "device.service"]
+9 −8
Original line number Diff line number Diff line
@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.


anytree==2.8.0
APScheduler==3.10.1
bitarray==2.8.*
cryptography==36.0.2
deepdiff==6.7.*
deepmerge==1.1.*
@@ -22,26 +22,27 @@ deepmerge==1.1.*
Flask==2.1.3
Flask-HTTPAuth==4.5.0
Flask-RESTful==0.3.9
ipaddress
Jinja2==3.0.3
numpy<2.0.0
libyang==2.8.0
macaddress
ncclient==0.6.15
numpy<2.0.0
p4runtime==1.3.0
pandas==1.5.*
paramiko==2.9.2
pyang==2.6.*
git+https://github.com/robshakir/pyangbind.git
python-json-logger==2.0.2
#pytz==2021.3
#redis==4.1.2
requests==2.27.1
requests-mock==1.9.3
xmltodict==0.12.0
tabulate
ipaddress
macaddress
yattag
pyang==2.6.0
git+https://github.com/robshakir/pyangbind.git
websockets==10.4
werkzeug==2.3.7
xmltodict==0.12.0
yattag

# pip's dependency resolver does not take into account installed packages.
# p4runtime does not specify the version of grpcio/protobuf it needs, so it tries to install latest one
Loading