Commit a6e0aa4b authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Technologies

--HG--
branch : develop
parent 22cf8bee
//---------------------------------------------------------------------
// inv.technology application
//---------------------------------------------------------------------
// Copyright (C) 2007-2014 The NOC Project
// See LICENSE for details
//---------------------------------------------------------------------
console.debug("Defining NOC.inv.technology.Application");
Ext.define("NOC.inv.technology.Application", {
extend: "NOC.core.ModelApplication",
requires: [
"NOC.inv.technology.Model"
],
model: "NOC.inv.technology.Model",
search: true,
initComponent: function() {
var me = this;
me.jsonPanel = Ext.create("NOC.core.JSONPreview", {
app: me,
restUrl: "/inv/technology/{{id}}/json/",
previewName: "Technology: {{name}}"
});
me.ITEM_JSON = me.registerItem(me.jsonPanel);
Ext.apply(me, {
columns: [
{
text: "Name",
dataIndex: "name",
width: 150
},
{
text: "Description",
dataIndex: "description",
flex: 1
}
],
fields: [
{
name: "name",
xtype: "textfield",
fieldLabel: "Name",
allowBlank: false
},
{
name: "uuid",
xtype: "displayfield",
fieldLabel: "UUID",
allowBlank: true
},
{
name: "description",
xtype: "textarea",
fieldLabel: "Description",
allowBlank: true
}
],
formToolbar: [
{
text: "JSON",
glyph: NOC.glyph.file,
tooltip: "Show JSON",
hasAccess: NOC.hasPermission("read"),
scope: me,
handler: me.onJSON
}
]
});
me.callParent();
},
//
onJSON: function() {
var me = this;
me.showItem(me.ITEM_JSON);
me.jsonPanel.preview(me.currentRecord);
}
});
//---------------------------------------------------------------------
// NOC.inv.technology.Lookup
//---------------------------------------------------------------------
// Copyright (C) 2007-2014 The NOC Project
// See LICENSE for details
//---------------------------------------------------------------------
console.debug("Defining NOC.inv.technology.Lookup");
Ext.define("NOC.inv.technology.Lookup", {
extend: "NOC.core.Lookup",
url: "/inv/technology/lookup/"
});
//---------------------------------------------------------------------
// NOC.inv.technology.Lookup
//---------------------------------------------------------------------
// Copyright (C) 2007-2014 The NOC Project
// See LICENSE for details
//---------------------------------------------------------------------
console.debug("Defining NOC.inv.technology.LookupField");
Ext.define("NOC.inv.technology.LookupField", {
extend: "NOC.core.LookupField",
alias: "widget.inv.technology.LookupField",
requires: ["NOC.inv.technology.Lookup"]
});
//---------------------------------------------------------------------
// inv.technology Model
//---------------------------------------------------------------------
// Copyright (C) 2007-2014 The NOC Project
// See LICENSE for details
//---------------------------------------------------------------------
console.debug("Defining NOC.inv.technology.Model");
Ext.define("NOC.inv.technology.Model", {
extend: "Ext.data.Model",
rest_url: "/inv/technology/",
fields: [
{
name: "id",
type: "string"
},
{
name: "uuid",
type: "string"
},
{
name: "description",
type: "string"
},
{
name: "name",
type: "string"
}
]
});
# -*- coding: utf-8 -*-
##----------------------------------------------------------------------
## inv.technology unittes
##----------------------------------------------------------------------
## Copyright (C) 2007-2014 The NOC Project
## See LICENSE for details
##----------------------------------------------------------------------
## NOC modules
from noc.lib.test import RestModelTestCase, unittest
@unittest.skip("Not ready")
class TechnologyTestCase(RestModelTestCase):
app = "inv.technology"
scenario = [
{
"GET": {
# key: value
},
"POST": {
# key: value
},
"PUT": {
# key: value
}
}
]
# -*- coding: utf-8 -*-
##----------------------------------------------------------------------
## inv.technology application
##----------------------------------------------------------------------
## Copyright (C) 2007-2014 The NOC Project
## See LICENSE for details
##----------------------------------------------------------------------
## NOC modules
from noc.lib.app import ExtDocApplication, view
from noc.inv.models import Technology
class TechnologyApplication(ExtDocApplication):
"""
Technology application
"""
title = "Technology"
menu = "Setup | Technologies"
model = Technology
search = ["name"]
{
"name": "Packet | DOCSIS",
"uuid": "abd729b4-b9c0-4394-8d1c-75c36c45304d",
"description": "DOCSIS"
}
{
"name": "Packet | IPoE",
"uuid": "c0add299-57df-46cc-aa9d-6146e6247777",
"description": "IP over Ethernet"
}
{
"name": "Packet | PPPoE",
"uuid": "5e2d7644-84b2-4990-abc5-fe94c42c5c8f",
"description": "PPP over Ethernet"
}
{
"name": "Packet | PPTP",
"uuid": "dc63d901-4f6b-491b-9904-7167be4ece44",
"description": "PPTP"
}
{
"name": "Phone | VoIP",
"uuid": "76e1c701-49e2-4877-883d-96376ea0d814",
"description": "Voice-over-IP"
}
{
"name": "TV | Cable",
"uuid": "8a3f6a7e-ecac-4034-9ec1-865b05fddb26",
"description": "PAL/SECAM/NTSC Cable TV"
}
{
"name": "TV | DVB-C",
"uuid": "a4c5dd3d-de82-448c-b6b8-30a30b058c95",
"description": "Digital video broadcasting - Cable"
}
name,uuid,path,hash
Packet | DOCSIS,abd729b4-b9c0-4394-8d1c-75c36c45304d,Packet/DOCSIS.json,c457c17307b009775ae29bc8bccfa29b17d7663002f525e68072ee832522e4c5
Packet | IPoE,c0add299-57df-46cc-aa9d-6146e6247777,Packet/IPoE.json,48ed4a6ac22f01a0e3ccd36c3f2acdb1e26aedeef1d179f703bfc72c3e9bbd2c
Packet | PPPoE,5e2d7644-84b2-4990-abc5-fe94c42c5c8f,Packet/PPPoE.json,22ac92ed9bde4ac12185ec656bae357e7b2bb1f7c2191b09dbb5557a5861df85
Packet | PPTP,dc63d901-4f6b-491b-9904-7167be4ece44,Packet/PPTP.json,4548d4bc9981850d53532d2ec50967447470ce376297b42ac3236335d10fd4c5
Phone | VoIP,76e1c701-49e2-4877-883d-96376ea0d814,Phone/VoIP.json,ee9424a7df1abeaf201e481d1c5b945f75a44219b1086f5a06b664af00ddddd3
TV | Cable,8a3f6a7e-ecac-4034-9ec1-865b05fddb26,TV/Cable.json,51c7410d994adb5b1caf5fe12a2adc4d423c55e139c58d7f2f5219ba0f1b999a
TV | DVB-C,a4c5dd3d-de82-448c-b6b8-30a30b058c95,TV/DVB-C.json,aa7cd7d8bf61e34691beebb32ee8a11d5a38947da12fdf04d886fe6f24a85ebc
......@@ -21,6 +21,7 @@ from connectionrule import ConnectionRule
from objectmodel import ObjectModel
from unknownmodel import UnknownModel
from modelmapping import ModelMapping
from technology import Technology
class SocketAttribute(EmbeddedDocument):
......
## -*- coding: utf-8 -*-
##----------------------------------------------------------------------
## Technology
##----------------------------------------------------------------------
## Copyright (C) 2007-2014 The NOC Project
## See LICENSE for details
##----------------------------------------------------------------------
## Python modules
import os
## Third-party modules
from mongoengine.document import Document
from mongoengine.fields import StringField, UUIDField
## NOC modules
from noc.lib.prettyjson import to_json
from noc.lib.text import quote_safe_path
class Technology(Document):
"""
Equipment vendor
"""
meta = {
"collection": "noc.technologies",
"allow_inheritance": False,
"json_collection": "inv.technologies"
}
# Group | Name
name = StringField(unique=True)
uuid = UUIDField(binary=True)
description = StringField()
def __unicode__(self):
return self.name
def get_json_path(self):
p = [quote_safe_path(n.strip()) for n in self.name.split("|")]
return os.path.join(*p) + ".json"
def to_json(self):
r = {
"name": self.name,
"uuid": self.uuid
}
if self.description:
r["description"] = self.description
return to_json(r, order=["name", "uuid", "description"])
......@@ -16,6 +16,7 @@ from django.core.management.base import BaseCommand, CommandError
from noc.lib.collection import Collection
from noc.main.models.doccategory import DocCategory
from noc.gis.models.layer import Layer
from noc.inv.models.technology import Technology
from noc.inv.models.vendor import Vendor
from noc.inv.models.modelinterface import ModelInterface
from noc.inv.models.connectiontype import ConnectionType
......@@ -90,6 +91,7 @@ class Command(BaseCommand):
# Gis
("gis.layers", Layer),
# Inventory
("inv.technologies", Technology),
("inv.vendors", Vendor),
("inv.modelinterfaces", ModelInterface),
("inv.connectiontypes", ConnectionType),
......
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