def create(scope): CNDB = scope.CNDB PAP = scope.PAP Adr = CNDB.IP4_Network.net_address.P_Type mgr = PAP.Person \ (first_name = 'Ralf', last_name = 'Schlatterbeck', raw = True) node1 = CNDB.Node(name="nogps", manager=mgr, raw=True) gps1 = dict(lat="48 d 15 m", lon="15 d 52 m 27.84 s") node2 = CNDB.Node \ (name = "node2", manager = mgr, position = gps1, raw = True) net = CNDB.IP4_Network('192.168.23.0/24', raw=True) a1 = net.reserve('192.168.23.1/32') a2 = net.reserve(Adr('192.168.23.2/32')) a3 = net.reserve('192.168.23.3/32') a4 = net.reserve(Adr('192.168.23.4/32')) devtype = CNDB.Net_Device_Type.instance_or_new \ (name = 'Generic', raw = True) dev = CNDB.Net_Device \ (left = devtype, node = node2, name = 'dev', raw = True) wr = CNDB.Wired_Interface(left=dev, name='wr', raw=True) wl = CNDB.Wireless_Interface(left=dev, name='wl', raw=True) ir1 = CNDB.Net_Interface_in_IP4_Network(wr, a1, mask_len=24) il1 = CNDB.Net_Interface_in_IP4_Network(wl, a2, mask_len=32) ir2 = CNDB.Net_Interface_in_IP4_Network(wr, a3, mask_len=24) il2 = CNDB.Net_Interface_in_IP4_Network(wl, a4, mask_len=24)
def net_fixtures(scope): """ Create more fixtures for testing IP allocation and polymorphic queries on owner. """ create(scope) scope.commit() CNDB = scope.CNDB PAP = scope.PAP cta = PAP.Person \ (first_name = 'Christian', last_name = 'Tanzer', raw = True) dtype = CNDB.Net_Device_Type.instance(name='Generic', raw=True) rsc = PAP.Person.query(first_name='ralf').one() swing = PAP.Company(name="Swing") ff = PAP.Association(name="Funkfeuer") n1 = CNDB.Node \ (name = "Node-net1", manager = cta, owner = swing, raw = True) n2 = CNDB.Node(name="Node-net2", manager=cta, owner=ff, raw=True) n3 = CNDB.Node(name="Node-net3", manager=rsc, owner=ff, raw=True) n4 = CNDB.Node(name="Node-net4", manager=rsc, raw=True) net = CNDB.IP4_Network \ (net_address = '10.10.0.0/16', owner = ff, raw = True) nv6 = CNDB.IP6_Network('2001:db8::/32', owner=swing, raw=True) n1d1 = CNDB.Net_Device \ (left = dtype, node = n1, name = 'n1d1', raw = True) n1d2 = CNDB.Net_Device \ (left = dtype, node = n1, name = 'n1d2', raw = True) n2d1 = CNDB.Net_Device \ (left = dtype, node = n2, name = 'n2d1', raw = True) n2d2 = CNDB.Net_Device \ (left = dtype, node = n2, name = 'n2d2', raw = True) n2d3 = CNDB.Net_Device \ (left = dtype, node = n2, name = 'n2d3', raw = True) n3d1 = CNDB.Net_Device \ (left = dtype, node = n3, name = 'n3d1', raw = True) n4d1 = CNDB.Net_Device \ (left = dtype, node = n4, name = 'n4d1', raw = True) n4d2 = CNDB.Net_Device \ (left = dtype, node = n4, name = 'n4d2', raw = True) n4d3 = CNDB.Net_Device \ (left = dtype, node = n4, name = 'n4d3', raw = True) n4d4 = CNDB.Net_Device \ (left = dtype, node = n4, name = 'n4d4', raw = True) n4d5 = CNDB.Net_Device \ (left = dtype, node = n4, name = 'n4d5', raw = True)
from __future__ import absolute_import, unicode_literals from _CNDB import CNDB from _GTW import GTW from _TFL import TFL import _CNDB._GTW.deploy import _GTW._Werkzeug.deploy import _CNDB._Base_Command_ class CNDB_Command \ ( CNDB._Base_Command_ , CNDB.GTW.deploy.Command , GTW.Werkzeug.deploy.Command ) : _defaults = dict \ ( app_dir = "www/app" , app_module = "./Command.py" , bugs_address = "[email protected],[email protected]" , copyright_holder = "Mag. Christian Tanzer, Ralf Schlatterbeck" , languages = "de,en" ) Command = CNDB_Command # end class if __name__ != "__main__" : CNDB._Export_Module () ### __END__ CNDB.deploy
_Sub_Command_ = _CNDB_Sub_Command_ # end class class CNDB_Command (CNDB._Base_Command_, GTW.Werkzeug.Command) : _rn_prefix = "CNDB_" _opts = \ ( "-auth_required:B=True?Is authorization required?" , ) _template_prefixes = dict \ ( CNDB = sos.path.dirname (_CNDB._JNJ.__file__) ) class _CNDB_Collect_Garbage_ (_Sub_Command_) : """Collect freed IP addresses out of cooldown""" _Collect_Garbage_ = _CNDB_Collect_Garbage_ # end class def _handle_collect_garbage (self, cmd) : scope = self._handle_load (cmd) for ipn in scope.CNDB.IP_Network.query (~MOM.Q.parent) : ipn.collect_garbage () # end def _handle_collect_garbage Command = CNDB_Command # end class if __name__ != "__main__" : CNDB._Export ("*") ### __END__ CNDB.Command
# You should have received a copy of the GNU Affero General Public License # along with this module. If not, see <http://www.gnu.org/licenses/>. # #*** </License> ***********************************************************# # #++ # Name # CNDB.OMP__init__ # # Purpose # Package defining the common node database model for Community Networks. # # Revision Dates # 07-Jul-2014 (CT) Creation # ««revision-date»»··· #-- from __future__ import absolute_import, division, print_function, unicode_literals from _MOM import MOM from _CNDB import CNDB import _MOM.Derived_PNS _desc_ = """ Object model defining the common node database model for Community Networks. """ OMP = MOM.Derived_PNS (parent = MOM, pns_alias = "CNDB") CNDB._Export ("OMP") ### __END__ CNDB.OMP__init__
# Copyright (C) 2012 Mag. Christian Tanzer. All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This package is part of the package CNDB. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # CNDB.JNJ.__init__ # # Purpose # Jinja templates for CNDB # # Revision Dates # 6-Jun-2012 (CT) Creation # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _CNDB import CNDB JNJ = Package_Namespace () CNDB._Export ("JNJ") del Package_Namespace ### __END__ CNDB.JNJ.__init__
from _CNDB import CNDB from _GTW import GTW from _TFL import TFL import _CNDB._GTW.deploy import _GTW._Werkzeug.deploy import _CNDB._Base_Command_ class CNDB_Command \ ( CNDB._Base_Command_ , CNDB.GTW.deploy.Command , GTW.Werkzeug.deploy.Command ) : _defaults = dict \ ( app_dir = "www/app" , app_module = "./Command.py" , bugs_address = "[email protected],[email protected]" , copyright_holder = "Mag. Christian Tanzer, Ralf Schlatterbeck" , languages = "de,en" ) Command = CNDB_Command # end class if __name__ != "__main__": CNDB._Export_Module() ### __END__ CNDB.deploy
# Copyright (C) 2012 Mag. Christian Tanzer. All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This package is part of the package CNDB. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # CNDB.GTW.__init__ # # Purpose # RESTful web services for CNDB # # Revision Dates # 6-Jun-2012 (CT) Creation # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _CNDB import CNDB GTW = Package_Namespace() CNDB._Export("GTW") del Package_Namespace ### __END__ CNDB.GTW.__init__
# ««revision-date»»··· #-- from __future__ import division, print_function from __future__ import absolute_import, unicode_literals from _CNDB import CNDB from _TFL import TFL import _TFL.Command class _Base_Command_(TFL.Command.Root_Command): class Config_Dirs(TFL.Command.Root_Command.Config_Dirs): _defaults = \ ( "~/" , "$app_dir/../.." , "~/httpd_config" , "$app_dir/httpd_config" ) # end class Config_Dirs # end class _Base_Command_ if __name__ != "__main__": CNDB._Export("_Base_Command_") ### __END__ CNDB._Base_Command_
# 5-Sep-2014 (CT) Creation (factored from FFW) # ««revision-date»»··· #-- from __future__ import division, print_function from __future__ import absolute_import, unicode_literals from _CNDB import CNDB from _TFL import TFL import _TFL.Command class _Base_Command_ (TFL.Command.Root_Command) : class Config_Dirs (TFL.Command.Root_Command.Config_Dirs) : _defaults = \ ( "~/" , "$app_dir/../.." , "~/httpd_config" , "$app_dir/httpd_config" ) # end class Config_Dirs # end class _Base_Command_ if __name__ != "__main__" : CNDB._Export ("_Base_Command_") ### __END__ CNDB._Base_Command_
# This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # #*** </License> ***********************************************************# # #++ # Name # CNDB.OMP__init__ # # Purpose # Package defining the common node database model for Community Networks. # # Revision Dates # 07-Jul-2014 (CT) Creation # ««revision-date»»··· #-- from __future__ import absolute_import, division, print_function, unicode_literals from _MOM import MOM from _CNDB import CNDB import _MOM.Derived_PNS _desc_ = """ Object model defining the common node database model for Community Networks. """ OMP = MOM.Derived_PNS(parent=MOM, pns_alias="CNDB") CNDB._Export("OMP") ### __END__ CNDB.OMP__init__
def create(scope): """Create fixtures for common node database""" Auth = scope.Auth CNDB = scope.CNDB ant = CNDB.Antenna_Type \ ( name = "Generic" , desc = "for unknown antennae" , gain = "20.0" , polarization = "horizontal" , raw = True ) CNDB.Antenna_Band \ (ant, band = dict (lower = "1 Hz", upper = "1 THz"), raw = True) CNDB.Net_Device_Type \ (name = "Generic", desc = "for unknown or planned devices", raw = True) s11a = CNDB.Wireless_Standard \ (name = "802.11a", bandwidth = "20 MHz", raw = True) s11b = CNDB.Wireless_Standard \ (name = "802.11b", bandwidth = "20 MHz", raw = True) s11g = CNDB.Wireless_Standard \ (name = "802.11g", bandwidth = "20 MHz", raw = True) s11n = CNDB.Wireless_Standard \ (name = "802.11n", bandwidth = "40 MHz", raw = True) for std in s11b, s11g: CNDB.Wireless_Channel \ (left = std, number = "1", frequency = "2412 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "2", frequency = "2417 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "3", frequency = "2422 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "4", frequency = "2427 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "5", frequency = "2432 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "6", frequency = "2437 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "7", frequency = "2442 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "8", frequency = "2447 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "9", frequency = "2452 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "10", frequency = "2457 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "11", frequency = "2462 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "12", frequency = "2467 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "13", frequency = "2472 MHz", raw = True) CNDB.Wireless_Channel \ (left = std, number = "14", frequency = "2484 MHz", raw = True) # 802.11a CNDB.Wireless_Channel \ (left = s11a, number = "36", frequency = "5180 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "40", frequency = "5200 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "44", frequency = "5220 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "48", frequency = "5240 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "52", frequency = "5260 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "56", frequency = "5280 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "60", frequency = "5300 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "64", frequency = "5320 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "100", frequency = "5500 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "104", frequency = "5520 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "108", frequency = "5540 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "112", frequency = "5560 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "116", frequency = "5580 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "120", frequency = "5600 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "124", frequency = "5620 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "128", frequency = "5640 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "132", frequency = "5660 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "136", frequency = "5680 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "140", frequency = "5700 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "149", frequency = "5745 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "153", frequency = "5765 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "157", frequency = "5785 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "161", frequency = "5805 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "165", frequency = "5825 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "172", frequency = "5860 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "173", frequency = "5865 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "174", frequency = "5870 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "175", frequency = "5875 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "176", frequency = "5880 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "177", frequency = "5885 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "178", frequency = "5890 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "179", frequency = "5895 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "180", frequency = "5900 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "181", frequency = "5905 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "182", frequency = "5910 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11a, number = "183", frequency = "5915 MHz", raw = True) # channels not listed on # http://linuxwireless.org/en/developers/Documentation/ChannelList #CNDB.Wireless_Channel \ # (left = s11a, number = "147", frequency = "5735 MHz", raw = True) #CNDB.Wireless_Channel \ # (left = s11a, number = "151", frequency = "5755 MHz", raw = True) #CNDB.Wireless_Channel \ # (left = s11a, number = "155", frequency = "5775 MHz", raw = True) #CNDB.Wireless_Channel \ # (left = s11a, number = "167", frequency = "5835 MHz", raw = True) # 802.11n CNDB.Wireless_Channel \ (left = s11n, number = "36", frequency = "5180 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "40", frequency = "5200 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "44", frequency = "5220 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "48", frequency = "5240 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "52", frequency = "5260 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "56", frequency = "5280 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "60", frequency = "5300 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "64", frequency = "5320 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "100", frequency = "5500 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "104", frequency = "5520 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "108", frequency = "5540 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "112", frequency = "5560 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "116", frequency = "5580 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "120", frequency = "5600 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "124", frequency = "5620 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "128", frequency = "5640 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "132", frequency = "5660 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "136", frequency = "5680 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "149", frequency = "5745 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "153", frequency = "5765 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "157", frequency = "5785 MHz", raw = True) CNDB.Wireless_Channel \ (left = s11n, number = "161", frequency = "5805 MHz", raw = True) # See # http://git.kernel.org/?p=linux/kernel/git/linville/wireless-regdb.git # FIXME: Use parser dbparse.py from above # and import db.txt from above dom = CNDB.Regulatory_Domain(countrycode="AT", raw=True) CNDB.Regulatory_Permission \ ( left = dom , band = dict (lower = "2402 MHz", upper = "2482 MHz") , bandwidth = "40 MHz" , eirp = "20 dBm" , raw = True ) CNDB.Regulatory_Permission \ ( left = dom , band = dict (lower = "5170 MHz", upper = "5250 MHz") , bandwidth = "40 MHz" , eirp = "20 dBm" , raw = True ) CNDB.Regulatory_Permission \ ( left = dom , band = dict (lower = "5250 MHz", upper = "5330 MHz") , bandwidth = "40 MHz" , eirp = "20 dBm" , need_DFS = "yes" , raw = True ) CNDB.Regulatory_Permission \ ( left = dom , band = dict (lower = "5490 MHz", upper = "5710 MHz") , bandwidth = "40 MHz" , eirp = "27 dBm" , need_DFS = "yes" , raw = True ) scope.commit()
class CNDB_Command(CNDB._Base_Command_, GTW.Werkzeug.Command): _rn_prefix = "CNDB_" _opts = \ ( "-auth_required:B=True?Is authorization required?" , ) _template_prefixes = dict \ ( CNDB = sos.path.dirname (_CNDB._JNJ.__file__) ) class _CNDB_Collect_Garbage_(_Sub_Command_): """Collect freed IP addresses out of cooldown""" _Collect_Garbage_ = _CNDB_Collect_Garbage_ # end class def _handle_collect_garbage(self, cmd): scope = self._handle_load(cmd) for ipn in scope.CNDB.IP_Network.query(~MOM.Q.parent): ipn.collect_garbage() # end def _handle_collect_garbage Command = CNDB_Command # end class if __name__ != "__main__": CNDB._Export("*") ### __END__ CNDB.Command
# Copyright (C) 2012 Mag. Christian Tanzer. All rights reserved # Glasauergasse 32, A--1130 Wien, Austria. [email protected] # **************************************************************************** # This package is part of the package CNDB. # # This module is licensed under the terms of the BSD 3-Clause License # <http://www.c-tanzer.at/license/bsd_3c.html>. # **************************************************************************** # #++ # Name # CNDB.GTW.__init__ # # Purpose # RESTful web services for CNDB # # Revision Dates # 6-Jun-2012 (CT) Creation # ««revision-date»»··· #-- from _TFL.Package_Namespace import Package_Namespace from _CNDB import CNDB GTW = Package_Namespace () CNDB._Export ("GTW") del Package_Namespace ### __END__ CNDB.GTW.__init__