Commit 0b2d1010 authored by Janis Streib's avatar Janis Streib 🦉
Browse files

FIX: rollback of some changes until path search is implemented in js

parent 70aaecff
Pipeline #157688 passed with stages
in 7 minutes and 15 seconds
......@@ -539,6 +539,160 @@ class APIToken(MetaDBObject):
self.login_name = None
class NDPPort(DBObject):
TABLE = 'nd_p_port'
def __init__(self, name, module=None, **kwargs):
self.name = name
self.module = module
@staticmethod
def get_nd_p_port_by_vlan(db, connection, vlan_id, ni_name):
res = db.execute(connection,
"""
select nd_mdl_typ_class.name as root_nd_mdl_typ_class_name, root_typ.name as root_nd_mdl_typ_name, dst.name as nd_p_port_name, root.name as root_nd_mdl_name, mod.name as base_nd_mdl_name,
nd_room.name as nd_room_name, nd_room.nr as nd_room_nr, nd_floor.nr as nd_floor_nr, nd_floor.descr as nd_floor_descr,
nd_bldg.nr as nd_bldg_nr, nd_bldg.name as nd_bldg_name from nd_dev
INNER JOIN dns_ntree on nd_dev.dns_ntree_key_nr=dns_ntree.key_nr
inner join nd_l_port on nd_dev.key_nr=nd_l_port.nd_dev_key_nr
inner join nd_vlan on nd_l_port.nd_vlan_key_nr=nd_vlan.key_nr
inner join nd_net_instnc on nd_vlan.nd_net_instnc_key_nr=nd_net_instnc.key_nr
inner join nd_l2p_port on nd_l_port.key_nr=nd_l2p_port.nd_l_port_key_nr
inner join nd_p_port src on nd_l2p_port.nd_p_port_key_nr = src.key_nr
inner join nd_p_port dst on src.nd_dest_p_port_key_nr=dst.key_nr
inner join nd_mdl mod on dst.nd_mdl_key_nr=mod.key_nr
inner join nd_mdl root on mod.nd_root_mdl_key_nr=root.key_nr
inner join nd_room on root.nd_room_key_nr=nd_room.key_nr
inner join nd_floor on nd_room.nd_floor_key_nr=nd_floor.key_nr
inner join nd_bldg on nd_room.nd_bldg_key_nr=nd_bldg.key_nr
inner join nd_mdl_typ root_typ on root.nd_mdl_typ_key_nr = root_typ.key_nr
inner join nd_mdl_typ_class on root_typ.nd_mdl_typ_class_key_nr=nd_mdl_typ_class.key_nr
where nd_net_instnc.name = {ni_name} and nd_vlan.id = {vlan_id}
""",
{'ni_name': ni_name, 'vlan_id': vlan_id})
if len(res) == 0:
return None
return [NDPPort(
**_marshal_dict(r, NDPPort),
module=NDModule(**_marshal_dict(_marshal_dict_str(r, 'base'), NDModule),
root_module=NDModule(**_marshal_dict(_marshal_dict_str(r, 'root'), NDModule),
room=NDRoom(
**_marshal_dict(r, NDRoom)),
floor=NDFloor(
**_marshal_dict(r, NDFloor)),
building=NDBuilding(
**_marshal_dict(r, NDBuilding)),
module_type=NDModuleType(
**_marshal_dict(_marshal_dict_str(r, 'root'), NDModuleType),
type_class=NDModuleTypeClass(
**_marshal_dict(_marshal_dict_str(r, 'root'),
NDModuleTypeClass)
)
)
),
)
) for r in res]
@staticmethod
def get_nd_p_port_by_dev_fqdn_and_port_name(db, connection, fqdn, port):
res = db.execute(connection,
"""
select nd_mdl_typ_class.name as root_nd_mdl_typ_class_name, root_typ.name as root_nd_mdl_typ_name, dst.name as nd_p_port_name, root.name as root_nd_mdl_name, mod.name as base_nd_mdl_name,
nd_room.name as nd_room_name, nd_room.nr as nd_room_nr, nd_floor.nr as nd_floor_nr, nd_floor.descr as nd_floor_descr,
nd_bldg.nr as nd_bldg_nr, nd_bldg.name as nd_bldg_name from nd_dev
INNER JOIN dns_ntree on nd_dev.dns_ntree_key_nr=dns_ntree.key_nr
inner join nd_l_port on nd_dev.key_nr=nd_l_port.nd_dev_key_nr
inner join nd_l2p_port on nd_l_port.key_nr=nd_l2p_port.nd_l_port_key_nr
inner join nd_p_port src on nd_l2p_port.nd_p_port_key_nr = src.key_nr
inner join nd_p_port dst on src.nd_dest_p_port_key_nr=dst.key_nr
inner join nd_mdl mod on dst.nd_mdl_key_nr=mod.key_nr
inner join nd_mdl root on mod.nd_root_mdl_key_nr=root.key_nr
inner join nd_room on root.nd_room_key_nr=nd_room.key_nr
inner join nd_floor on nd_room.nd_floor_key_nr=nd_floor.key_nr
inner join nd_bldg on nd_room.nd_bldg_key_nr=nd_bldg.key_nr
inner join nd_mdl_typ root_typ on root.nd_mdl_typ_key_nr = root_typ.key_nr
inner join nd_mdl_typ_class on root_typ.nd_mdl_typ_class_key_nr=nd_mdl_typ_class.key_nr
where dns_ntree.fqdn = {fqdn} and nd_l_port.name={port}
""",
{'port': port, 'fqdn': fqdn})
if len(res) == 0:
return None
res = res[0]
return NDPPort(
**_marshal_dict(res, NDPPort),
module=NDModule(**_marshal_dict(_marshal_dict_str(res, 'base'), NDModule),
root_module=NDModule(**_marshal_dict(_marshal_dict_str(res, 'root'), NDModule),
room=NDRoom(
**_marshal_dict(res, NDRoom)),
floor=NDFloor(
**_marshal_dict(res, NDFloor)),
building=NDBuilding(
**_marshal_dict(res, NDBuilding)),
module_type=NDModuleType(
**_marshal_dict(_marshal_dict_str(res, 'root'), NDModuleType),
type_class=NDModuleTypeClass(
**_marshal_dict(_marshal_dict_str(res, 'root'),
NDModuleTypeClass)
)
)
),
)
)
class NDBuilding(DBObject):
TABLE = 'nd_bldg'
def __init__(self, nr, name=None, **kwargs):
self.nr = nr
self.name = name
class NDFloor(DBObject):
TABLE = 'nd_floor'
def __init__(self, nr, descr=None, **kwargs):
self.nr = nr
self.description = descr
class NDRoom(DBObject):
TABLE = 'nd_room'
def __init__(self, nr, name=None, **kwargs):
self.nr = nr
self.name = name
class NDModule(DBObject):
TABLE = 'nd_mdl'
def __init__(self, name, descr=None, root_module=None, room=None, floor=None, building=None, module_type=None,
**kwargs):
self.name = name
self.description = descr
self.root_module = root_module
self.room = room
self.building = building
self.floor = floor
self.module_type = module_type
class NDModuleType(DBObject):
TABLE = 'nd_mdl_typ'
def __init__(self, name, type_class=None, **kwargs):
self.name = name
self.type_class = type_class
class NDModuleTypeClass(DBObject):
TABLE = 'nd_mdl_typ_class'
def __init__(self, name, **kwargs):
self.name = name
# Pseudo-objects for strings
class VDNSRecords(DBObject):
......
Markdown is supported
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