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

Merge branch 'feat/310-cttc-implement-nbi-connector-to-interface-with-osm-client' into 'develop'

Resolve "(CTTC) Implement NBI connector to interface with OSM Client"

See merge request !374
parents d5b61df7 4cc250f3
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -113,3 +113,10 @@ spec:
                name: nbiservice
                port:
                  number: 8080
          - path: /()(osm-api/.*)
            pathType: Prefix
            backend:
              service:
                name: nbiservice
                port:
                  number: 8080
+16 −6
Original line number Diff line number Diff line
@@ -15,16 +15,16 @@
apiVersion: apps/v1
kind: Deployment
metadata:
  name: osm_clientservice
  name: osm-clientservice
spec:
  selector:
    matchLabels:
      app: osm_clientservice
      app: osm-clientservice
  #replicas: 1
  template:
    metadata:
      labels:
        app: osm_clientservice
        app: osm-clientservice
    spec:
      terminationGracePeriodSeconds: 5
      containers:
@@ -37,6 +37,16 @@ spec:
          env:
            - name: OSM_ADDRESS
              value: "127.0.0.1"
            - name: OSM_PORT
              value: "80"
            - name: OSM_USERNAME
              value: "admin"
            - name: OSM_PASSWORD
              value: "admin"
            - name: OSM_PROJECT
              value: "admin"
            - name: OSM_VERIFY_TLS
              value: "FALSE"
            - name: LOG_LEVEL
              value: "INFO"
          readinessProbe:
@@ -56,13 +66,13 @@ spec:
apiVersion: v1
kind: Service
metadata:
  name: osm_clientservice
  name: osm-clientservice
  labels:
    app: osm_clientservice
    app: osm-clientservice
spec:
  type: ClusterIP
  selector:
    app: osm_clientservice
    app: osm-clientservice
  ports:
    - name: grpc
      protocol: TCP
+3 −0
Original line number Diff line number Diff line
@@ -68,6 +68,9 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui"
# Uncomment to activate VNT Manager
#export TFS_COMPONENTS="${TFS_COMPONENTS} vnt_manager"

# Uncomment to activate OSM Client
#export TFS_COMPONENTS="${TFS_COMPONENTS} osm_client"

# Uncomment to activate DLT and Interdomain
#export TFS_COMPONENTS="${TFS_COMPONENTS} interdomain dlt"
#if [[ "$TFS_COMPONENTS" == *"dlt"* ]]; then
+74 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2025 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.


# Pre-build Cleanup
docker ps --all --quiet | xargs --no-run-if-empty docker stop
docker container prune --force
docker ps --all --quiet | xargs --no-run-if-empty docker rm --force
docker image prune --force
docker network prune --force
docker volume prune --all --force
#docker buildx prune --force

# Build Docker images
docker buildx build -t "mock-osm-nbi:test" -f ./src/tests/tools/mock_osm_nbi/Dockerfile ./src/tests/tools/mock_osm_nbi
docker buildx build -t "osm_client:latest" -f ./src/osm_client/Dockerfile .

# Post-build Cleanup
docker image prune --force


# Deploy Mock OSM NBI and OSM Client
docker network create --driver bridge --subnet=172.254.251.0/24 --gateway=172.254.251.254 mock-osm-nbi-br

docker run --detach --name mock_osm_nbi --network=mock-osm-nbi-br --ip 172.254.251.10 --publish 80 --publish 443 \
  --env LOG_LEVEL=DEBUG --env FLASK_ENV=development \
  mock-osm-nbi:test

docker run --detach --name osm_client --network=mock-osm-nbi-br --ip 172.254.251.11 \
  --env LOG_LEVEL=DEBUG --env FLASK_ENV=development \
  --env OSM_ADDRESS=172.254.251.10 --env OSM_PORT=443 \
  osm_client:latest


# Post-deploy status
docker ps -a

while ! docker logs osm_client 2>&1 | grep -q 'Running...'; do sleep 1; done
docker logs osm_client
docker logs mock_osm_nbi


# Execute tests
docker exec -i osm_client bash -c "coverage run -m pytest --log-level=INFO --verbose osm_client/tests/test_unitary.py"
docker exec -i osm_client bash -c "coverage report --include='osm_client/*' --show-missing"


# Post-tests logs
docker logs osm_client
docker logs mock_osm_nbi


# Post-tests cleanup
docker ps --all --quiet | xargs --no-run-if-empty docker stop
docker container prune --force
docker ps --all --quiet | xargs --no-run-if-empty docker rm --force
docker image prune --force
docker network prune --force
docker volume prune --all --force
docker buildx prune --force

echo "Bye!"
+27 −0
Original line number Diff line number Diff line
#!/bin/bash
# Copyright 2022-2025 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.

########################################################################################################################
# Define your deployment settings here
########################################################################################################################

# If not already set, set the name of the Kubernetes namespace to deploy to.
export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"}

########################################################################################################################
# Automated steps start here
########################################################################################################################

kubectl --namespace $TFS_K8S_NAMESPACE logs deployment/osm-clientservice -c server
Loading