Loading src/monitoring/service/EventTools.py +5 −24 Original line number Diff line number Diff line Loading @@ -87,12 +87,10 @@ class EventsDeviceCollector: event_type = event.event.event_type device_uuid = event.device_id.device_uuid.uuid if event_type in {EventTypeEnum.EVENTTYPE_REMOVE}: LOGGER.info('removing device') self._device_to_state.pop(device_uuid, None) continue if event_type not in {EventTypeEnum.EVENTTYPE_CREATE, EventTypeEnum.EVENTTYPE_UPDATE}: LOGGER.info('unexpected event') # Unknown event type continue Loading @@ -111,7 +109,6 @@ class EventsDeviceCollector: # device is not ready for monitoring continue LOGGER.info('checking endpoints') enabled_endpoint_names = set() for config_rule in device.device_config.config_rules: Loading @@ -119,40 +116,24 @@ 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) LOGGER.info(' str_resource_key={:s}'.format(str(str_resource_key))) if not str_resource_key.startswith('/interface['): continue json_resource_value = json.loads(config_rule.custom.resource_value) LOGGER.info(' json_resource_value={:s}'.format(str(json_resource_value))) if 'name' not in json_resource_value: LOGGER.info(' missing name') continue if 'enabled' not in json_resource_value: LOGGER.info(' missing enabled') continue if not json_resource_value['enabled']: LOGGER.info(' not enabled') continue LOGGER.info(' enabled') if 'name' not in json_resource_value: continue if 'enabled' not in json_resource_value: continue if not json_resource_value['enabled']: continue enabled_endpoint_names.add(json_resource_value['name']) LOGGER.info('enabled_endpoint_names={:s}'.format(str(enabled_endpoint_names))) for endpoint in device.device_endpoints: endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid endpoint_name_or_uuid = endpoint.name if endpoint_name_or_uuid is None or len(endpoint_name_or_uuid) == 0: endpoint_name_or_uuid = endpoint_uuid LOGGER.info(' endpoint: {:s}'.format(str(endpoint_name_or_uuid))) if endpoint_name_or_uuid not in enabled_endpoint_names: LOGGER.info(' skipping not enabled') continue if endpoint_name_or_uuid not in enabled_endpoint_names: continue self._name_mapping.set_endpoint_name(endpoint_uuid, endpoint.name) for value in endpoint.kpi_sample_types: if value == KPISAMPLETYPE_UNKNOWN: LOGGER.info(' unknown kpi sample type') continue if value == KPISAMPLETYPE_UNKNOWN: continue kpi_descriptor = monitoring_pb2.KpiDescriptor() kpi_descriptor.kpi_description = device.device_type Loading Loading
src/monitoring/service/EventTools.py +5 −24 Original line number Diff line number Diff line Loading @@ -87,12 +87,10 @@ class EventsDeviceCollector: event_type = event.event.event_type device_uuid = event.device_id.device_uuid.uuid if event_type in {EventTypeEnum.EVENTTYPE_REMOVE}: LOGGER.info('removing device') self._device_to_state.pop(device_uuid, None) continue if event_type not in {EventTypeEnum.EVENTTYPE_CREATE, EventTypeEnum.EVENTTYPE_UPDATE}: LOGGER.info('unexpected event') # Unknown event type continue Loading @@ -111,7 +109,6 @@ class EventsDeviceCollector: # device is not ready for monitoring continue LOGGER.info('checking endpoints') enabled_endpoint_names = set() for config_rule in device.device_config.config_rules: Loading @@ -119,40 +116,24 @@ 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) LOGGER.info(' str_resource_key={:s}'.format(str(str_resource_key))) if not str_resource_key.startswith('/interface['): continue json_resource_value = json.loads(config_rule.custom.resource_value) LOGGER.info(' json_resource_value={:s}'.format(str(json_resource_value))) if 'name' not in json_resource_value: LOGGER.info(' missing name') continue if 'enabled' not in json_resource_value: LOGGER.info(' missing enabled') continue if not json_resource_value['enabled']: LOGGER.info(' not enabled') continue LOGGER.info(' enabled') if 'name' not in json_resource_value: continue if 'enabled' not in json_resource_value: continue if not json_resource_value['enabled']: continue enabled_endpoint_names.add(json_resource_value['name']) LOGGER.info('enabled_endpoint_names={:s}'.format(str(enabled_endpoint_names))) for endpoint in device.device_endpoints: endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid endpoint_name_or_uuid = endpoint.name if endpoint_name_or_uuid is None or len(endpoint_name_or_uuid) == 0: endpoint_name_or_uuid = endpoint_uuid LOGGER.info(' endpoint: {:s}'.format(str(endpoint_name_or_uuid))) if endpoint_name_or_uuid not in enabled_endpoint_names: LOGGER.info(' skipping not enabled') continue if endpoint_name_or_uuid not in enabled_endpoint_names: continue self._name_mapping.set_endpoint_name(endpoint_uuid, endpoint.name) for value in endpoint.kpi_sample_types: if value == KPISAMPLETYPE_UNKNOWN: LOGGER.info(' unknown kpi sample type') continue if value == KPISAMPLETYPE_UNKNOWN: continue kpi_descriptor = monitoring_pb2.KpiDescriptor() kpi_descriptor.kpi_description = device.device_type Loading