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

Add Sensor ETL model.

parent c87106f9
# ----------------------------------------------------------------------
# Sensor loader
# ----------------------------------------------------------------------
# Copyright (C) 2007-2016 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# NOC modules
from .base import BaseLoader
from ..models.sensor import Sensor
from noc.inv.models.object import Object
from noc.inv.models.sensor import Sensor as SensorModel
class SensorLoader(BaseLoader):
"""
Sensor loader
"""
name = "sensor"
model = SensorModel
data_model = Sensor
discard_deferred = True
workflow_event_model = False
def find_object(self, v):
"""
Find object by remote system/remote id
:param v:
:return:
"""
r = super().find_object(v)
if not r:
oo = Object.get_managed(v["managed_object"])
find_query = {"local_id": v["local_id"], "object": oo}
r = self.model.objects.filter(**find_query).first()
return r
# ----------------------------------------------------------------------
# SensorModel
# ----------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for details
# ----------------------------------------------------------------------
# Python modules
from typing import Optional, List
# NOC modules
from .base import BaseModel, Reference
class Sensor(BaseModel):
id: str
local_id: str
units: str
object: Optional[Reference]
managed_object: Optional[Reference]
# Workflow state
state: Optional[str]
labels: List[str] = []
......@@ -31,6 +31,7 @@ class BaseRemoteSystem(object):
"project",
"managedobject",
"link",
"sensor",
"subscriberprofile",
"subscriber",
"serviceprofile",
......
......@@ -105,6 +105,7 @@ class RemoteSystem(Document):
enable_networksegment = BooleanField()
enable_networksegmentprofile = BooleanField()
enable_object = BooleanField()
enable_sensor = BooleanField()
enable_service = BooleanField()
enable_serviceprofile = BooleanField()
enable_street = BooleanField()
......
......@@ -118,6 +118,11 @@ Ext.define("NOC.main.remotesystem.Application", {
xtype: "checkbox",
boxLabel: __("Object")
},
{
name: "enable_sensor",
xtype: "checkbox",
boxLabel: __("Sensor")
},
{
name: "enable_service",
xtype: "checkbox",
......
......@@ -80,6 +80,10 @@ Ext.define("NOC.main.remotesystem.Model", {
name: "enable_object",
type: "boolean"
},
{
name: "enable_sensor",
type: "boolean"
},
{
name: "enable_service",
type: "boolean"
......
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