Commit ebd836d3 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

NBI component:

- Updated to use gunicorn as WGSI HTTP server
- Removed gRPC client/server as it was unused
- Added WebSocket Flask-SocketIO
- Implemented Heartbeat endpoint based on WebSocket
- Other minor framework and WebUI fixes
parent e94c8d32
Loading
Loading
Loading
Loading
+14 −19
Original line number Diff line number Diff line
@@ -23,9 +23,6 @@ spec:
  replicas: 1
  template:
    metadata:
      annotations:
        config.linkerd.io/skip-inbound-ports: "8762"
        config.linkerd.io/skip-outbound-ports: "8762"
      labels:
        app: nbiservice
    spec:
@@ -36,22 +33,28 @@ spec:
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
            - containerPort: 9090
            - containerPort: 9192
            - containerPort: 8761
          env:
            - name: LOG_LEVEL
              value: "INFO"
            - name: FLASK_ENV
              value: "production"  # change to "development" if developing
            - name: IETF_NETWORK_RENDERER
              value: "LIBYANG"
            - name: WS_IP_PORT
              value: "8761"
          readinessProbe:
            exec:
              command: ["/bin/grpc_health_probe", "-addr=:9090"]
            httpGet:
              path: /healthz
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 10
            failureThreshold: 3
          livenessProbe:
            exec:
              command: ["/bin/grpc_health_probe", "-addr=:9090"]
            httpGet:
              path: /healthz
              port: 8080
            initialDelaySeconds: 5
            periodSeconds: 10
            failureThreshold: 3
          resources:
            requests:
              cpu: 50m
@@ -75,15 +78,7 @@ spec:
      protocol: TCP
      port: 8080
      targetPort: 8080
    - name: grpc
      protocol: TCP
      port: 9090
      targetPort: 9090
    - name: metrics
      protocol: TCP
      port: 9192
      targetPort: 9192
    - name: websocket
      protocol: TCP
      port: 8761
      targetPort: 8761

proto/nbi.proto

deleted100644 → 0
+0 −28
Original line number Diff line number Diff line
// Copyright 2022-2024 ETSI 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.

syntax = "proto3";
package nbi;

import "context.proto";

service NbiService {
  rpc CheckCredentials                 (context.TeraFlowController) returns (context.AuthenticationResult) {}
  rpc GetConnectivityServiceStatus     (context.ServiceId         ) returns (context.ServiceStatus       ) {}
  rpc CreateConnectivityService        (context.Service           ) returns (context.ServiceId           ) {}
  rpc EditConnectivityService          (context.Service           ) returns (context.ServiceId           ) {}
  rpc DeleteConnectivityService        (context.Service           ) returns (context.Empty               ) {}
  rpc GetAllActiveConnectivityServices (context.Empty             ) returns (context.ServiceIdList       ) {}
  rpc ClearAllConnectivityServices     (context.Empty             ) returns (context.Empty               ) {}
}
+0 −1
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@ DEFAULT_SERVICE_GRPC_PORTS = {
    ServiceNameEnum.POLICY                 .value :  6060,
    ServiceNameEnum.MONITORING             .value :  7070,
    ServiceNameEnum.DLT                    .value :  8080,
    ServiceNameEnum.NBI                    .value :  9090,
    ServiceNameEnum.L3_CAD                 .value : 10001,
    ServiceNameEnum.L3_AM                  .value : 10002,
    ServiceNameEnum.DBSCANSERVING          .value : 10008,
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ unit_test nbi:
      fi
  script:
    - docker pull "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
    - docker run --name $IMAGE_NAME -d -p 9090:9090 -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - docker run --name $IMAGE_NAME -d -v "$PWD/src/$IMAGE_NAME/tests:/opt/results" --network=teraflowbridge $CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG
    - sleep 5
    - docker ps -a
    - docker logs $IMAGE_NAME
+3 −14
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ FROM python:3.9-slim

# Install dependencies
RUN apt-get --yes --quiet --quiet update && \
    apt-get --yes --quiet --quiet install wget g++ git build-essential cmake libpcre2-dev python3-dev python3-cffi && \
    apt-get --yes --quiet --quiet install 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
@@ -37,23 +37,11 @@ RUN ldconfig
# Set Python to show logs as they occur
ENV PYTHONUNBUFFERED=0

# Download the gRPC health probe
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.0 && \
    wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-amd64 && \
    chmod +x /bin/grpc_health_probe

# Get generic Python packages
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade setuptools wheel
RUN python3 -m pip install --upgrade pip-tools

# Get common Python packages
# Note: this step enables sharing the previous Docker build steps among all the Python components
WORKDIR /var/teraflow
COPY common_requirements.in common_requirements.in
RUN pip-compile --quiet --output-file=common_requirements.txt common_requirements.in
RUN python3 -m pip install -r common_requirements.txt

# Add common files into working directory
WORKDIR /var/teraflow/common
COPY src/common/. ./
@@ -94,4 +82,5 @@ RUN mkdir -p /var/teraflow/tests/tools
COPY src/tests/tools/mock_osm/. tests/tools/mock_osm/

# Start the service
ENTRYPOINT ["python", "-m", "nbi.service"]
#ENTRYPOINT ["gunicorn", "-w", "4", "--worker-class", "eventlet", "-b", "0.0.0.0:8080", "nbi.service:nbi_app"]
ENTRYPOINT ["gunicorn", "-w", "4", "--worker-class", "geventwebsocket.gunicorn.workers.GeventWebSocketWorker", "-b", "0.0.0.0:8080", "nbi.service.app:nbi_app"]
Loading