Commit d0172421 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Monitoring component:

- Enhanced logic to detect enabled endpoints and devices
parent 2859baad
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -108,12 +108,15 @@ class EventsDeviceCollector:
                        if config_rule.action != ConfigActionEnum.CONFIGACTION_SET: continue
                        if config_rule.WhichOneof('config_rule') != 'custom': continue
                        str_resource_key = str(config_rule.custom.resource_key)
                        if not str_resource_key.startswith('/interface['): continue
                        if str_resource_key.startswith('/interface[') or str_resource_key.startswith('/endpoints/endpoint['):
                            json_resource_value = json.loads(config_rule.custom.resource_value)
                            if 'name' not in json_resource_value: continue
                        if 'enabled' not in json_resource_value: continue
                            if 'enabled' in json_resource_value:
                                if not json_resource_value['enabled']: continue
                                enabled_endpoint_names.add(json_resource_value['name'])
                            if 'oper-status' in json_resource_value:
                                if str(json_resource_value['oper-status']).upper() != 'UP': continue
                                enabled_endpoint_names.add(json_resource_value['name'])

                    endpoints_monitored = self._device_endpoint_monitored.setdefault(device_uuid, dict())
                    for endpoint in device.device_endpoints:
@@ -127,7 +130,10 @@ class EventsDeviceCollector:
                        endpoint_was_monitored = endpoints_monitored.get(endpoint_uuid, False)
                        endpoint_is_enabled = (endpoint_name_or_uuid in enabled_endpoint_names)

                        if not endpoint_was_monitored and endpoint_is_enabled:
                        if not endpoint_was_monitored and not endpoint_is_enabled:
                            # endpoint is idle, do nothing
                            pass
                        elif not endpoint_was_monitored and endpoint_is_enabled:
                            # activate
                            for value in endpoint.kpi_sample_types:
                                if value == KPISAMPLETYPE_UNKNOWN: continue