Loading .gitlab-ci.yml +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ include: #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_attackmitigator/.gitlab-ci.yml' - local: '/src/slice/.gitlab-ci.yml' #- local: '/src/slice/.gitlab-ci.yml' #- local: '/src/interdomain/.gitlab-ci.yml' - local: '/src/pathcomp/.gitlab-ci.yml' #- local: '/src/dlt/.gitlab-ci.yml' Loading src/common/tools/rest_conf/client/RestConfClient.py +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ class RestConfClient(RestApiClient): username : Optional[str] = None, password : Optional[str] = None, restconf_version : Optional[str] = None, timeout : int = 30, verify_certs : bool = True, allow_redirects : bool = True, logger : Optional[logging.Logger] = None logger : Optional[logging.Logger] = None, **kwargs ) -> None: super().__init__( address, port=port, scheme=scheme, username=username, password=password, Loading src/device/service/DeviceServiceServicerImpl.py +5 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ from .Tools import ( check_connect_rules, check_no_endpoints, compute_rules_to_add_delete, configure_rules, deconfigure_rules, get_device_controller_uuid, populate_config_rules, populate_endpoint_monitoring_resources, populate_endpoints, populate_initial_config_rules, subscribe_kpi, unsubscribe_kpi, update_endpoints, _raw_config_rules_to_grpc subscribe_kpi, unsubscribe_kpi, update_endpoints, update_sap_id, _raw_config_rules_to_grpc ) LOGGER = logging.getLogger(__name__) Loading @@ -55,6 +55,7 @@ class DeviceServiceServicerImpl(DeviceServiceServicer): self.monitoring_loops = monitoring_loops self.mutex_queues = MutexQueues() LOGGER.debug('Servicer Created') self.sap_id =0 @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def AddDevice(self, request : Device, context : grpc.ServicerContext) -> DeviceId: Loading Loading @@ -93,6 +94,9 @@ class DeviceServiceServicerImpl(DeviceServiceServicer): device_uuid = device.device_id.device_uuid.uuid device_name = device.name update_sap_id(device, self.sap_id) self.sap_id += 1 t2 = time.time() self.mutex_queues.add_alias(device_uuid, device_name) Loading src/device/service/Tools.py +20 −0 Original line number Diff line number Diff line Loading @@ -719,3 +719,23 @@ def extract_resources(config : dict, device : Device) -> list[list[dict], dict]: resources.append({'resource_key': 'upper-frequency', 'value': upper_frequency}) return [resources, conditions] def update_sap_id(device: Device, sap_id: int) -> None: found = False for config_rule in device.device_config.config_rules: if config_rule.WhichOneof('config_rule') == 'custom' and config_rule.custom.resource_key == '_connect/settings': try: settings = json.loads(config_rule.custom.resource_value) except ValueError: settings = {} settings['sap_id'] = str(sap_id) config_rule.custom.resource_value = json.dumps(settings) found = True break if not found: new_rule = device.device_config.config_rules.add() new_rule.action = ConfigActionEnum.CONFIGACTION_SET new_rule.custom.resource_key = '_connect/settings' settings = {'sap_id': str(sap_id)} new_rule.custom.resource_value = json.dumps(settings) src/device/service/drivers/openconfig/OpenConfigDriver.py +2 −0 Original line number Diff line number Diff line Loading @@ -294,6 +294,7 @@ class OpenConfigDriver(_Driver): self.__out_samples = queue.Queue() self.__netconf_handler = NetconfSessionHandler(self.address, self.port, **(self.settings)) self.__samples_cache = SamplesCache(self.__netconf_handler, self.__logger) self.sap_id = 0 # Initialize sap_id to zero def Connect(self) -> bool: with self.__lock: Loading Loading @@ -340,6 +341,7 @@ class OpenConfigDriver(_Driver): MSG = 'Exception retrieving {:s}: {:s}' self.__logger.exception(MSG.format(str_resource_name, str(resource_key))) results.append((resource_key, e)) # if validation fails, store the exception self.sap_id += 1 return results @metered_subclass_method(METRICS_POOL) Loading Loading
.gitlab-ci.yml +1 −1 Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ include: #- local: '/src/l3_distributedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_centralizedattackdetector/.gitlab-ci.yml' #- local: '/src/l3_attackmitigator/.gitlab-ci.yml' - local: '/src/slice/.gitlab-ci.yml' #- local: '/src/slice/.gitlab-ci.yml' #- local: '/src/interdomain/.gitlab-ci.yml' - local: '/src/pathcomp/.gitlab-ci.yml' #- local: '/src/dlt/.gitlab-ci.yml' Loading
src/common/tools/rest_conf/client/RestConfClient.py +1 −1 Original line number Diff line number Diff line Loading @@ -26,7 +26,7 @@ class RestConfClient(RestApiClient): username : Optional[str] = None, password : Optional[str] = None, restconf_version : Optional[str] = None, timeout : int = 30, verify_certs : bool = True, allow_redirects : bool = True, logger : Optional[logging.Logger] = None logger : Optional[logging.Logger] = None, **kwargs ) -> None: super().__init__( address, port=port, scheme=scheme, username=username, password=password, Loading
src/device/service/DeviceServiceServicerImpl.py +5 −1 Original line number Diff line number Diff line Loading @@ -37,7 +37,7 @@ from .Tools import ( check_connect_rules, check_no_endpoints, compute_rules_to_add_delete, configure_rules, deconfigure_rules, get_device_controller_uuid, populate_config_rules, populate_endpoint_monitoring_resources, populate_endpoints, populate_initial_config_rules, subscribe_kpi, unsubscribe_kpi, update_endpoints, _raw_config_rules_to_grpc subscribe_kpi, unsubscribe_kpi, update_endpoints, update_sap_id, _raw_config_rules_to_grpc ) LOGGER = logging.getLogger(__name__) Loading @@ -55,6 +55,7 @@ class DeviceServiceServicerImpl(DeviceServiceServicer): self.monitoring_loops = monitoring_loops self.mutex_queues = MutexQueues() LOGGER.debug('Servicer Created') self.sap_id =0 @safe_and_metered_rpc_method(METRICS_POOL, LOGGER) def AddDevice(self, request : Device, context : grpc.ServicerContext) -> DeviceId: Loading Loading @@ -93,6 +94,9 @@ class DeviceServiceServicerImpl(DeviceServiceServicer): device_uuid = device.device_id.device_uuid.uuid device_name = device.name update_sap_id(device, self.sap_id) self.sap_id += 1 t2 = time.time() self.mutex_queues.add_alias(device_uuid, device_name) Loading
src/device/service/Tools.py +20 −0 Original line number Diff line number Diff line Loading @@ -719,3 +719,23 @@ def extract_resources(config : dict, device : Device) -> list[list[dict], dict]: resources.append({'resource_key': 'upper-frequency', 'value': upper_frequency}) return [resources, conditions] def update_sap_id(device: Device, sap_id: int) -> None: found = False for config_rule in device.device_config.config_rules: if config_rule.WhichOneof('config_rule') == 'custom' and config_rule.custom.resource_key == '_connect/settings': try: settings = json.loads(config_rule.custom.resource_value) except ValueError: settings = {} settings['sap_id'] = str(sap_id) config_rule.custom.resource_value = json.dumps(settings) found = True break if not found: new_rule = device.device_config.config_rules.add() new_rule.action = ConfigActionEnum.CONFIGACTION_SET new_rule.custom.resource_key = '_connect/settings' settings = {'sap_id': str(sap_id)} new_rule.custom.resource_value = json.dumps(settings)
src/device/service/drivers/openconfig/OpenConfigDriver.py +2 −0 Original line number Diff line number Diff line Loading @@ -294,6 +294,7 @@ class OpenConfigDriver(_Driver): self.__out_samples = queue.Queue() self.__netconf_handler = NetconfSessionHandler(self.address, self.port, **(self.settings)) self.__samples_cache = SamplesCache(self.__netconf_handler, self.__logger) self.sap_id = 0 # Initialize sap_id to zero def Connect(self) -> bool: with self.__lock: Loading Loading @@ -340,6 +341,7 @@ class OpenConfigDriver(_Driver): MSG = 'Exception retrieving {:s}: {:s}' self.__logger.exception(MSG.format(str_resource_name, str(resource_key))) results.append((resource_key, e)) # if validation fails, store the exception self.sap_id += 1 return results @metered_subclass_method(METRICS_POOL) Loading