Commit 1a3fbf20 authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Merge branch 'patch-avs-add-ip-param-confdb' into 'master'

Add IP type to ConfDB Query params.

See merge request noc/noc!5890
parents f72095e7 c5f12ddf
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# ConfDBQuery model # ConfDBQuery model
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project # Copyright (C) 2007-2021 The NOC Project
# See LICENSE for details # See LICENSE for details
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
...@@ -22,19 +22,31 @@ from mongoengine.fields import ( ...@@ -22,19 +22,31 @@ from mongoengine.fields import (
import cachetools import cachetools
# NOC modules # NOC modules
from noc.core.ip import IP
from noc.core.prettyjson import to_json from noc.core.prettyjson import to_json
from noc.core.text import quote_safe_path from noc.core.text import quote_safe_path
from noc.core.model.decorator import on_delete_check from noc.core.model.decorator import on_delete_check
from noc.sa.interfaces.base import StringParameter, IntParameter, BooleanParameter from noc.sa.interfaces.base import StringParameter, IntParameter, BooleanParameter
class IPParameter(object):
def clean(self, value):
return IP.prefix(value)
id_lock = threading.Lock() id_lock = threading.Lock()
TYPE_MAP = {"str": StringParameter(), "int": IntParameter(), "bool": BooleanParameter()} TYPE_MAP = {
"str": StringParameter(),
"int": IntParameter(),
"bool": BooleanParameter(),
"ip": IPParameter(),
}
class ConfDBQueryParam(EmbeddedDocument): class ConfDBQueryParam(EmbeddedDocument):
meta = {"strict": False} meta = {"strict": False}
name = StringField() name = StringField()
type = StringField(choices=["str", "int", "bool"]) type = StringField(choices=["str", "int", "bool", "ip"])
default = StringField() default = StringField()
description = StringField() description = StringField()
......
...@@ -81,7 +81,8 @@ Ext.define("NOC.cm.confdbquery.Application", { ...@@ -81,7 +81,8 @@ Ext.define("NOC.cm.confdbquery.Application", {
store: [ store: [
["str", "str"], ["str", "str"],
["int", "int"], ["int", "int"],
["bool", "bool"] ["bool", "bool"],
["ip", "IP"]
] ]
} }
}, },
......
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