Loading src/device/client/DeviceClient.py +4 −3 Original line number Diff line number Diff line Loading @@ -82,8 +82,9 @@ class DeviceClient: response = self.stub.MonitorDeviceKpi(request) LOGGER.debug('MonitorDeviceKpi result: {:s}'.format(grpc_message_to_json_string(response))) return response def ConfigureOpticalDevice(self, request : MyConfig) -> MyConfigId: def ConfigureOpticalDevice(self, request : MyConfig) -> MyConfigId: LOGGER.debug('ConfigureOpticalDevice request: {:s}'.format(grpc_message_to_json_string(request))) response = self.openconfig_stub.ConfigureOpticalDevice(request) LOGGER.debug('ConfigureOpticalDevice result: {:s}'.format(grpc_message_to_json_string(response))) return response src/device/service/DeviceService.py +0 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ class DeviceService(GenericGrpcService): add_DeviceServiceServicer_to_server(self.device_servicer, self.server) add_OpenConfigServiceServicer_to_server(self.openconfig_device_servicer,self.server) def stop(self): super().stop() self.monitoring_loops.stop() src/device/service/DeviceServiceServicerImpl.py +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,8 @@ from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, get_env_var_name from common.method_wrappers.Decorator import MetricTypeEnum, MetricsPool, safe_and_metered_rpc_method from common.method_wrappers.ServiceExceptions import NotFoundException, OperationFailedException from common.proto.context_pb2 import ( Device, DeviceConfig, DeviceDriverEnum, DeviceId, DeviceOperationalStatusEnum, Empty, Link,MyConfig,MyConfigId) Device, DeviceConfig, DeviceDriverEnum, DeviceId, DeviceOperationalStatusEnum, Empty, Link, MyConfig, MyConfigId ) from common.proto.device_pb2 import MonitoringSettings from common.proto.device_pb2_grpc import DeviceServiceServicer from common.tools.context_queries.Device import get_device Loading src/device/service/OpenConfigServicer.py +7 −85 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, get_env_var_name from common.method_wrappers.Decorator import MetricTypeEnum, MetricsPool, safe_and_metered_rpc_method from common.method_wrappers.ServiceExceptions import NotFoundException, OperationFailedException from common.proto.context_pb2 import ( Device, DeviceConfig, DeviceDriverEnum, DeviceId, DeviceOperationalStatusEnum, Empty, Link,MyConfig,MyConfigId ,MyConfig,MyConfigList) Device, DeviceConfig, DeviceDriverEnum, DeviceId, DeviceOperationalStatusEnum, Empty, Link, MyConfig, MyConfigId, MyConfig, MyConfigList ) from common.proto.device_pb2 import MonitoringSettings from common.proto.device_pb2_grpc import DeviceServiceServicer from common.tools.context_queries.Device import get_device Loading Loading @@ -93,98 +95,18 @@ class OpenConfigServicer(DeviceServiceServicer): except Exception as error : LOGGER.debug("error %s",error) # @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) # def ConfigureOpenConfigDevice(self, request : MyConfig, context : grpc.ServicerContext) -> DeviceId: # device_id = request.myconfig_id # device_uuid = device_id.myconfig_uuid # self.mutex_queues.wait_my_turn(device_uuid) # t1 = time.time() # try: # context_client = ContextClient() # t2 = time.time() # device = get_device( # context_client, device_uuid, rw_copy=True, include_endpoints=False, include_components=False, # include_config_rules=True) # if device is None: # raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice') # t3 = time.time() # device_controller_uuid = get_device_controller_uuid(device) # if device_controller_uuid is not None: # device = get_device( # context_client, device_controller_uuid, rw_copy=True, include_endpoints=False, # include_components=False, include_config_rules=True) # if device is None: # raise NotFoundException( # 'Device', device_controller_uuid, extra_details='loading in ConfigureDevice') # device_uuid = device.device_id.device_uuid.uuid # driver : _Driver = get_driver(self.driver_instance_cache, device) # resources_to_set, resources_to_delete = compute_rules_to_add_delete(device, request) # results_setconfig = driver.SetConfig(resources=resources_to_set) # except Exception as e: # LOGGER.debug("error in updating %s",e) ''' @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def ConfigureOpticalDevice (self, request : MyConfig, context:grpc.ServicerContext) -> Empty: LOGGER.info('Updating from ConfigureOpticalDevice %s',request) device_id = request.myconfig_id device_uuid = device_id.myconfig_uuid resources=[] add_proccess=False update_interface=False result=None config =eval(request.config) filter_fields= ["frequency","target-output-power","interface","operational-mode"] try: context_client = ContextClient() device = get_device( context_client, device_uuid, rw_copy=True, include_endpoints=False, include_components=False, include_config_rules=True) if device is None: LOGGER.debug("device is none") raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice') resources,conditions=extract_resources(config=config,device=device) driver : _Driver = get_driver(self.driver_instance_cache, device) LOGGER.info("resource %s conditions %s",resources,conditions) result = driver.SetConfig(resources=resources,conditions=conditions) driver.GetConfig(resource_keys=filter_fields) except Exception as e: LOGGER.info("error in configuring %s",e) LOGGER.info("result %s",result) return Empty() ''' #modified Andrea @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def ConfigureOpticalDevice (self, request : MyConfig, context:grpc.ServicerContext) -> Empty: LOGGER.info('Setting from ConfigureOpticalDevice with Flows %s',request) #device_id = request.myconfig_id #device_uuid = device_id.myconfig_uuid device_uuid = request.myconfig_id.myconfig_uuid LOGGER.info("AAAAAAAAAAAAAAAAAAAAAAA device uuid {}".format(device_uuid)) LOGGER.info("device uuid {}".format(device_uuid)) resources=[] result=None config = eval(request.config) filter_fields= ["frequency", "target-output-power", "interface", "operational-mode"] try: context_client = ContextClient() device = get_device( Loading @@ -192,7 +114,7 @@ class OpenConfigServicer(DeviceServiceServicer): include_config_rules=False) if device is None: LOGGER.info("AAAAAAAAAAAAAAAAAAAAAAAdevice is none") LOGGER.info("device is none") raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice') resources,conditions=extract_resources(config=config,device=device) driver : _Driver = get_driver(self.driver_instance_cache, device) Loading src/device/service/Tools.py +59 −58 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ # 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 Loading Loading @@ -454,6 +455,7 @@ 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] Loading Loading @@ -527,4 +529,3 @@ def extract_resources (config:dict,device:Device)-> list : resources.append({"resource_key":"lower-frequency","value":lower_frequency}) resources.append({"resource_key":"upper-frequency","value":upper_frequency}) return [resources,conditions] Loading
src/device/client/DeviceClient.py +4 −3 Original line number Diff line number Diff line Loading @@ -82,8 +82,9 @@ class DeviceClient: response = self.stub.MonitorDeviceKpi(request) LOGGER.debug('MonitorDeviceKpi result: {:s}'.format(grpc_message_to_json_string(response))) return response def ConfigureOpticalDevice(self, request : MyConfig) -> MyConfigId: def ConfigureOpticalDevice(self, request : MyConfig) -> MyConfigId: LOGGER.debug('ConfigureOpticalDevice request: {:s}'.format(grpc_message_to_json_string(request))) response = self.openconfig_stub.ConfigureOpticalDevice(request) LOGGER.debug('ConfigureOpticalDevice result: {:s}'.format(grpc_message_to_json_string(response))) return response
src/device/service/DeviceService.py +0 −1 Original line number Diff line number Diff line Loading @@ -40,7 +40,6 @@ class DeviceService(GenericGrpcService): add_DeviceServiceServicer_to_server(self.device_servicer, self.server) add_OpenConfigServiceServicer_to_server(self.openconfig_device_servicer,self.server) def stop(self): super().stop() self.monitoring_loops.stop()
src/device/service/DeviceServiceServicerImpl.py +2 −1 Original line number Diff line number Diff line Loading @@ -20,7 +20,8 @@ from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, get_env_var_name from common.method_wrappers.Decorator import MetricTypeEnum, MetricsPool, safe_and_metered_rpc_method from common.method_wrappers.ServiceExceptions import NotFoundException, OperationFailedException from common.proto.context_pb2 import ( Device, DeviceConfig, DeviceDriverEnum, DeviceId, DeviceOperationalStatusEnum, Empty, Link,MyConfig,MyConfigId) Device, DeviceConfig, DeviceDriverEnum, DeviceId, DeviceOperationalStatusEnum, Empty, Link, MyConfig, MyConfigId ) from common.proto.device_pb2 import MonitoringSettings from common.proto.device_pb2_grpc import DeviceServiceServicer from common.tools.context_queries.Device import get_device Loading
src/device/service/OpenConfigServicer.py +7 −85 Original line number Diff line number Diff line Loading @@ -20,7 +20,9 @@ from common.Settings import ENVVAR_SUFIX_SERVICE_HOST, get_env_var_name from common.method_wrappers.Decorator import MetricTypeEnum, MetricsPool, safe_and_metered_rpc_method from common.method_wrappers.ServiceExceptions import NotFoundException, OperationFailedException from common.proto.context_pb2 import ( Device, DeviceConfig, DeviceDriverEnum, DeviceId, DeviceOperationalStatusEnum, Empty, Link,MyConfig,MyConfigId ,MyConfig,MyConfigList) Device, DeviceConfig, DeviceDriverEnum, DeviceId, DeviceOperationalStatusEnum, Empty, Link, MyConfig, MyConfigId, MyConfig, MyConfigList ) from common.proto.device_pb2 import MonitoringSettings from common.proto.device_pb2_grpc import DeviceServiceServicer from common.tools.context_queries.Device import get_device Loading Loading @@ -93,98 +95,18 @@ class OpenConfigServicer(DeviceServiceServicer): except Exception as error : LOGGER.debug("error %s",error) # @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) # def ConfigureOpenConfigDevice(self, request : MyConfig, context : grpc.ServicerContext) -> DeviceId: # device_id = request.myconfig_id # device_uuid = device_id.myconfig_uuid # self.mutex_queues.wait_my_turn(device_uuid) # t1 = time.time() # try: # context_client = ContextClient() # t2 = time.time() # device = get_device( # context_client, device_uuid, rw_copy=True, include_endpoints=False, include_components=False, # include_config_rules=True) # if device is None: # raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice') # t3 = time.time() # device_controller_uuid = get_device_controller_uuid(device) # if device_controller_uuid is not None: # device = get_device( # context_client, device_controller_uuid, rw_copy=True, include_endpoints=False, # include_components=False, include_config_rules=True) # if device is None: # raise NotFoundException( # 'Device', device_controller_uuid, extra_details='loading in ConfigureDevice') # device_uuid = device.device_id.device_uuid.uuid # driver : _Driver = get_driver(self.driver_instance_cache, device) # resources_to_set, resources_to_delete = compute_rules_to_add_delete(device, request) # results_setconfig = driver.SetConfig(resources=resources_to_set) # except Exception as e: # LOGGER.debug("error in updating %s",e) ''' @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def ConfigureOpticalDevice (self, request : MyConfig, context:grpc.ServicerContext) -> Empty: LOGGER.info('Updating from ConfigureOpticalDevice %s',request) device_id = request.myconfig_id device_uuid = device_id.myconfig_uuid resources=[] add_proccess=False update_interface=False result=None config =eval(request.config) filter_fields= ["frequency","target-output-power","interface","operational-mode"] try: context_client = ContextClient() device = get_device( context_client, device_uuid, rw_copy=True, include_endpoints=False, include_components=False, include_config_rules=True) if device is None: LOGGER.debug("device is none") raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice') resources,conditions=extract_resources(config=config,device=device) driver : _Driver = get_driver(self.driver_instance_cache, device) LOGGER.info("resource %s conditions %s",resources,conditions) result = driver.SetConfig(resources=resources,conditions=conditions) driver.GetConfig(resource_keys=filter_fields) except Exception as e: LOGGER.info("error in configuring %s",e) LOGGER.info("result %s",result) return Empty() ''' #modified Andrea @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def ConfigureOpticalDevice (self, request : MyConfig, context:grpc.ServicerContext) -> Empty: LOGGER.info('Setting from ConfigureOpticalDevice with Flows %s',request) #device_id = request.myconfig_id #device_uuid = device_id.myconfig_uuid device_uuid = request.myconfig_id.myconfig_uuid LOGGER.info("AAAAAAAAAAAAAAAAAAAAAAA device uuid {}".format(device_uuid)) LOGGER.info("device uuid {}".format(device_uuid)) resources=[] result=None config = eval(request.config) filter_fields= ["frequency", "target-output-power", "interface", "operational-mode"] try: context_client = ContextClient() device = get_device( Loading @@ -192,7 +114,7 @@ class OpenConfigServicer(DeviceServiceServicer): include_config_rules=False) if device is None: LOGGER.info("AAAAAAAAAAAAAAAAAAAAAAAdevice is none") LOGGER.info("device is none") raise NotFoundException('Device', device_uuid, extra_details='loading in ConfigureDevice') resources,conditions=extract_resources(config=config,device=device) driver : _Driver = get_driver(self.driver_instance_cache, device) Loading
src/device/service/Tools.py +59 −58 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ # 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 Loading Loading @@ -454,6 +455,7 @@ 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] Loading Loading @@ -527,4 +529,3 @@ def extract_resources (config:dict,device:Device)-> list : resources.append({"resource_key":"lower-frequency","value":lower_frequency}) resources.append({"resource_key":"upper-frequency","value":upper_frequency}) return [resources,conditions]