From 7ad1d40fd71c613948c9379363b21fed27caf807 Mon Sep 17 00:00:00 2001 From: gifrerenom <lluis.gifre@cttc.es> Date: Sun, 29 Jan 2023 09:08:48 +0000 Subject: [PATCH] Context component: - added logto config rule management for debug purposes --- src/context/service/database/ConfigRule.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/context/service/database/ConfigRule.py b/src/context/service/database/ConfigRule.py index e35f246b6..0f0e9668c 100644 --- a/src/context/service/database/ConfigRule.py +++ b/src/context/service/database/ConfigRule.py @@ -14,6 +14,7 @@ import datetime, json, logging from sqlalchemy import delete +from sqlalchemy.dialects import postgresql from sqlalchemy.dialects.postgresql import insert from sqlalchemy.orm import Session from typing import Dict, List, Optional, Set @@ -104,8 +105,11 @@ def upsert_config_rules( str_config_rule = json.dumps(config_rule) raise Exception(MSG.format(str_config_rule, str(device_uuid), str(service_uuid), str(slice_uuid))) - #LOGGER.warning('uuids_to_delete={:s}'.format(str(uuids_to_delete))) - #LOGGER.warning('rules_to_upsert={:s}'.format(str(rules_to_upsert))) + LOGGER.warning('device_uuid={:s}'.format(str(device_uuid))) + LOGGER.warning('service_uuid={:s}'.format(str(service_uuid))) + LOGGER.warning('slice_uuid={:s}'.format(str(slice_uuid))) + LOGGER.warning('uuids_to_delete={:s}'.format(str(uuids_to_delete))) + LOGGER.warning('rules_to_upsert={:s}'.format(str(rules_to_upsert))) delete_affected = False upsert_affected = False @@ -116,7 +120,14 @@ def upsert_config_rules( if service_uuid is not None: stmt = stmt.where(ConfigRuleModel.service_uuid == service_uuid) if slice_uuid is not None: stmt = stmt.where(ConfigRuleModel.slice_uuid == slice_uuid ) stmt = stmt.where(ConfigRuleModel.configrule_uuid.in_(uuids_to_delete)) - configrule_deletes = session.execute(stmt)#.fetchall() + + str_stmt = stmt.compile(dialect=postgresql.dialect(), compile_kwargs={"literal_binds": True}) + LOGGER.warning('raw delete stmt={:s}'.format(str(str_stmt))) + + configrule_deletes = session.execute(stmt) + + LOGGER.warning('configrule_deletes.rowcount={:s}'.format(str(configrule_deletes.rowcount))) + delete_affected = int(configrule_deletes.rowcount) > 0 if len(rules_to_upsert) > 0: -- GitLab