Loading manifests/opticalcontrollerservice.yaml +6 −6 Original line number Diff line number Diff line Loading @@ -37,12 +37,12 @@ spec: env: - name: LOG_LEVEL value: "INFO" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10060"] livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10060"] #readinessProbe: # exec: # command: ["/bin/grpc_health_probe", "-addr=:10060"] #livenessProbe: # exec: # command: ["/bin/grpc_health_probe", "-addr=:10060"] resources: requests: cpu: 500m Loading src/device/service/Tools.py +75 −93 Original line number Diff line number Diff line Loading @@ -11,30 +11,27 @@ # 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 uuid import UUID, uuid4, uuid5 import json, logging from typing import Any, Dict, List, Optional, Tuple, Union from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.method_wrappers.ServiceExceptions import InvalidArgumentException from common.proto.context_pb2 import ConfigActionEnum, ConfigRule_ACL, Device, DeviceConfig, Link, Location from common.DeviceTypes import DeviceTypeEnum from common.method_wrappers.ServiceExceptions import InvalidArgumentException, NotFoundException from common.proto.context_pb2 import ConfigActionEnum, ConfigRule_ACL, Device, DeviceConfig, EndPoint, Link, Location from common.proto.device_pb2 import MonitoringSettings from common.proto.kpi_sample_types_pb2 import KpiSampleType from common.tools.grpc.ConfigRules import update_config_rule_custom from common.tools.grpc.Tools import grpc_message_to_json from common.type_checkers.Checkers import chk_length, chk_type from .driver_api._Driver import _Driver, RESOURCE_ENDPOINTS from .monitoring.MonitoringLoops import MonitoringLoops from .ErrorMessages import ( ERROR_BAD_RESOURCE, ERROR_DELETE, ERROR_GET, ERROR_GET_INIT, ERROR_MISSING_KPI, ERROR_SAMPLETYPE, ERROR_SET, ERROR_SUBSCRIBE, ERROR_UNSUBSCRIBE, ERROR_UNSUP_RESOURCE ) from .drivers.oc_driver.OCDriver import OCDriver from common.method_wrappers.ServiceExceptions import NotFoundException from common.type_checkers.Checkers import chk_length, chk_type from common.proto.context_pb2 import EndPoint LOGGER = logging.getLogger(__name__) def get_endpoint_matching(device : Device, endpoint_uuid_or_name : str) -> EndPoint: for endpoint in device.device_endpoints: choices = {endpoint.endpoint_id.endpoint_uuid.uuid, endpoint.name} Loading Loading @@ -454,89 +451,74 @@ def update_endpoints(src_device : Device, dst_device : Device) -> None: dst_topology_id = dst_endpoint_id.topology_id if len(src_topology_uuid) > 0: dst_topology_id.topology_uuid.uuid = src_topology_uuid if len(src_context_uuid) > 0: dst_topology_id.context_id.context_uuid.uuid = src_context_uuid def oc_default_endpoints( device : Device, driver : _Driver, monitoring_loops : MonitoringLoops, new_sub_devices : Dict[str, Device], new_sub_links : Dict[str, Link] ) -> List[str]: pass #def get_enpoint_name (device:Device,endpoint_id:str): # str(UUID(str_uuid_or_name)) def get_edit_target(device : Device, is_opticalband : bool) -> str: if (is_opticalband): return "optical-band" else : if device.device_type =='optical-roadm': return 'media-channel' else : return 'optical-channel' if is_opticalband: return 'optical-band' if device.device_type == DeviceTypeEnum.OPTICAL_ROADM: return 'media-channel' return 'optical-channel' def is_key_existed(key : str, keys_dic = dict, key_name_to_use = None) -> dict: dic = {} dic["resource_key"]=key dic['resource_key'] = key if key_name_to_use is not None: dic["resource_key"]=key_name_to_use dic['resource_key'] = key_name_to_use if key in keys_dic: dic["value"]=keys_dic[key] dic['value'] = keys_dic[key] else: dic["value"]=None dic['value'] = None return dic def extract_resources(config : dict, device : Device) -> list: conditions = {} resources = [] resources.append(is_key_existed("channel_namespace",config)) resources.append(is_key_existed("add_transceiver",config)) is_opticalband=False if ( 'is_opticalband' in config): is_opticalband=config['is_opticalband'] conditions["is_opticalband"]=is_opticalband conditions["edit_type"]=get_edit_target(device=device,is_opticalband=is_opticalband) if ('flow' in config): resources.append(is_key_existed('channel_namespace', config)) resources.append(is_key_existed('add_transceiver', config)) is_opticalband = config.get('is_opticalband', False) conditions['is_opticalband'] = is_opticalband conditions['edit_type'] = get_edit_target(device, is_opticalband) if 'flow' in config: #for tuple_value in config['flow'][device.name]: source_vals = [] dest_vals = [] for tuple_value in config['flow']: source_port = None destination_port = None #resources.append({"resource_key":"source_port","value":source_port}) #resources.append({"resource_key":"destination_port","value":destination_port}) source_port_uuid, destination_port_uuid = tuple_value if (source_port_uuid !='0'): if source_port_uuid != '0': src_endpoint_obj = get_endpoint_matching(device, source_port_uuid) source_port = src_endpoint_obj.name source_vals.append(source_port) if (destination_port_uuid !='0'): if destination_port_uuid != '0': dst_endpoint_obj = get_endpoint_matching(device, destination_port_uuid) destination_port = dst_endpoint_obj.name dest_vals.append(destination_port) resources.append({"resource_key":"source_port","value":source_vals}) resources.append({"resource_key":"destination_port","value":dest_vals}) if ('new_config' in config): resources.append({'resource_key': 'source_port', 'value': source_vals}) resources.append({'resource_key': 'destination_port', 'value': dest_vals }) if 'new_config' in config: lower_frequency = None upper_frequency = None resources.append(is_key_existed(key="target-output-power",keys_dic=config["new_config"])) resources.append(is_key_existed(key="frequency",keys_dic=config["new_config"])) resources.append(is_key_existed(key="operational-mode",keys_dic=config["new_config"])) resources.append(is_key_existed(key="line-port",keys_dic=config["new_config"])) resources.append(is_key_existed(key="band_type",keys_dic=config["new_config"],key_name_to_use='name')) resources.append(is_key_existed("ob_id",config["new_config"],key_name_to_use='optical-band-parent')) resources.append(is_key_existed(key="name",keys_dic=config["new_config"],key_name_to_use="channel_name")) resources.append(is_key_existed('target-output-power', keys_dic=config['new_config'])) resources.append(is_key_existed('frequency', keys_dic=config['new_config'])) resources.append(is_key_existed('operational-mode', keys_dic=config['new_config'])) resources.append(is_key_existed('line-port', keys_dic=config['new_config'])) resources.append(is_key_existed('band_type', keys_dic=config['new_config'], key_name_to_use='name')) resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='optical-band-parent')) resources.append(is_key_existed('name', keys_dic=config['new_config'], key_name_to_use='channel_name')) if not is_opticalband: if 'frequency' in config['new_config'] and 'band' in config['new_config'] and conditions["edit_type"] == 'media-channel': if 'frequency' in config['new_config'] and 'band' in config['new_config'] and conditions['edit_type'] == 'media-channel': lower_frequency = int(int(config['new_config']['frequency']) - (int(config['new_config']['band'])/2)) upper_frequency = int(int(config['new_config']['frequency']) + (int(config['new_config']['band'])/2)) #lower_frequency = (config['new_config']['frequency'] - config['new_config']['band'])/2 #upper_frequency = (config['new_config']['frequency'] + config['new_config']['band'])/2 resources.append(is_key_existed(key="flow_id",keys_dic=config["new_config"],key_name_to_use="index")) #resources.append({"resource_key":"index","value":config["new_config"]["flow_id"] if "flow_id" in config["new_config"] else None}) resources.append(is_key_existed('flow_id', keys_dic=config['new_config'], key_name_to_use='index')) #resources.append({'resource_key':'index','value':config['new_config']['flow_id'] if 'flow_id' in config['new_config'] else None}) else: lower_frequency=config['new_config']['low-freq'] if "low-freq" in config['new_config'] else None lower_frequency = config['new_config']['low-freq'] if 'low-freq' in config['new_config'] else None upper_frequency = config['new_config']['up-freq' ] if 'up-freq' in config['new_config'] else None resources.append(is_key_existed(key="ob_id",keys_dic=config["new_config"],key_name_to_use="index")) #resources.append({"resource_key":"index","value":config["new_config"]["ob_id"] if "ob_id" in config["new_config"] else None}) resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='index')) #resources.append({'resource_key':'index','value':config['new_config']['ob_id'] if 'ob_id' in config['new_config'] else None}) resources.append({'resource_key': 'lower-frequency', 'value': lower_frequency}) resources.append({'resource_key': 'upper-frequency', 'value': upper_frequency}) resources.append({"resource_key":"lower-frequency","value":lower_frequency}) resources.append({"resource_key":"upper-frequency","value":upper_frequency}) return [resources, conditions] src/opticalcontroller/RSA.py +14 −0 Original line number Diff line number Diff line # Copyright 2022-2023 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. import dijsktra from tools import * from variables import * Loading src/opticalcontroller/dijsktra.py +14 −0 Original line number Diff line number Diff line # Copyright 2022-2023 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. import sys class Vertex: Loading src/opticalcontroller/tools.py +0 −2 Original line number Diff line number Diff line # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -13,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import numpy as np from variables import * import json Loading Loading
manifests/opticalcontrollerservice.yaml +6 −6 Original line number Diff line number Diff line Loading @@ -37,12 +37,12 @@ spec: env: - name: LOG_LEVEL value: "INFO" readinessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10060"] livenessProbe: exec: command: ["/bin/grpc_health_probe", "-addr=:10060"] #readinessProbe: # exec: # command: ["/bin/grpc_health_probe", "-addr=:10060"] #livenessProbe: # exec: # command: ["/bin/grpc_health_probe", "-addr=:10060"] resources: requests: cpu: 500m Loading
src/device/service/Tools.py +75 −93 Original line number Diff line number Diff line Loading @@ -11,30 +11,27 @@ # 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 uuid import UUID, uuid4, uuid5 import json, logging from typing import Any, Dict, List, Optional, Tuple, Union from common.Constants import DEFAULT_CONTEXT_NAME, DEFAULT_TOPOLOGY_NAME from common.method_wrappers.ServiceExceptions import InvalidArgumentException from common.proto.context_pb2 import ConfigActionEnum, ConfigRule_ACL, Device, DeviceConfig, Link, Location from common.DeviceTypes import DeviceTypeEnum from common.method_wrappers.ServiceExceptions import InvalidArgumentException, NotFoundException from common.proto.context_pb2 import ConfigActionEnum, ConfigRule_ACL, Device, DeviceConfig, EndPoint, Link, Location from common.proto.device_pb2 import MonitoringSettings from common.proto.kpi_sample_types_pb2 import KpiSampleType from common.tools.grpc.ConfigRules import update_config_rule_custom from common.tools.grpc.Tools import grpc_message_to_json from common.type_checkers.Checkers import chk_length, chk_type from .driver_api._Driver import _Driver, RESOURCE_ENDPOINTS from .monitoring.MonitoringLoops import MonitoringLoops from .ErrorMessages import ( ERROR_BAD_RESOURCE, ERROR_DELETE, ERROR_GET, ERROR_GET_INIT, ERROR_MISSING_KPI, ERROR_SAMPLETYPE, ERROR_SET, ERROR_SUBSCRIBE, ERROR_UNSUBSCRIBE, ERROR_UNSUP_RESOURCE ) from .drivers.oc_driver.OCDriver import OCDriver from common.method_wrappers.ServiceExceptions import NotFoundException from common.type_checkers.Checkers import chk_length, chk_type from common.proto.context_pb2 import EndPoint LOGGER = logging.getLogger(__name__) def get_endpoint_matching(device : Device, endpoint_uuid_or_name : str) -> EndPoint: for endpoint in device.device_endpoints: choices = {endpoint.endpoint_id.endpoint_uuid.uuid, endpoint.name} Loading Loading @@ -454,89 +451,74 @@ def update_endpoints(src_device : Device, dst_device : Device) -> None: dst_topology_id = dst_endpoint_id.topology_id if len(src_topology_uuid) > 0: dst_topology_id.topology_uuid.uuid = src_topology_uuid if len(src_context_uuid) > 0: dst_topology_id.context_id.context_uuid.uuid = src_context_uuid def oc_default_endpoints( device : Device, driver : _Driver, monitoring_loops : MonitoringLoops, new_sub_devices : Dict[str, Device], new_sub_links : Dict[str, Link] ) -> List[str]: pass #def get_enpoint_name (device:Device,endpoint_id:str): # str(UUID(str_uuid_or_name)) def get_edit_target(device : Device, is_opticalband : bool) -> str: if (is_opticalband): return "optical-band" else : if device.device_type =='optical-roadm': return 'media-channel' else : return 'optical-channel' if is_opticalband: return 'optical-band' if device.device_type == DeviceTypeEnum.OPTICAL_ROADM: return 'media-channel' return 'optical-channel' def is_key_existed(key : str, keys_dic = dict, key_name_to_use = None) -> dict: dic = {} dic["resource_key"]=key dic['resource_key'] = key if key_name_to_use is not None: dic["resource_key"]=key_name_to_use dic['resource_key'] = key_name_to_use if key in keys_dic: dic["value"]=keys_dic[key] dic['value'] = keys_dic[key] else: dic["value"]=None dic['value'] = None return dic def extract_resources(config : dict, device : Device) -> list: conditions = {} resources = [] resources.append(is_key_existed("channel_namespace",config)) resources.append(is_key_existed("add_transceiver",config)) is_opticalband=False if ( 'is_opticalband' in config): is_opticalband=config['is_opticalband'] conditions["is_opticalband"]=is_opticalband conditions["edit_type"]=get_edit_target(device=device,is_opticalband=is_opticalband) if ('flow' in config): resources.append(is_key_existed('channel_namespace', config)) resources.append(is_key_existed('add_transceiver', config)) is_opticalband = config.get('is_opticalband', False) conditions['is_opticalband'] = is_opticalband conditions['edit_type'] = get_edit_target(device, is_opticalband) if 'flow' in config: #for tuple_value in config['flow'][device.name]: source_vals = [] dest_vals = [] for tuple_value in config['flow']: source_port = None destination_port = None #resources.append({"resource_key":"source_port","value":source_port}) #resources.append({"resource_key":"destination_port","value":destination_port}) source_port_uuid, destination_port_uuid = tuple_value if (source_port_uuid !='0'): if source_port_uuid != '0': src_endpoint_obj = get_endpoint_matching(device, source_port_uuid) source_port = src_endpoint_obj.name source_vals.append(source_port) if (destination_port_uuid !='0'): if destination_port_uuid != '0': dst_endpoint_obj = get_endpoint_matching(device, destination_port_uuid) destination_port = dst_endpoint_obj.name dest_vals.append(destination_port) resources.append({"resource_key":"source_port","value":source_vals}) resources.append({"resource_key":"destination_port","value":dest_vals}) if ('new_config' in config): resources.append({'resource_key': 'source_port', 'value': source_vals}) resources.append({'resource_key': 'destination_port', 'value': dest_vals }) if 'new_config' in config: lower_frequency = None upper_frequency = None resources.append(is_key_existed(key="target-output-power",keys_dic=config["new_config"])) resources.append(is_key_existed(key="frequency",keys_dic=config["new_config"])) resources.append(is_key_existed(key="operational-mode",keys_dic=config["new_config"])) resources.append(is_key_existed(key="line-port",keys_dic=config["new_config"])) resources.append(is_key_existed(key="band_type",keys_dic=config["new_config"],key_name_to_use='name')) resources.append(is_key_existed("ob_id",config["new_config"],key_name_to_use='optical-band-parent')) resources.append(is_key_existed(key="name",keys_dic=config["new_config"],key_name_to_use="channel_name")) resources.append(is_key_existed('target-output-power', keys_dic=config['new_config'])) resources.append(is_key_existed('frequency', keys_dic=config['new_config'])) resources.append(is_key_existed('operational-mode', keys_dic=config['new_config'])) resources.append(is_key_existed('line-port', keys_dic=config['new_config'])) resources.append(is_key_existed('band_type', keys_dic=config['new_config'], key_name_to_use='name')) resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='optical-band-parent')) resources.append(is_key_existed('name', keys_dic=config['new_config'], key_name_to_use='channel_name')) if not is_opticalband: if 'frequency' in config['new_config'] and 'band' in config['new_config'] and conditions["edit_type"] == 'media-channel': if 'frequency' in config['new_config'] and 'band' in config['new_config'] and conditions['edit_type'] == 'media-channel': lower_frequency = int(int(config['new_config']['frequency']) - (int(config['new_config']['band'])/2)) upper_frequency = int(int(config['new_config']['frequency']) + (int(config['new_config']['band'])/2)) #lower_frequency = (config['new_config']['frequency'] - config['new_config']['band'])/2 #upper_frequency = (config['new_config']['frequency'] + config['new_config']['band'])/2 resources.append(is_key_existed(key="flow_id",keys_dic=config["new_config"],key_name_to_use="index")) #resources.append({"resource_key":"index","value":config["new_config"]["flow_id"] if "flow_id" in config["new_config"] else None}) resources.append(is_key_existed('flow_id', keys_dic=config['new_config'], key_name_to_use='index')) #resources.append({'resource_key':'index','value':config['new_config']['flow_id'] if 'flow_id' in config['new_config'] else None}) else: lower_frequency=config['new_config']['low-freq'] if "low-freq" in config['new_config'] else None lower_frequency = config['new_config']['low-freq'] if 'low-freq' in config['new_config'] else None upper_frequency = config['new_config']['up-freq' ] if 'up-freq' in config['new_config'] else None resources.append(is_key_existed(key="ob_id",keys_dic=config["new_config"],key_name_to_use="index")) #resources.append({"resource_key":"index","value":config["new_config"]["ob_id"] if "ob_id" in config["new_config"] else None}) resources.append(is_key_existed('ob_id', keys_dic=config['new_config'], key_name_to_use='index')) #resources.append({'resource_key':'index','value':config['new_config']['ob_id'] if 'ob_id' in config['new_config'] else None}) resources.append({'resource_key': 'lower-frequency', 'value': lower_frequency}) resources.append({'resource_key': 'upper-frequency', 'value': upper_frequency}) resources.append({"resource_key":"lower-frequency","value":lower_frequency}) resources.append({"resource_key":"upper-frequency","value":upper_frequency}) return [resources, conditions]
src/opticalcontroller/RSA.py +14 −0 Original line number Diff line number Diff line # Copyright 2022-2023 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. import dijsktra from tools import * from variables import * Loading
src/opticalcontroller/dijsktra.py +14 −0 Original line number Diff line number Diff line # Copyright 2022-2023 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. import sys class Vertex: Loading
src/opticalcontroller/tools.py +0 −2 Original line number Diff line number Diff line # Copyright 2022-2023 ETSI TeraFlowSDN - TFS OSG (https://tfs.etsi.org/) # # Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -13,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import numpy as np from variables import * import json Loading