Commit ef62aadf authored by Andrey Vertiprahov's avatar Andrey Vertiprahov
Browse files

Merge branch 'fix-avs-isrege-label-migration' into 'master'

Add migrate is_regex to is_matching field in Label.

See merge request !6272
parents 8e7bda32 e0b4c5ca
# ----------------------------------------------------------------------
# Migrate is_regex to is_matching field
# ----------------------------------------------------------------------
# Copyright (C) 2007-2022 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# NOC modules
from noc.core.migration.base import BaseMigration
class Migration(BaseMigration):
depends_on = [("main", "0063_migrate_filter_labels")]
def migrate(self):
self.mongo_db["labels"].update_many({"is_regex": True}, {"$set": {"is_matching": True}})
...@@ -1176,7 +1176,7 @@ class Label(Document): ...@@ -1176,7 +1176,7 @@ class Label(Document):
""" """
rxs = [] rxs = []
for ll in Label.objects.filter( for ll in Label.objects.filter(
__raw__={"is_regex": True, "match_regex": {"$elemMatch": {"scope": scope}}} __raw__={"is_matching": True, "match_regex": {"$elemMatch": {"scope": scope}}}
): ):
for rx in ll.match_regex: for rx in ll.match_regex:
if rx.scope == scope: if rx.scope == scope:
......
...@@ -280,7 +280,7 @@ Ext.define("NOC.main.label.Application", { ...@@ -280,7 +280,7 @@ Ext.define("NOC.main.label.Application", {
value: "{is_matching}", value: "{is_matching}",
disabled: "{isEnableDisableRx}" disabled: "{isEnableDisableRx}"
}, },
boxLabel: __("Regexp Label"), boxLabel: __("Is Matching Label"),
}, },
{ {
name: "match_regex", name: "match_regex",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment