diff --git a/my_deploy.sh b/my_deploy.sh index 7cf57a6cb01840ec7414de7cf378b7ddf968a5b7..ee17cb3679f6390115917a005cfaf670585c28c7 100755 --- a/my_deploy.sh +++ b/my_deploy.sh @@ -20,7 +20,7 @@ export TFS_REGISTRY_IMAGES="http://localhost:32000/tfs/" # Set the list of components, separated by spaces, you want to build images for, and deploy. -export TFS_COMPONENTS="context device app pathcomp service slice nbi webui load_generator" +export TFS_COMPONENTS="context device pathcomp service slice nbi webui load_generator" # Uncomment to activate Monitoring (old) #export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring" @@ -29,7 +29,7 @@ export TFS_COMPONENTS="context device app pathcomp service slice nbi webui load_ #export TFS_COMPONENTS="${TFS_COMPONENTS} kpi_manager kpi_value_writer kpi_value_api" # Uncomment to activate BGP-LS Speaker -export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker" +#export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker" # Uncomment to activate Optical Controller # To manage optical connections, "service" requires "opticalcontroller" to be deployed @@ -71,7 +71,14 @@ export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker" #fi # Uncomment to activate QKD App -#export TFS_COMPONENTS="${TFS_COMPONENTS} app" +# To manage QKD Apps, "service" requires "qkd_app" to be deployed +# before "service", thus we "hack" the TFS_COMPONENTS environment variable prepending the +# "qkd_app" only if "service" is already in TFS_COMPONENTS, and re-export it. +#if [[ "$TFS_COMPONENTS" == *"service"* ]]; then +# BEFORE="${TFS_COMPONENTS% service*}" +# AFTER="${TFS_COMPONENTS#* service}" +# export TFS_COMPONENTS="${BEFORE} qkd_app service ${AFTER}" +#fi # Set the tag you want to use for your images. @@ -115,7 +122,6 @@ export CRDB_PASSWORD="tfs123" # Set the database name to be used by Context. export CRDB_DATABASE="tfs" -export CRDB_DATABASE_APP="tfs_app" # Set CockroachDB installation mode to 'single'. This option is convenient for development and testing. # See ./deploy/all.sh or ./deploy/crdb.sh for additional details diff --git a/src/qkd_app/__main__.py b/src/qkd_app/__main__.py index db09b91f852e02bff2e08fe6606027d8d3c75fbc..ed7e554728eb2de6240dd4facb7f084337a026a4 100644 --- a/src/qkd_app/__main__.py +++ b/src/qkd_app/__main__.py @@ -14,15 +14,15 @@ import logging, signal, sys, threading from prometheus_client import start_http_server -from common.Constants import ServiceNameEnum +#from common.Constants import ServiceNameEnum 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) + #ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, get_env_var_name, + get_log_level, get_metrics_port, wait_for_environment_variables) from qkd_app.service.QKDAppService import AppService from qkd_app.service.rest_server.RestServer import RestServer from qkd_app.service.rest_server.qkd_app import register_qkd_app -from common.message_broker.Factory import get_messagebroker_backend -from common.message_broker.MessageBroker import MessageBroker +#from common.message_broker.Factory import get_messagebroker_backend +#from common.message_broker.MessageBroker import MessageBroker from qkd_app.service.database.Engine import Engine from qkd_app.service.database.models._Base import rebuild_database @@ -41,8 +41,8 @@ def main(): LOGGER = logging.getLogger(__name__) wait_for_environment_variables([ - get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST ), - get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), + #get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_HOST ), + #get_env_var_name(ServiceNameEnum.CONTEXT, ENVVAR_SUFIX_SERVICE_PORT_GRPC), ]) signal.signal(signal.SIGINT, signal_handler) diff --git a/src/qkd_app/service/QKDAppServiceServicerImpl.py b/src/qkd_app/service/QKDAppServiceServicerImpl.py index ceda50029ea7acb014fba4bcbf87641edba919bb..df7a885c47eda9d7a6137c9905388da49c698e7e 100644 --- a/src/qkd_app/service/QKDAppServiceServicerImpl.py +++ b/src/qkd_app/service/QKDAppServiceServicerImpl.py @@ -13,7 +13,7 @@ # limitations under the License. import grpc, logging, sqlalchemy -from typing import Iterator, Optional +#from typing import Iterator, Optional from common.message_broker.MessageBroker import MessageBroker import grpc, json, logging #, deepdiff from common.proto.context_pb2 import ( @@ -21,20 +21,20 @@ from common.proto.context_pb2 import ( from common.proto.qkd_app_pb2 import (App, AppId, AppList, QKDAppTypesEnum) from common.proto.qkd_app_pb2_grpc import AppServiceServicer from common.method_wrappers.Decorator import MetricsPool, safe_and_metered_rpc_method -from common.tools.context_queries.InterDomain import is_inter_domain #, is_multi_domain -from common.tools.grpc.ConfigRules import copy_config_rules -from common.tools.grpc.Constraints import copy_constraints -from common.tools.grpc.EndPointIds import copy_endpoint_ids -from common.tools.grpc.ServiceIds import update_service_ids +#from common.tools.context_queries.InterDomain import is_inter_domain #, is_multi_domain +#from common.tools.grpc.ConfigRules import copy_config_rules +#from common.tools.grpc.Constraints import copy_constraints +#from common.tools.grpc.EndPointIds import copy_endpoint_ids +#from common.tools.grpc.ServiceIds import update_service_ids #from common.tools.grpc.Tools import grpc_message_to_json_string -from context.client.ContextClient import ContextClient -from qkd_app.client.QKDAppClient import QKDAppClient +#from context.client.ContextClient import ContextClient +#from qkd_app.client.QKDAppClient import QKDAppClient from .database.QKDApp import app_set, app_list_objs, app_get, app_get_by_server from common.method_wrappers.ServiceExceptions import NotFoundException LOGGER = logging.getLogger(__name__) -METRICS_POOL = MetricsPool('App', 'RPC') +METRICS_POOL = MetricsPool('QkdApp', 'RPC') # Optare: This file must be edited based on app's logic diff --git a/src/qkd_app/service/database/__init__.py b/src/qkd_app/service/database/__init__.py index b6826c7c5b10c9f427bdc50267bedfdb4ba7cb92..07d08814021ef82220611ee21c01ba01806682e9 100644 --- a/src/qkd_app/service/database/__init__.py +++ b/src/qkd_app/service/database/__init__.py @@ -10,4 +10,4 @@ # 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. \ No newline at end of file +# limitations under the License. diff --git a/src/qkd_app/service/database/models/__init__.py b/src/qkd_app/service/database/models/__init__.py index b6826c7c5b10c9f427bdc50267bedfdb4ba7cb92..07d08814021ef82220611ee21c01ba01806682e9 100644 --- a/src/qkd_app/service/database/models/__init__.py +++ b/src/qkd_app/service/database/models/__init__.py @@ -10,4 +10,4 @@ # 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. \ No newline at end of file +# limitations under the License. diff --git a/src/qkd_app/service/database/uuids/QKDApp.py b/src/qkd_app/service/database/uuids/QKDApp.py index acc31250ac187cd73f9106a4e83ffdc67f8e6b60..175f1d5f3cf4ceda12a022b4afadb376e11ae5a5 100644 --- a/src/qkd_app/service/database/uuids/QKDApp.py +++ b/src/qkd_app/service/database/uuids/QKDApp.py @@ -1,3 +1,17 @@ +# 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. + from common.proto.qkd_app_pb2 import AppId from common.method_wrappers.ServiceExceptions import InvalidArgumentsException from ._Builder import get_uuid_from_string, get_uuid_random diff --git a/src/qkd_app/service/rest_server/__init__.py b/src/qkd_app/service/rest_server/__init__.py index b6826c7c5b10c9f427bdc50267bedfdb4ba7cb92..07d08814021ef82220611ee21c01ba01806682e9 100644 --- a/src/qkd_app/service/rest_server/__init__.py +++ b/src/qkd_app/service/rest_server/__init__.py @@ -10,4 +10,4 @@ # 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. \ No newline at end of file +# limitations under the License. diff --git a/src/service/Dockerfile b/src/service/Dockerfile index cfb9900ae000ef8e542fc9bb4a208b5609057164..6f23f0a89387e2db3802ee20e003ccb6482844ff 100644 --- a/src/service/Dockerfile +++ b/src/service/Dockerfile @@ -70,8 +70,8 @@ COPY src/pathcomp/frontend/__init__.py pathcomp/frontend/__init__.py COPY src/pathcomp/frontend/client/. pathcomp/frontend/client/ COPY src/e2e_orchestrator/__init__.py e2e_orchestrator/__init__.py COPY src/e2e_orchestrator/client/. e2e_orchestrator/client/ -COPY src/app/__init__.py app/__init__.py -COPY src/app/client/. app/client/ +COPY src/qkd_app/__init__.py qkd_app/__init__.py +COPY src/qkd_app/client/. qkd_app/client/ COPY src/service/. service/ # Start the service diff --git a/src/service/service/__main__.py b/src/service/service/__main__.py index 9e7e7b46bb2e8bc4242e795250b6162c730951d5..5f9f2fa3afb2b708068423f70f764ffc61d29d9c 100644 --- a/src/service/service/__main__.py +++ b/src/service/service/__main__.py @@ -44,9 +44,8 @@ def main(): get_env_var_name(ServiceNameEnum.DEVICE, ENVVAR_SUFIX_SERVICE_PORT_GRPC), get_env_var_name(ServiceNameEnum.PATHCOMP, ENVVAR_SUFIX_SERVICE_HOST ), get_env_var_name(ServiceNameEnum.PATHCOMP, ENVVAR_SUFIX_SERVICE_PORT_GRPC), - get_env_var_name(ServiceNameEnum.APP, ENVVAR_SUFIX_SERVICE_HOST ), - get_env_var_name(ServiceNameEnum.APP, ENVVAR_SUFIX_SERVICE_PORT_GRPC), - + get_env_var_name(ServiceNameEnum.QKD_APP, ENVVAR_SUFIX_SERVICE_HOST ), + get_env_var_name(ServiceNameEnum.QKD_APP, ENVVAR_SUFIX_SERVICE_PORT_GRPC), ]) signal.signal(signal.SIGINT, signal_handler) @@ -75,4 +74,4 @@ def main(): return 0 if __name__ == '__main__': - sys.exit(main()) \ No newline at end of file + sys.exit(main()) diff --git a/src/service/service/task_scheduler/TaskExecutor.py b/src/service/service/task_scheduler/TaskExecutor.py index cff9d3aaa6233ce1e189d81e5147c4ed7c014099..f7287f35231a3f42eb080eeabad12b28c583df07 100644 --- a/src/service/service/task_scheduler/TaskExecutor.py +++ b/src/service/service/task_scheduler/TaskExecutor.py @@ -46,7 +46,7 @@ class CacheableObjectType(Enum): CONNECTION = 'connection' DEVICE = 'device' SERVICE = 'service' - APP = 'app' + QKD_APP = 'qkd-app' class TaskExecutor: def __init__(self, service_handler_factory : ServiceHandlerFactory) -> None: @@ -227,10 +227,10 @@ class TaskExecutor: ) - # ----- App-related methods --------------------------------------------------------------------------------------- + # ----- QkdApp-related methods ------------------------------------------------------------------------------------- def register_app(self, app: App) -> None: app_key = get_app_key(app.app_id) self._qkd_app_client.RegisterApp(app) LOGGER.info("reg registered") - self._store_grpc_object(CacheableObjectType.APP, app_key, app) \ No newline at end of file + self._store_grpc_object(CacheableObjectType.QKD_APP, app_key, app)