Commit 740d4f6c authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Pre-release fixing

parent 2dac8825
Loading
Loading
Loading
Loading
+9 −18
Original line number Diff line number Diff line
@@ -100,20 +100,14 @@ class EventsDeviceCollector:
                    self._name_mapping.set_device_name(device_uuid, device.name)

                    old_operational_status = self._device_to_state.get(device_uuid, DEVICE_OP_STATUS_UNDEFINED)
                    LOGGER.info('old_operational_status={:s}'.format(str(old_operational_status)))
                    device_was_not_enabled = (old_operational_status in DEVICE_OP_STATUS_NOT_ENABLED)
                    LOGGER.info('device_was_not_enabled={:s}'.format(str(device_was_not_enabled)))

                    new_operational_status = device.device_operational_status
                    LOGGER.info('new_operational_status={:s}'.format(str(new_operational_status)))
                    device_is_enabled = (new_operational_status == DEVICE_OP_STATUS_ENABLED)
                    LOGGER.info('device_is_enabled={:s}'.format(str(device_is_enabled)))
                    self._device_to_state[device_uuid] = new_operational_status

                    activate_monitoring = device_was_not_enabled and device_is_enabled
                    LOGGER.info('activate_monitoring={:s}'.format(str(activate_monitoring)))
                    if not activate_monitoring:
                        LOGGER.info('device not ready for activation')
                        # device is not ready for monitoring
                        continue

@@ -122,17 +116,11 @@ class EventsDeviceCollector:
                    enabled_endpoint_names = set()
                    for config_rule in device.device_config.config_rules:
                        LOGGER.info(grpc_message_to_json_string(config_rule))
                        if config_rule.action != ConfigActionEnum.CONFIGACTION_SET:
                            LOGGER.info('  not set config rule')
                            continue
                        if config_rule.WhichOneof('config_rule') != 'custom':
                            LOGGER.info('  not custom')
                            continue
                        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['):
                            LOGGER.info('  not /interface')
                            continue
                        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:
@@ -150,12 +138,15 @@ class EventsDeviceCollector:
                    LOGGER.info('enabled_endpoint_names={:s}'.format(str(enabled_endpoint_names)))

                    for endpoint in device.device_endpoints:
                        LOGGER.info('  endpoint: {:s}'.format(str(endpoint.name)))
                        if endpoint.name not in enabled_endpoint_names:
                        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

                        endpoint_uuid = endpoint.endpoint_id.endpoint_uuid.uuid
                        self._name_mapping.set_endpoint_name(endpoint_uuid, endpoint.name)

                        for value in endpoint.kpi_sample_types: