diff --git a/my_deploy.sh b/my_deploy.sh index 524abc6cc8dc8dff25e559663cf73339ed1b2bd6..87f6e2491f6ca819afc008fbcad33a8cb2162210 100755 --- a/my_deploy.sh +++ b/my_deploy.sh @@ -20,10 +20,13 @@ 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 pathcomp opticalcontroller service slice webui " +export TFS_COMPONENTS="context device pathcomp service slice nbi webui load_generator" # Uncomment to activate Monitoring -#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring"../ +#export TFS_COMPONENTS="${TFS_COMPONENTS} monitoring" + +# Uncomment to activate BGP-LS Speaker +#export TFS_COMPONENTS="${TFS_COMPONENTS} bgpls_speaker" # Uncomment to activate ZTP #export TFS_COMPONENTS="${TFS_COMPONENTS} ztp" diff --git a/src/opticalcontroller/dijsktra.py b/src/opticalcontroller/dijsktra.py index 94975fd557990e89d11e706e4614f7c69617ceea..a86d1d93dcbc30b9e4e3b95a34a0922439871bf6 100644 --- a/src/opticalcontroller/dijsktra.py +++ b/src/opticalcontroller/dijsktra.py @@ -12,6 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +# TODO: migrate to NetworkX: +# https://networkx.org/documentation/stable/index.html +# https://networkx.org/documentation/stable/reference/algorithms/shortest_paths.html + import sys class Vertex: @@ -233,4 +237,4 @@ if __name__ == '__main__': print ('The shortest path : %s' %(path[::-1]))""" p = shortest_path(g, g.get_vertex('a'), g.get_vertex('e')) - print(p) \ No newline at end of file + print(p) diff --git a/src/service/Dockerfile b/src/service/Dockerfile index c48f1ab0ac47a2f6ddbc33e9a30075f9dea8d94c..aed4ce64c60a7cfca5b80dc46e03bad18a017ca9 100644 --- a/src/service/Dockerfile +++ b/src/service/Dockerfile @@ -62,16 +62,15 @@ RUN python3 -m pip install -r requirements.txt # Add component files into working directory WORKDIR /var/teraflow -COPY src/service/. service/ -#COPY src/context/__init__.py context/__init__.py -#COPY src/context/client/. context/client/ -COPY src/context/. context/. +COPY src/context/__init__.py context/__init__.py +COPY src/context/client/. context/client/ COPY src/device/__init__.py device/__init__.py COPY src/device/client/. device/client/ 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/service/. service/ # Start the service ENTRYPOINT ["python", "-m", "service.service"] diff --git a/src/service/service/__main__.py b/src/service/service/__main__.py index 31dbbdbe60bf00b66071d5dcbf1c86c1a7caf9c1..d096de8c64edaeda086460325e3878148623f28c 100644 --- a/src/service/service/__main__.py +++ b/src/service/service/__main__.py @@ -12,12 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging, signal, sys, threading,os +import logging, signal, sys, threading from prometheus_client import start_http_server 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,find_environment_variables) + wait_for_environment_variables +) from .ServiceService import ServiceService from .service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory from .service_handlers import SERVICE_HANDLERS @@ -43,18 +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.PATHCOMP, ENVVAR_SUFIX_SERVICE_HOST), - get_env_var_name(ServiceNameEnum.PATHCOMP, ENVVAR_SUFIX_SERVICE_PORT_GRPC) - - ]) - #Commented for merging with develop branch - # variables= find_environment_variables([ - # get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER,ENVVAR_SUFIX_SERVICE_HOST), - # get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER,ENVVAR_SUFIX_SERVICE_PORT_GRPC), - # ]) - signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) diff --git a/src/service/service/task_scheduler/TaskExecutor.py b/src/service/service/task_scheduler/TaskExecutor.py index 487c61efe3c7546e3672234b4f1f776bf86272ae..8e5ad4ecc2e9e57844a63c974e6c07aa1be38fa5 100644 --- a/src/service/service/task_scheduler/TaskExecutor.py +++ b/src/service/service/task_scheduler/TaskExecutor.py @@ -12,11 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import logging , json +import json, logging from enum import Enum from typing import TYPE_CHECKING, Any, Dict, Optional, Union from common.method_wrappers.ServiceExceptions import NotFoundException -from common.proto.context_pb2 import Connection, ConnectionId, Device, DeviceDriverEnum, DeviceId, Service, ServiceId,OpticalConfig,OpticalConfigId +from common.proto.context_pb2 import ( + Connection, ConnectionId, Device, DeviceDriverEnum, DeviceId, Service, ServiceId, + OpticalConfig, OpticalConfigId +) from common.tools.context_queries.Connection import get_connection_by_id from common.tools.context_queries.Device import get_device from common.tools.context_queries.Service import get_service_by_id @@ -25,7 +28,8 @@ from common.tools.object_factory.Device import json_device_id from context.client.ContextClient import ContextClient from device.client.DeviceClient import DeviceClient from service.service.service_handler_api.Exceptions import ( - UnsatisfiedFilterException, UnsupportedFilterFieldException, UnsupportedFilterFieldValueException) + UnsatisfiedFilterException, UnsupportedFilterFieldException, UnsupportedFilterFieldValueException +) from service.service.service_handler_api.ServiceHandlerFactory import ServiceHandlerFactory, get_service_handler_class from service.service.tools.ObjectKeys import get_connection_key, get_device_key, get_service_key @@ -114,39 +118,27 @@ class TaskExecutor: self._store_grpc_object(CacheableObjectType.DEVICE, device_key, device) # New function Andrea for Optical Devices - def configure_optical_device(self,device:Device,settings:str,flows:list,is_opticalband:bool): - - + def configure_optical_device(self, device : Device, settings : str, flows : list, is_opticalband : bool): device_key = get_device_key(device.device_id) - myid=OpticalConfigId() - myid.opticalconfig_uuid=device.device_id.device_uuid.uuid - opticalconfig=OpticalConfig() - - setting =settings.value if settings else "" - - new_config={} + myid = OpticalConfigId() + myid.opticalconfig_uuid = device.device_id.device_uuid.uuid + opticalconfig = OpticalConfig() + setting = settings.value if settings else "" + new_config = {} try: - result=self._context_client.SelectOpticalConfig(myid) - - new_config=json.loads(result.config) - - if result is not None : - - new_config["new_config"]=setting - new_config["is_opticalband"]=is_opticalband - new_config["flow"]=flows - result.config = str(new_config) - opticalconfig.CopyFrom(result) - - self._device_client.ConfigureOpticalDevice(opticalconfig) - - self._store_grpc_object(CacheableObjectType.DEVICE, device_key, device) + result = self._context_client.SelectOpticalConfig(myid) + new_config = json.loads(result.config) + if result is not None : + new_config["new_config"] = setting + new_config["is_opticalband"] = is_opticalband + new_config["flow"] = flows + result.config = str(new_config) + opticalconfig.CopyFrom(result) + self._device_client.ConfigureOpticalDevice(opticalconfig) + self._store_grpc_object(CacheableObjectType.DEVICE, device_key, device) except Exception as e: LOGGER.info("error in config my config %s",e) - - - - + def get_device_controller(self, device : Device) -> Optional[Device]: #json_controller = None #for config_rule in device.device_config.config_rules: diff --git a/src/service/service/tools/OpticalTools.py b/src/service/service/tools/OpticalTools.py index a5529adc809f2b7d20c65093ab60ce9287eec787..8b3e3153beb53063b17ae7998e8a7d49f8abd64e 100644 --- a/src/service/service/tools/OpticalTools.py +++ b/src/service/service/tools/OpticalTools.py @@ -15,45 +15,46 @@ import json import requests -import uuid ,os +import uuid from common.Constants import * from typing import Dict, List from common.proto.context_pb2 import( - Device, DeviceId, Service, Connection, EndPointId, TopologyId, ContextId, Uuid, ConfigRule, ConfigActionEnum, ConfigRule_Custom) + Device, DeviceId, Service, Connection, EndPointId, TopologyId, ContextId, Uuid, + ConfigRule, ConfigActionEnum, ConfigRule_Custom +) from common.proto.pathcomp_pb2 import PathCompReply from typing import Dict, List, Optional, Tuple from common.Constants import ServiceNameEnum from common.Settings import ( - ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, find_environment_variables ,get_env_var_name) + ENVVAR_SUFIX_SERVICE_HOST, ENVVAR_SUFIX_SERVICE_PORT_GRPC, find_environment_variables, get_env_var_name +) from context.service.database.uuids.EndPoint import endpoint_get_uuid - - from service.service.tools.replies import reply_uni_txt, optical_band_uni_txt, reply_bid_txt, optical_band_bid_txt log = logging.getLogger(__name__) testing = False - -opticalcontrollers_url= find_environment_variables([ - get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER,ENVVAR_SUFIX_SERVICE_HOST), - get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER,ENVVAR_SUFIX_SERVICE_PORT_GRPC), - ]) -OPTICAL_IP=opticalcontrollers_url[get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER,ENVVAR_SUFIX_SERVICE_HOST)] -OPTICAL_PORT=opticalcontrollers_url[get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER,ENVVAR_SUFIX_SERVICE_PORT_GRPC)] -log.info(OPTICAL_IP,OPTICAL_PORT) -def get_uuids_from_names(devices: List[Device], device_name: str, port_name: str): +VAR_NAME_OPTICAL_CONTROLLER_HOST = get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER, ENVVAR_SUFIX_SERVICE_HOST) +VAR_NAME_OPTICAL_CONTROLLER_PORT = get_env_var_name(ServiceNameEnum.OPTICALCONTROLLER, ENVVAR_SUFIX_SERVICE_PORT_GRPC) + +opticalcontrollers_url = find_environment_variables([ + VAR_NAME_OPTICAL_CONTROLLER_HOST, + VAR_NAME_OPTICAL_CONTROLLER_PORT, +]) +OPTICAL_IP = opticalcontrollers_url.get(VAR_NAME_OPTICAL_CONTROLLER_HOST) +OPTICAL_PORT = opticalcontrollers_url.get(VAR_NAME_OPTICAL_CONTROLLER_PORT) +log.info(str(OPTICAL_IP), str(OPTICAL_PORT)) + +def get_uuids_from_names(devices: List[Device], device_name: str, port_name: str): device_uuid = "" port_uuid = "" for device in devices: if device.name == device_name: - device_uuid = device.device_id.device_uuid.uuid - for ep in device.device_endpoints: if ep.name == port_name: port_uuid = ep.endpoint_id.endpoint_uuid.uuid - return device_uuid, port_uuid return "", "" @@ -296,4 +297,4 @@ def add_service_to_reply(reply : PathCompReply, service : Service)-> Service: def add_connection_to_reply(reply : PathCompReply)-> Connection: conn = reply.connections.add() - return conn \ No newline at end of file + return conn diff --git a/src/tests/ofc24/README.md b/src/tests/ofc24/README.md index 3d01142cbf5880ea613644e6dd4014df7e703aa7..93e95fc642273bf852c829d6fae14cddf8ccba96 100644 --- a/src/tests/ofc24/README.md +++ b/src/tests/ofc24/README.md @@ -1,10 +1,21 @@ -# start topology , 2 Transponders Openconfig and 2 multi granular Roadms : +# OFC'24 - Test scenario +## Start Topology +Topology is composed of 2 transponders managed through OpenConfig and 2 Multi-granular ROAMDS +Strat the topology executing the following command: +```bash sudo ./start_topo.sh +``` -# populate tfs context in (pushing the json files) following the file index , i.e : 1 , 2 -# last json is with ID 7 is the service , to check the service is onboarded successfully go into the srevice interface -# of tfs webGui -# to check if the devices are configured , run -screen -r tx with x = 1, 2,3 , 4 -# to release the terminal , press ctrl + a + d \ No newline at end of file +## Populate the TFS context and topology +Pushing the JSON files following the file indexes, i.e, 1, 2, 3, ... +The last JSON file with ID 7 is the service. +To check the service is onboarded successfully go into the TFS WebUI and check the `Service` tab. + +## Check configuration in devices +Check if the devices are configured properly. +To check that, run, for each device (X={1, 2, 3, 4}): +```bash +screen -r tX +``` +To release the terminal, press `Ctrl + A + D` diff --git a/src/tests/ofc24/start_topo.sh b/src/tests/ofc24/start_topo.sh index 760f9ab23e51f525da142c68305486b5d8a7aef4..c924064763c14e4da45344cd21f4d9c81c9640a9 100755 --- a/src/tests/ofc24/start_topo.sh +++ b/src/tests/ofc24/start_topo.sh @@ -1,6 +1,4 @@ #!/bin/bash -<<<<<<< HEAD:ofc24/start_topo.sh -======= # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,11 +12,11 @@ # 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. ->>>>>>> d5bb84dd9f53b483dcb31ec12a061abe21668703:src/tests/ofc24/start_topo.sh IMAGE_NAME="asgamb1/oc23bgp.img:latest" -Docker_Container=$1 -Docker_Port="2022" +DOCKER_CONTAINER=$1 +DOCKER_PORT="2022" + sudo docker stop na1 -t 1 sudo docker stop na2 -t 1 sudo docker stop na3 -t 1 @@ -43,16 +41,14 @@ echo "Creating Transponder Agents" -screen -dmS t1 -T xterm sh -c "docker run -p 127.0.0.1:2023:2022 -v ~/tempOC/files:/files --name $Docker_Container -it asgamb1/oc23bgp.img:latest bash" +screen -dmS t1 -T xterm sh -c "docker run -p 127.0.0.1:2023:2022 -v ~/tempOC/files:/files --name $DOCKER_CONTAINER -it asgamb1/oc23bgp.img:latest bash" sleep 2 -if [ "$( docker container inspect -f '{{.State.Running}}' "$Docker_Container")" = "true" ]; then - - docker exec "$Docker_Container" cp /files/demoECOC21_4.xml demoECOC21.xml - - docker exec "$Docker_Container" /confd/examples.confd/OC23/startNetconfAgent.sh +if [ "$( docker container inspect -f '{{.State.Running}}' "$DOCKER_CONTAINER")" = "true" ]; then + docker exec "$DOCKER_CONTAINER" cp /files/demoECOC21_4.xml demoECOC21.xml + docker exec "$DOCKER_CONTAINER" /confd/examples.confd/OC23/startNetconfAgent.sh else echo "your container is not running yet" - +fi echo " It may take a while , Hang on ..." source "./startExtraNetConfigAgent.sh" "na1" "2023" @@ -61,9 +57,7 @@ sleep 3 source "./startExtraNetConfigAgent.sh" "na2" "2024" sleep 3 -R1 bash -c "cp /tempOC/files/plat_r1.xml /confd/examples.confd/OC23/init_openconfig-platform.xml; ./startNetconfAgent.sh" -R2 bash -c "cp /tempOC/files/plat_r2.xml /confd/examples.confd/OC23/init_openconfig-platform.xml; ./startNetconfAgent.sh" screen -dmS t3 -T xterm sh -c 'docker run -p 10.0.2.15:2025:2022 -v ~/tfs-ctrl/tempOC/files:/files --name na3 -it asgamb1/flexscale-node.img:latest ./startNetconfAgent.sh' screen -dmS t4 -T xterm sh -c 'docker run -p 10.0.2.15:2026:2022 -v ~/tfs-ctrl/tempOC/files:/files --name na4 -it asgamb1/flexscale-node.img:latest ./startNetconfAgent.sh'