diff --git a/my_deploy.sh b/my_deploy.sh index 88be82b63e9e79a97ee79702de886f69a6152f94..cd07c078b62a858d76bcc1947146003649735ffc 100755 --- a/my_deploy.sh +++ b/my_deploy.sh @@ -28,6 +28,9 @@ export TFS_COMPONENTS="context device pathcomp service slice nbi webui load_gene # Uncomment to activate Monitoring Framework (new) #export TFS_COMPONENTS="${TFS_COMPONENTS} kpi_manager kpi_value_writer kpi_value_api" +# Uncomment to activate pcep +#export TFS_COMPONENTS="${TFS_COMPONENTS} pcep" + # Uncomment to activate BGP-LS Speaker #export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker" diff --git a/src/common/Constants.py b/src/common/Constants.py index 0bf1b26fe653a3976a8790e01576cce421f48c2e..c7db87a06a1c15141565bd00b57f35667e3f2fee 100644 --- a/src/common/Constants.py +++ b/src/common/Constants.py @@ -62,7 +62,6 @@ class ServiceNameEnum(Enum): E2EORCHESTRATOR = 'e2e-orchestrator' OPTICALCONTROLLER = 'opticalcontroller' BGPLS = 'bgpls-speaker' - PCEP = 'pcep' KPIMANAGER = 'kpi-manager' KPIVALUEAPI = 'kpi-value-api' KPIVALUEWRITER = 'kpi-value-writer' diff --git a/src/pcep/.gitlab-ci.yml b/src/pcep/.gitlab-ci.yml index dd861a02587ac0bf08b48cc6e603410f5386ce4c..a755aa0b5897b2189347e15ca9e34f00df8ecf6d 100644 --- a/src/pcep/.gitlab-ci.yml +++ b/src/pcep/.gitlab-ci.yml @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/Config.py b/src/pcep/Config.py index 1549d9811aa5d1c193a44ad45d0d7773236c0612..a5ccb6078c2c18285753cacb045f9614017f8485 100644 --- a/src/pcep/Config.py +++ b/src/pcep/Config.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/Dockerfile b/src/pcep/Dockerfile index 48f2db27d3da9b3caf584445246f113af24d12db..38b8cfe9ea3cd17179413bc5138310e66a5a9e28 100644 --- a/src/pcep/Dockerfile +++ b/src/pcep/Dockerfile @@ -38,7 +38,7 @@ RUN python3 -m pip install --upgrade pip-tools # Install OpenJDK-11 RUN apt-get update && \ - apt-get install -y openjdk-11-jre-headless && \ + apt-get install -y openjdk-17-jre && \ apt-get clean; # Get common Python packages diff --git a/src/pcep/__init__.py b/src/pcep/__init__.py index 1549d9811aa5d1c193a44ad45d0d7773236c0612..a5ccb6078c2c18285753cacb045f9614017f8485 100644 --- a/src/pcep/__init__.py +++ b/src/pcep/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/requirements.in b/src/pcep/requirements.in index bffe88732b108cd5da3bf6331d6a8c3056ccaf02..c65dd1942ee6f8f49b5de494e0e750470c9d3597 100644 --- a/src/pcep/requirements.in +++ b/src/pcep/requirements.in @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/PcepService.py b/src/pcep/service/PcepService.py index 744532b3b73e60ff83017349a382c885f646a6fa..04b8702d3ed7bd8697490d61c4333e32feac3d76 100644 --- a/src/pcep/service/PcepService.py +++ b/src/pcep/service/PcepService.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/PcepServiceServicerImpl.py b/src/pcep/service/PcepServiceServicerImpl.py index 4975a71dcb338d0250b0df8e9f60109377f5abff..2390d8aecd5b744fd4f74e0e769869c640ebae9e 100644 --- a/src/pcep/service/PcepServiceServicerImpl.py +++ b/src/pcep/service/PcepServiceServicerImpl.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/__init__.py b/src/pcep/service/__init__.py index 1549d9811aa5d1c193a44ad45d0d7773236c0612..a5ccb6078c2c18285753cacb045f9614017f8485 100644 --- a/src/pcep/service/__init__.py +++ b/src/pcep/service/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/__main__.py b/src/pcep/service/__main__.py index 51972320062c545e4140c0586a4c09acf4e5adcf..4825a84b29e7f641c8c0d9a19b960fd90c3b5522 100644 --- a/src/pcep/service/__main__.py +++ b/src/pcep/service/__main__.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/resources/BGP4Parameters_2.xml b/src/pcep/service/resources/BGP4Parameters_2.xml index d7a101668f7aff256afd2b236b4d951e554e0a8e..f59ea1f3bd1c3a91ff606bbac9c4d770ce8395a2 100644 --- a/src/pcep/service/resources/BGP4Parameters_2.xml +++ b/src/pcep/service/resources/BGP4Parameters_2.xml @@ -1,4 +1,18 @@ -<?xml version="1.0" encoding="UTF-8"?> + <!-- Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. --> + + <?xml version="1.0" encoding="UTF-8"?> <config> <!-- TCP port where the BGP is listening for incoming bgp4 connections. Optional Parameter. Default value: 179 (BGP Port) --> <BGP4Port>22179</BGP4Port> diff --git a/src/pcep/service/resources/log4j2.xml b/src/pcep/service/resources/log4j2.xml index fa4ad59c9e4745a568adbaf76ab34540e73cd7f5..83a073bbcd72d872066a54f3e3204f705e021f25 100644 --- a/src/pcep/service/resources/log4j2.xml +++ b/src/pcep/service/resources/log4j2.xml @@ -1,4 +1,18 @@ -<?xml version="1.0" encoding="UTF-8"?> + <!-- Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. --> + + <?xml version="1.0" encoding="UTF-8"?> <Configuration status="DEBUG"> <Appenders> <Console name="Console" target="SYSTEM_OUT"> diff --git a/src/pcep/service/resources/topologia_ifusion.xml b/src/pcep/service/resources/topologia_ifusion.xml index 7c1f9ad3d3d039b2caf04ce7d83d1bf6eae763df..f533866869d532362971bb1c2fc177f70f191491 100644 --- a/src/pcep/service/resources/topologia_ifusion.xml +++ b/src/pcep/service/resources/topologia_ifusion.xml @@ -1,4 +1,18 @@ -<?xml version="1.0" encoding="UTF-8"?> + <!-- Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. --> + + <?xml version="1.0" encoding="UTF-8"?> <network> <domain> <layer type="mpls" ></layer> diff --git a/src/pcep/service/tools/GrpcServer.py b/src/pcep/service/tools/GrpcServer.py index eefecf6c1c4edb5aa6eaf8b94f086335ccad7291..60a77e405d9b4b970f2949ee45c701d3b5e9ed45 100644 --- a/src/pcep/service/tools/GrpcServer.py +++ b/src/pcep/service/tools/GrpcServer.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/tools/Grpc_TestClient/gRPC_PCEPClient.py b/src/pcep/service/tools/Grpc_TestClient/gRPC_PCEPClient.py index 99fe94350a7c5b0558e777d42f6025f6f59e26e6..2d233ec4895524740d6e16fd602dafb8155f93a7 100644 --- a/src/pcep/service/tools/Grpc_TestClient/gRPC_PCEPClient.py +++ b/src/pcep/service/tools/Grpc_TestClient/gRPC_PCEPClient.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/tools/Grpc_TestClient/grpcService.proto b/src/pcep/service/tools/Grpc_TestClient/grpcService.proto index ff0ac0b028d22b13f900ff37309df099c95102ac..1da1ab3efed07da3fa11eb18abbc809adfcd0df4 100644 --- a/src/pcep/service/tools/Grpc_TestClient/grpcService.proto +++ b/src/pcep/service/tools/Grpc_TestClient/grpcService.proto @@ -1,4 +1,4 @@ -// Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +// Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/tools/Grpc_TestClient/grpcService_pb2.py b/src/pcep/service/tools/Grpc_TestClient/grpcService_pb2.py index 314442ae410d645acb3fc0d113e9bfbfab41aa92..f36920a1f490d4740bfcd5fc4eef566bf0c0cccb 100644 --- a/src/pcep/service/tools/Grpc_TestClient/grpcService_pb2.py +++ b/src/pcep/service/tools/Grpc_TestClient/grpcService_pb2.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/tools/Grpc_TestClient/grpcService_pb2_grpc.py b/src/pcep/service/tools/Grpc_TestClient/grpcService_pb2_grpc.py index a2a3ca301d2e50ca92e5690d7ce1367c87da2b55..bd8ea38652573891521258d924eef68bba863500 100644 --- a/src/pcep/service/tools/Grpc_TestClient/grpcService_pb2_grpc.py +++ b/src/pcep/service/tools/Grpc_TestClient/grpcService_pb2_grpc.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/tools/Grpc_TestClient/test_gRPC_client.py b/src/pcep/service/tools/Grpc_TestClient/test_gRPC_client.py index b4eadb87768bbfff11fd2d43e4c4c086b5751c85..598165b582f0f4e23747eebb6fbcab58584d4e70 100644 --- a/src/pcep/service/tools/Grpc_TestClient/test_gRPC_client.py +++ b/src/pcep/service/tools/Grpc_TestClient/test_gRPC_client.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/tools/JavaRunner.py b/src/pcep/service/tools/JavaRunner.py index 27d090f1fdc25b245433ed118a3dd2054843648e..71a9515772cc1fd858897c22e82c4a7bdd61b440 100644 --- a/src/pcep/service/tools/JavaRunner.py +++ b/src/pcep/service/tools/JavaRunner.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/service/tools/PCEServerConfiguration.xml b/src/pcep/service/tools/PCEServerConfiguration.xml index a48b4c03bc0a512555dba403c2a63432ef65acc2..64b2ac34deb587c1298ae8f511a42734f997f8bc 100644 --- a/src/pcep/service/tools/PCEServerConfiguration.xml +++ b/src/pcep/service/tools/PCEServerConfiguration.xml @@ -1,4 +1,18 @@ -<?xml version="1.0" encoding="UTF-8"?> + <!-- Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. --> + + <?xml version="1.0" encoding="UTF-8"?> <config> <PCEServerPort>4189</PCEServerPort> <PCEManagementPort>6666</PCEManagementPort> diff --git a/src/pcep/service/tools/__init__.py b/src/pcep/service/tools/__init__.py index 1549d9811aa5d1c193a44ad45d0d7773236c0612..a5ccb6078c2c18285753cacb045f9614017f8485 100644 --- a/src/pcep/service/tools/__init__.py +++ b/src/pcep/service/tools/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/pcep/tests/__init__.py b/src/pcep/tests/__init__.py index 1549d9811aa5d1c193a44ad45d0d7773236c0612..a5ccb6078c2c18285753cacb045f9614017f8485 100644 --- a/src/pcep/tests/__init__.py +++ b/src/pcep/tests/__init__.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) +# Copyright 2022-2024 ETSI TeraFlowSDN - TFS OSG (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. diff --git a/src/service/service/service_handlers/qkd/qkd_service_handler.py b/src/service/service/service_handlers/qkd/qkd_service_handler.py index 76c67867ee2f4bae60b8dd6e187f221f2efc1eb0..be567d652ee938972a1d14ad560331db8898d172 100644 --- a/src/service/service/service_handlers/qkd/qkd_service_handler.py +++ b/src/service/service/service_handlers/qkd/qkd_service_handler.py @@ -17,7 +17,7 @@ import json, logging, uuid from typing import Any, Dict, List, Optional, Tuple, Union from common.method_wrappers.Decorator import MetricsPool, metered_subclass_method from common.proto.context_pb2 import ConfigRule, DeviceId, Service -from common.proto.app_pb2 import App, QKDAppStatusEnum, QKDAppTypesEnum +# from common.proto.app_pb2 import App, QKDAppStatusEnum, QKDAppTypesEnum from common.tools.object_factory.ConfigRule import json_config_rule_delete, json_config_rule_set from common.tools.object_factory.Device import json_device_id from common.type_checkers.Checkers import chk_type @@ -63,235 +63,235 @@ class QKDServiceHandler(_ServiceHandler): context_uuid = self.__service.service_id.context_id.context_uuid.uuid results = [] - try: + # try: - if len(endpoints) > 4: - is_virtual = True - else: - is_virtual = False + # if len(endpoints) > 4: + # is_virtual = True + # else: + # is_virtual = False - devices = [] - qkdn_ids = [] - interfaces = [] - links = [] + # devices = [] + # qkdn_ids = [] + # interfaces = [] + # links = [] - # Optare: First a big iteration through all devices is done in order to obtain all information needed for the whole operation - # Optare: This is a way to minimize time of operation. Otherwise it would require many O(N) operations. This way we can reduce it to one + # # Optare: First a big iteration through all devices is done in order to obtain all information needed for the whole operation + # # Optare: This is a way to minimize time of operation. Otherwise it would require many O(N) operations. This way we can reduce it to one - # Populate devices and QKDN ids - for idx, endpoint in enumerate(endpoints[::2]): - device_uuid, endpoint_left_uuid = get_device_endpoint_uuids(endpoint) - _, endpoint_right_uuid = get_device_endpoint_uuids(endpoints[2 * idx + 1]) + # # Populate devices and QKDN ids + # for idx, endpoint in enumerate(endpoints[::2]): + # device_uuid, endpoint_left_uuid = get_device_endpoint_uuids(endpoint) + # _, endpoint_right_uuid = get_device_endpoint_uuids(endpoints[2 * idx + 1]) - device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) - devices.append(device) - interfaces.append([0,0]) - links.append([]) + # device = self.__task_executor.get_device(DeviceId(**json_device_id(device_uuid))) + # devices.append(device) + # interfaces.append([0,0]) + # links.append([]) - endpoint_left = get_endpoint_name_by_uuid(device, endpoint_left_uuid) if idx > 0 else None - endpoint_right = get_endpoint_name_by_uuid(device, endpoint_right_uuid) if 2 * idx + 2 < len(endpoints) else None + # endpoint_left = get_endpoint_name_by_uuid(device, endpoint_left_uuid) if idx > 0 else None + # endpoint_right = get_endpoint_name_by_uuid(device, endpoint_right_uuid) if 2 * idx + 2 < len(endpoints) else None - for config_rule in device.device_config.config_rules: - resource_key = config_rule.custom.resource_key + # for config_rule in device.device_config.config_rules: + # resource_key = config_rule.custom.resource_key - if resource_key == '__node__': - value = json.loads(config_rule.custom.resource_value) - qkdn_ids.append(value['qkdn_id']) + # if resource_key == '__node__': + # value = json.loads(config_rule.custom.resource_value) + # qkdn_ids.append(value['qkdn_id']) - elif resource_key.startswith('/interface'): - value = json.loads(config_rule.custom.resource_value) - try: - endpoint_str = value['qkdi_att_point']['uuid'] - LOGGER.info("A: " + str(endpoint_str) + "....." + str(endpoint_left) + "....." + str(endpoint_right)) - - if endpoint_str == endpoint_left: - interfaces[idx][0] = value['qkdi_id'] - elif endpoint_str == endpoint_right: - interfaces[idx][1] = value['qkdi_id'] - except KeyError: - pass + # elif resource_key.startswith('/interface'): + # value = json.loads(config_rule.custom.resource_value) + # try: + # endpoint_str = value['qkdi_att_point']['uuid'] + # LOGGER.info("A: " + str(endpoint_str) + "....." + str(endpoint_left) + "....." + str(endpoint_right)) + + # if endpoint_str == endpoint_left: + # interfaces[idx][0] = value['qkdi_id'] + # elif endpoint_str == endpoint_right: + # interfaces[idx][1] = value['qkdi_id'] + # except KeyError: + # pass - elif resource_key.startswith('/link'): - value = json.loads(config_rule.custom.resource_value) - links[idx].append(( value['uuid'], - (value['src_qkdn_id'], value['src_interface_id']), - (value['dst_qkdn_id'], value['dst_interface_id']) - )) + # elif resource_key.startswith('/link'): + # value = json.loads(config_rule.custom.resource_value) + # links[idx].append(( value['uuid'], + # (value['src_qkdn_id'], value['src_interface_id']), + # (value['dst_qkdn_id'], value['dst_interface_id']) + # )) - LOGGER.info("IFs: " + str(interfaces)) - LOGGER.info("Links: " + str(links)) - LOGGER.info("context_: " + context_uuid) + # LOGGER.info("IFs: " + str(interfaces)) + # LOGGER.info("Links: " + str(links)) + # LOGGER.info("context_: " + context_uuid) - # Optare: From here now is where the work is really done. It iterates over every device in use for the service (ordered) + # # Optare: From here now is where the work is really done. It iterates over every device in use for the service (ordered) - src_device_uuid, src_endpoint_uuid = get_device_endpoint_uuids(endpoints[0]) - src_device = devices[0] - src_endpoint = get_endpoint_matching(src_device, src_endpoint_uuid) + # src_device_uuid, src_endpoint_uuid = get_device_endpoint_uuids(endpoints[0]) + # src_device = devices[0] + # src_endpoint = get_endpoint_matching(src_device, src_endpoint_uuid) - dst_device_uuid, dst_endpoint_uuid = get_device_endpoint_uuids(endpoints[-1]) - dst_device = devices[-1] - dst_endpoint = get_endpoint_matching(dst_device, dst_endpoint_uuid) + # dst_device_uuid, dst_endpoint_uuid = get_device_endpoint_uuids(endpoints[-1]) + # dst_device = devices[-1] + # dst_endpoint = get_endpoint_matching(dst_device, dst_endpoint_uuid) - src_qkdn_id = qkdn_ids[0] - dst_qkdn_id = qkdn_ids[-1] + # src_qkdn_id = qkdn_ids[0] + # dst_qkdn_id = qkdn_ids[-1] - src_interface_id = interfaces[0][1] - dst_interface_id = interfaces[-1][0] + # src_interface_id = interfaces[0][1] + # dst_interface_id = interfaces[-1][0] - service_qkdl_id_src_dst = str(uuid.uuid4()) - service_qkdl_id_dst_src = str(uuid.uuid4()) + # service_qkdl_id_src_dst = str(uuid.uuid4()) + # service_qkdl_id_dst_src = str(uuid.uuid4()) - for idx, device in enumerate(devices): + # for idx, device in enumerate(devices): - # Even though we always create them together. There is a chance the admin deletes one of the rules manually - phys_qkdl_id_right = None if idx == (len(devices) - 1) else '' # None == impossible - phys_qkdl_id_left = None if idx == 0 else '' # None == impossible + # # Even though we always create them together. There is a chance the admin deletes one of the rules manually + # phys_qkdl_id_right = None if idx == (len(devices) - 1) else '' # None == impossible + # phys_qkdl_id_left = None if idx == 0 else '' # None == impossible - for link_uuid, link_src, link_dst in links[idx]: - qkdn_link_src, qkdn_interface_src = link_src - qkdn_link_dst, qkdn_interface_dst = link_dst + # for link_uuid, link_src, link_dst in links[idx]: + # qkdn_link_src, qkdn_interface_src = link_src + # qkdn_link_dst, qkdn_interface_dst = link_dst - if phys_qkdl_id_right == '' and \ - qkdn_link_src == qkdn_ids[idx] and qkdn_interface_src == interfaces[idx][1] and \ - qkdn_link_dst[idx+1] and qkdn_interface_dst == interfaces[idx+1][0]: - phys_qkdl_id_right = link_uuid + # if phys_qkdl_id_right == '' and \ + # qkdn_link_src == qkdn_ids[idx] and qkdn_interface_src == interfaces[idx][1] and \ + # qkdn_link_dst[idx+1] and qkdn_interface_dst == interfaces[idx+1][0]: + # phys_qkdl_id_right = link_uuid - if phys_qkdl_id_left == '' and \ - qkdn_link_src == qkdn_ids[idx] and qkdn_interface_src == interfaces[idx][0] and \ - qkdn_link_dst[idx-1] and qkdn_interface_dst == interfaces[idx-1][1]: - phys_qkdl_id_left = link_uuid + # if phys_qkdl_id_left == '' and \ + # qkdn_link_src == qkdn_ids[idx] and qkdn_interface_src == interfaces[idx][0] and \ + # qkdn_link_dst[idx-1] and qkdn_interface_dst == interfaces[idx-1][1]: + # phys_qkdl_id_left = link_uuid - # Optare: Before adding information to config_rules you have to delete the list first otherwise old content will be called again - del device.device_config.config_rules[:] + # # Optare: Before adding information to config_rules you have to delete the list first otherwise old content will be called again + # del device.device_config.config_rules[:] - if phys_qkdl_id_right: - if not is_virtual: - service_qkdl_id_src_dst = phys_qkdl_id_right + # if phys_qkdl_id_right: + # if not is_virtual: + # service_qkdl_id_src_dst = phys_qkdl_id_right - elif phys_qkdl_id_right == '': - qkdl_id_src_dst = str(uuid.uuid4()) if is_virtual else service_qkdl_id_src_dst + # elif phys_qkdl_id_right == '': + # qkdl_id_src_dst = str(uuid.uuid4()) if is_virtual else service_qkdl_id_src_dst - json_config_rule = json_config_rule_set('/link/link[{:s}]'.format(qkdl_id_src_dst), { - 'uuid' : qkdl_id_src_dst, - 'type' : 'DIRECT', - 'src_qkdn_id' : qkdn_ids[idx], - 'src_interface_id' : interfaces[idx][1], - 'dst_qkdn_id' : qkdn_ids[idx+1], - 'dst_interface_id' : interfaces[idx+1][0], - }) + # json_config_rule = json_config_rule_set('/link/link[{:s}]'.format(qkdl_id_src_dst), { + # 'uuid' : qkdl_id_src_dst, + # 'type' : 'DIRECT', + # 'src_qkdn_id' : qkdn_ids[idx], + # 'src_interface_id' : interfaces[idx][1], + # 'dst_qkdn_id' : qkdn_ids[idx+1], + # 'dst_interface_id' : interfaces[idx+1][0], + # }) - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + # device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - if phys_qkdl_id_left: - if not is_virtual: - service_qkdl_id_dst_src = phys_qkdl_id_left + # if phys_qkdl_id_left: + # if not is_virtual: + # service_qkdl_id_dst_src = phys_qkdl_id_left - elif phys_qkdl_id_left == '': - qkdl_id_dst_src = str(uuid.uuid4()) if is_virtual else service_qkdl_id_dst_src + # elif phys_qkdl_id_left == '': + # qkdl_id_dst_src = str(uuid.uuid4()) if is_virtual else service_qkdl_id_dst_src - json_config_rule = json_config_rule_set('/link/link[{:s}]'.format(qkdl_id_dst_src), { - 'uuid' : qkdl_id_dst_src, - 'type' : 'DIRECT', - 'src_qkdn_id' : qkdn_ids[idx], - 'src_interface_id' : interfaces[idx][0], - 'dst_qkdn_id' : qkdn_ids[idx-1], - 'dst_interface_id' : interfaces[idx-1][1], - }) + # json_config_rule = json_config_rule_set('/link/link[{:s}]'.format(qkdl_id_dst_src), { + # 'uuid' : qkdl_id_dst_src, + # 'type' : 'DIRECT', + # 'src_qkdn_id' : qkdn_ids[idx], + # 'src_interface_id' : interfaces[idx][0], + # 'dst_qkdn_id' : qkdn_ids[idx-1], + # 'dst_interface_id' : interfaces[idx-1][1], + # }) - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + # device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - if is_virtual: - if idx < len(qkdn_ids) - 1: - json_config_rule = json_config_rule_set('/link/link[{:s}]'.format(service_qkdl_id_src_dst), { - 'uuid' : service_qkdl_id_src_dst, - 'type' : 'VIRTUAL', - 'src_qkdn_id' : src_qkdn_id, - 'src_interface_id' : src_interface_id, - 'dst_qkdn_id' : dst_qkdn_id, - 'dst_interface_id' : dst_interface_id, - 'virt_prev_hop' : qkdn_ids[idx-1] if idx > 0 else None, - 'virt_next_hops' : qkdn_ids[idx+1:], - 'virt_bandwidth' : 0, - }) - - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - - if idx > 0: - json_config_rule = json_config_rule_set('/link/link[{:s}]'.format(service_qkdl_id_dst_src), { - 'uuid' : service_qkdl_id_dst_src, - 'type' : 'VIRTUAL', - 'src_qkdn_id' : dst_qkdn_id, - 'src_interface_id' : dst_interface_id, - 'dst_qkdn_id' : src_qkdn_id, - 'dst_interface_id' : src_interface_id, - 'virt_prev_hop' : qkdn_ids[idx+1] if idx < len(qkdn_ids) - 1 else None, - 'virt_next_hops' : qkdn_ids[idx-1::-1], - 'virt_bandwidth' : 0, - }) - - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - - - - json_config_rule = json_config_rule_set('/services/service[{:s}]'.format(service_uuid), { - 'uuid' : service_uuid, - 'qkdl_id_src_dst' : service_qkdl_id_src_dst, - 'qkdl_id_dst_src' : service_qkdl_id_dst_src, - }) - - device.device_config.config_rules.append(ConfigRule(**json_config_rule)) - self.__task_executor.configure_device(device) - - - if is_virtual: - - # Register App - internal_app_src_dst = { - 'app_id': {'context_id': {'context_uuid': {'uuid': context_uuid}}, 'app_uuid': {'uuid': str(uuid.uuid4())}}, - 'app_status': QKDAppStatusEnum.QKDAPPSTATUS_ON, - 'app_type': QKDAppTypesEnum.QKDAPPTYPES_INTERNAL, - 'server_app_id': '', - 'client_app_id': [], - 'backing_qkdl_id': [{'qkdl_uuid': {'uuid': service_qkdl_id_src_dst}}], - 'local_device_id': src_device.device_id, - 'remote_device_id': dst_device.device_id, - } - - self.__task_executor.register_app(App(**internal_app_src_dst)) + # if is_virtual: + # if idx < len(qkdn_ids) - 1: + # json_config_rule = json_config_rule_set('/link/link[{:s}]'.format(service_qkdl_id_src_dst), { + # 'uuid' : service_qkdl_id_src_dst, + # 'type' : 'VIRTUAL', + # 'src_qkdn_id' : src_qkdn_id, + # 'src_interface_id' : src_interface_id, + # 'dst_qkdn_id' : dst_qkdn_id, + # 'dst_interface_id' : dst_interface_id, + # 'virt_prev_hop' : qkdn_ids[idx-1] if idx > 0 else None, + # 'virt_next_hops' : qkdn_ids[idx+1:], + # 'virt_bandwidth' : 0, + # }) + + # device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + + # if idx > 0: + # json_config_rule = json_config_rule_set('/link/link[{:s}]'.format(service_qkdl_id_dst_src), { + # 'uuid' : service_qkdl_id_dst_src, + # 'type' : 'VIRTUAL', + # 'src_qkdn_id' : dst_qkdn_id, + # 'src_interface_id' : dst_interface_id, + # 'dst_qkdn_id' : src_qkdn_id, + # 'dst_interface_id' : src_interface_id, + # 'virt_prev_hop' : qkdn_ids[idx+1] if idx < len(qkdn_ids) - 1 else None, + # 'virt_next_hops' : qkdn_ids[idx-1::-1], + # 'virt_bandwidth' : 0, + # }) + + # device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + + + + # json_config_rule = json_config_rule_set('/services/service[{:s}]'.format(service_uuid), { + # 'uuid' : service_uuid, + # 'qkdl_id_src_dst' : service_qkdl_id_src_dst, + # 'qkdl_id_dst_src' : service_qkdl_id_dst_src, + # }) + + # device.device_config.config_rules.append(ConfigRule(**json_config_rule)) + # self.__task_executor.configure_device(device) + + + # if is_virtual: + + # # Register App + # internal_app_src_dst = { + # 'app_id': {'context_id': {'context_uuid': {'uuid': context_uuid}}, 'app_uuid': {'uuid': str(uuid.uuid4())}}, + # 'app_status': QKDAppStatusEnum.QKDAPPSTATUS_ON, + # 'app_type': QKDAppTypesEnum.QKDAPPTYPES_INTERNAL, + # 'server_app_id': '', + # 'client_app_id': [], + # 'backing_qkdl_id': [{'qkdl_uuid': {'uuid': service_qkdl_id_src_dst}}], + # 'local_device_id': src_device.device_id, + # 'remote_device_id': dst_device.device_id, + # } + + # self.__task_executor.register_app(App(**internal_app_src_dst)) - # Register App - internal_app_dst_src = { - 'app_id': {'context_id': {'context_uuid': {'uuid': context_uuid}}, 'app_uuid': {'uuid': str(uuid.uuid4())}}, - 'app_status': QKDAppStatusEnum.QKDAPPSTATUS_ON, - 'app_type': QKDAppTypesEnum.QKDAPPTYPES_INTERNAL, - 'server_app_id': '', - 'client_app_id': [], - 'backing_qkdl_id': [{'qkdl_uuid': {'uuid': service_qkdl_id_dst_src}}], - 'local_device_id': dst_device.device_id, - 'remote_device_id': src_device.device_id, - } - - self.__task_executor.register_app(App(**internal_app_dst_src)) - - results.append(True) - except Exception as e: # pylint: disable=broad-except - LOGGER.exception('Unable to SetEndpoint for Service({:s})'.format(str(service_uuid))) - results.append(e) + # # Register App + # internal_app_dst_src = { + # 'app_id': {'context_id': {'context_uuid': {'uuid': context_uuid}}, 'app_uuid': {'uuid': str(uuid.uuid4())}}, + # 'app_status': QKDAppStatusEnum.QKDAPPSTATUS_ON, + # 'app_type': QKDAppTypesEnum.QKDAPPTYPES_INTERNAL, + # 'server_app_id': '', + # 'client_app_id': [], + # 'backing_qkdl_id': [{'qkdl_uuid': {'uuid': service_qkdl_id_dst_src}}], + # 'local_device_id': dst_device.device_id, + # 'remote_device_id': src_device.device_id, + # } + + # self.__task_executor.register_app(App(**internal_app_dst_src)) + + # results.append(True) + # except Exception as e: # pylint: disable=broad-except + # LOGGER.exception('Unable to SetEndpoint for Service({:s})'.format(str(service_uuid))) + # results.append(e) return results