Commit e60ee186 authored by Andrea Sgambelluri's avatar Andrea Sgambelluri
Browse files

Merge branch 'develop' of https://labs.etsi.org/rep/tfs/controller into cnit_ofc26

parents 1d230e86 26f5a3cf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ import grpc, logging
from common.Constants import ServiceNameEnum
from common.Settings import get_service_host, get_service_port_grpc
from common.proto.automation_pb2_grpc import AutomationServiceStub
from common.proto.automation_pb2 import ZSMCreateRequest, ZSMService, ZSMServiceID, ZSMServiceState
from common.proto.automation_pb2 import ZSMCreateRequest, ZSMService
from common.tools.client.RetryDecorator import retry, delay_exponential
from common.tools.grpc.Tools import grpc_message_to_json_string

+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import grpc, logging, uuid
import grpc, logging
from common.Constants import ServiceNameEnum
from common.Settings import get_service_host, get_service_port_grpc
from common.proto.policy_pb2 import PolicyRuleService, PolicyRuleState
+14 −13
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
# limitations under the License.

import grpc, logging
from uuid import uuid4
from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method
from common.proto.automation_pb2_grpc import AutomationServiceServicer
from common.method_wrappers.ServiceExceptions import NotFoundException
@@ -23,7 +22,7 @@ from automation.service.database.AutomationDB import AutomationDB
from automation.service.database.AutomationModel import AutomationModel
from automation.service.zsm_handlers import ZSM_SERVICE_HANDLERS
from automation.service.zsm_handler_api.ZSMFilterFields import (
    ZSMFilterFieldEnum, #TELEMETRY_SERVICE_TYPE_VALUES, TARGET_SERVICE_TYPE_VALUES,
    ZSMFilterFieldEnum,
    ZSM_FILTER_FIELD_ALLOWED_VALUES
)
from context.client.ContextClient import ContextClient
@@ -48,17 +47,19 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
            targetService.service_type, telemetryService.service_type, ZSM_SERVICE_HANDLERS
        )

        response = None
        if handler_cls:
            handler_obj = handler_cls()  # instantiate it
            handler_obj.zsmCreate(request, context)
            response = handler_obj.zsmCreate(request, context)
        else:
            LOGGER.info("No matching handler found.")
            LOGGER.info("No matching handler found")

        response = ZSMService()
        automation_id = str(uuid4())
        zsm_to_insert = AutomationModel.convert_Automation_to_row(automation_id , "Test Description")
        if self.automation_db_obj.add_row_to_db(zsm_to_insert):
            response.zsmServiceId.uuid.uuid = automation_id
        zsm_to_insert = AutomationModel.convert_Automation_to_row(
            response.zsmServiceId.uuid.uuid, "ZSM service"
        )
        if not self.automation_db_obj.add_row_to_db(zsm_to_insert):
            LOGGER.error("Failed to insert new ZSM service")
            return response

        return response

@@ -76,7 +77,7 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):

        zsmServiceState  = ZSMServiceState()
        zsmServiceState.zsmServiceState = 5
        zsmServiceState.zsmServiceStateMessage = "Removed id: {:}".format(request)
        zsmServiceState.zsmServiceStateMessage = "Removed ZSM ID: {:}".format(request)

        return zsmServiceState

@@ -86,14 +87,14 @@ class AutomationServiceServicerImpl(AutomationServiceServicer):
        zsm_id_to_search = request.uuid.uuid
        row = self.automation_db_obj.search_db_row_by_id(AutomationModel, 'zsm_id', zsm_id_to_search)
        if row is None:
            LOGGER.info('No matching row found zsm id: {:}'.format(zsm_id_to_search))
            raise NotFoundException('ZsmID', zsm_id_to_search)
            LOGGER.info('No matching row found for ZSM ID: {:}'.format(zsm_id_to_search))
            raise NotFoundException('ZSM ID', zsm_id_to_search)
        response = AutomationModel.convert_row_to_Automation(row)
        return response

    @safe_and_metered_rpc_method(METRICS_POOL,LOGGER)
    def ZSMGetByService(self, request : ServiceId, context : grpc.ServicerContext) -> ZSMService:
        LOGGER.info('NOT IMPLEMENTED ZSMGetByService')
        LOGGER.info('ZSMGetByService is not implemented')
        return ZSMService()

    def get_service_handler_based_on_service_types(
+0 −3
Original line number Diff line number Diff line
@@ -14,7 +14,6 @@

import logging, signal, sys, threading
from prometheus_client import start_http_server
# from automation.service.EventEngine import EventEngine
from common.Constants import ServiceNameEnum
from common.Settings import (
    ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC,
@@ -22,8 +21,6 @@ from common.Settings import (
    wait_for_environment_variables
)
from .AutomationService import AutomationService
# from common.tools.database.GenericDatabase import Database
# from automation.service.database.AutomationModel import AutomationModel
from .database.Engine import Engine
from .database.models._Base import rebuild_database

+0 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@
import logging
from common.method_wrappers.Decorator import MetricsPool
from common.tools.database.GenericDatabase import Database
from common.method_wrappers.ServiceExceptions import OperationFailedException

LOGGER = logging.getLogger(__name__)
METRICS_POOL = MetricsPool('Automation', 'Database')
Loading