Commit 7ad1d40f authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Context component:

- added logto config rule management for debug purposes
parent c2a789ad
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -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: