Loading my_deploy.sh +5 −2 Original line number Diff line number Diff line Loading @@ -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" Loading src/opticalcontroller/dijsktra.py +5 −1 Original line number Diff line number Diff line Loading @@ -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: Loading src/service/Dockerfile +3 −4 Original line number Diff line number Diff line Loading @@ -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"] src/service/service/__main__.py +3 −12 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) Loading src/service/service/task_scheduler/TaskExecutor.py +24 −32 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -115,38 +119,26 @@ class TaskExecutor: # New function Andrea for Optical Devices 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 = {} 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) 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: Loading Loading
my_deploy.sh +5 −2 Original line number Diff line number Diff line Loading @@ -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" Loading
src/opticalcontroller/dijsktra.py +5 −1 Original line number Diff line number Diff line Loading @@ -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: Loading
src/service/Dockerfile +3 −4 Original line number Diff line number Diff line Loading @@ -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"]
src/service/service/__main__.py +3 −12 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) Loading
src/service/service/task_scheduler/TaskExecutor.py +24 −32 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -115,38 +119,26 @@ class TaskExecutor: # New function Andrea for Optical Devices 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 = {} 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) 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: Loading