Commit 7b0ea61b authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Merge branch 'noc-521' into 'microservices'

#521 Use managed object selector when rule is any

See merge request !237
parents 5f697896 6b1ce54e
Pipeline #2841 passed with stage
in 36 seconds
......@@ -10,8 +10,8 @@
import re
# NOC modules
from noc.lib.nosql import (Document, EmbeddedDocument, StringField,
ListField, EmbeddedDocumentField, BooleanField, ForeignKeyField,
IntField, PlainReferenceField)
ListField, EmbeddedDocumentField, BooleanField, ForeignKeyField,
IntField, PlainReferenceField)
from noc.core.ip import IP
from noc.main.models import PrefixTable
from interfaceprofile import InterfaceProfile
......@@ -124,7 +124,7 @@ class InterfaceClassificationMatch(EmbeddedDocument):
]
return "\n".join(r)
## Untagged
# Untagged
def compile_untagged_eq(self, f_name):
vlan = int(self.value)
if vlan < 1 or vlan > 4096:
......@@ -148,7 +148,7 @@ class InterfaceClassificationMatch(EmbeddedDocument):
]
return "\n".join(r)
## Tagged
# Tagged
def compile_tagged_eq(self, f_name):
vlan = int(self.value)
if vlan < 1 or vlan > 4096:
......@@ -189,7 +189,7 @@ class InterfaceClassificationRule(Document):
EmbeddedDocumentField(InterfaceClassificationMatch),
required=False)
profile = PlainReferenceField(InterfaceProfile,
default=InterfaceProfile.get_default_profile)
default=InterfaceProfile.get_default_profile)
def __unicode__(self):
r = [unicode(x) for x in self.match]
......@@ -245,7 +245,10 @@ class InterfaceClassificationRule(Document):
" return bson.ObjectId('%s')" % rule.profile.id
]
else:
mf += [" return bson.ObjectId('%s')" % rule.profile.id]
mf += [
" if in_selector(mo, %d):" % rule.selector.id,
" return bson.ObjectId('%s')" % rule.profile.id
]
r += mf
return "\n".join(r)
......
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