From f8c3a52f51f90c52720774b2b5e28f4357ae7de6 Mon Sep 17 00:00:00 2001
From: Waleed Akbar <wakbar@cttc.es>
Date: Thu, 18 Jul 2024 10:28:33 +0000
Subject: [PATCH] changes for integration with TFS (service is running)

---
 deploy/tfs.sh                                 |  2 +-
 manifests/kpi_managerservice.yaml             | 28 +++++++++----------
 src/kpi_manager/service/KpiManagerService.py  |  2 +-
 .../service/KpiManagerServiceServicerImpl.py  |  2 +-
 src/kpi_manager/service/__main__.py           |  3 +-
 5 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/deploy/tfs.sh b/deploy/tfs.sh
index 04895f984..f85e9bbc9 100755
--- a/deploy/tfs.sh
+++ b/deploy/tfs.sh
@@ -27,7 +27,7 @@ export TFS_REGISTRY_IMAGES=${TFS_REGISTRY_IMAGES:-"http://localhost:32000/tfs/"}
 
 # If not already set, set the list of components, separated by spaces, you want to build images for, and deploy.
 # By default, only basic components are deployed
-export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device ztp monitoring pathcomp service slice nbi webui load_generator"}
+export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device ztp monitoring pathcomp service slice nbi webui load_generator kpi_manager"}
 
 # If not already set, set the tag you want to use for your images.
 export TFS_IMAGE_TAG=${TFS_IMAGE_TAG:-"dev"}
diff --git a/manifests/kpi_managerservice.yaml b/manifests/kpi_managerservice.yaml
index 45ee77895..3e106fd92 100644
--- a/manifests/kpi_managerservice.yaml
+++ b/manifests/kpi_managerservice.yaml
@@ -15,26 +15,26 @@
 apiVersion: apps/v1
 kind: Deployment
 metadata:
-  name: kpi_managerservice
+  name: kpi-managerservice
 spec:
   selector:
     matchLabels:
-      app: kpi_managerservice
+      app: kpi-managerservice
   #replicas: 1
   template:
     metadata:
       annotations:
         config.linkerd.io/skip-outbound-ports: "4222"
       labels:
-        app: kpi_managerservice
+        app: kpi-managerservice
     spec:
       terminationGracePeriodSeconds: 5
       containers:
         - name: server
-          image: labs.etsi.org:5050/tfs/controller/context:latest
+          image: labs.etsi.org:5050/tfs/controller/kpi_manager:latest
           imagePullPolicy: Always
           ports:
-            - containerPort: 7071
+            - containerPort: 30010
             - containerPort: 9192
           env:
             - name: LOG_LEVEL
@@ -44,10 +44,10 @@ spec:
                 name: crdb-data
           readinessProbe:
             exec:
-              command: ["/bin/grpc_health_probe", "-addr=:7071"]
+              command: ["/bin/grpc_health_probe", "-addr=:30010"]
           livenessProbe:
             exec:
-              command: ["/bin/grpc_health_probe", "-addr=:7071"]
+              command: ["/bin/grpc_health_probe", "-addr=:30010"]
           resources:
             requests:
               cpu: 250m
@@ -59,18 +59,18 @@ spec:
 apiVersion: v1
 kind: Service
 metadata:
-  name: kpi_managerservice
+  name: kpi-managerservice
   labels:
-    app: kpi_managerservice
+    app: kpi-managerservice
 spec:
   type: ClusterIP
   selector:
-    app: kpi_managerservice
+    app: kpi-managerservice
   ports:
     - name: grpc
       protocol: TCP
-      port: 7071
-      targetPort: 7071
+      port: 30010
+      targetPort: 30010
     - name: metrics
       protocol: TCP
       port: 9192
@@ -79,12 +79,12 @@ spec:
 apiVersion: autoscaling/v2
 kind: HorizontalPodAutoscaler
 metadata:
-  name: kpi_managerservice-hpa
+  name: kpi-managerservice-hpa
 spec:
   scaleTargetRef:
     apiVersion: apps/v1
     kind: Deployment
-    name: kpi_managerservice
+    name: kpi-managerservice
   minReplicas: 1
   maxReplicas: 20
   metrics:
diff --git a/src/kpi_manager/service/KpiManagerService.py b/src/kpi_manager/service/KpiManagerService.py
index 434246a43..6c8c66393 100755
--- a/src/kpi_manager/service/KpiManagerService.py
+++ b/src/kpi_manager/service/KpiManagerService.py
@@ -14,7 +14,7 @@
 
 from common.Constants import ServiceNameEnum
 from common.Settings import get_service_port_grpc
-from monitoring.service.NameMapping import NameMapping
+from .NameMapping import NameMapping
 from common.tools.service.GenericGrpcService import GenericGrpcService
 from common.proto.kpi_manager_pb2_grpc import add_KpiManagerServiceServicer_to_server
 from kpi_manager.service.KpiManagerServiceServicerImpl import KpiManagerServiceServicerImpl
diff --git a/src/kpi_manager/service/KpiManagerServiceServicerImpl.py b/src/kpi_manager/service/KpiManagerServiceServicerImpl.py
index 2fd4e6ac8..17d8da675 100644
--- a/src/kpi_manager/service/KpiManagerServiceServicerImpl.py
+++ b/src/kpi_manager/service/KpiManagerServiceServicerImpl.py
@@ -20,7 +20,7 @@ from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_m
 from common.proto.context_pb2 import Empty
 from common.proto.kpi_manager_pb2_grpc import KpiManagerServiceServicer
 from common.proto.kpi_manager_pb2 import KpiId, KpiDescriptor, KpiDescriptorFilter, KpiDescriptorList
-from monitoring.service.NameMapping import NameMapping
+from .NameMapping import NameMapping
 from kpi_manager.database.Kpi_DB import KpiDB
 from kpi_manager.database.KpiModel import Kpi as KpiModel
 
diff --git a/src/kpi_manager/service/__main__.py b/src/kpi_manager/service/__main__.py
index ef39263ff..50b504867 100644
--- a/src/kpi_manager/service/__main__.py
+++ b/src/kpi_manager/service/__main__.py
@@ -19,8 +19,7 @@ from common.Settings import (
     ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, get_log_level, get_metrics_port,
     wait_for_environment_variables)
 from common.proto import monitoring_pb2
-from monitoring.service.EventTools import EventsDeviceCollector # import updated
-from monitoring.service.NameMapping import NameMapping          # import updated
+from .NameMapping import NameMapping          # import updated
 from .KpiManagerService import KpiManagerService
 
 terminate = threading.Event()
-- 
GitLab