From: Thierry Parmentelat Date: Tue, 26 Jan 2010 19:50:20 +0000 (+0000) Subject: reconcile accessors and db-config tags scripts X-Git-Tag: PLCAPI-5.0-1^2~3 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=8704fb5fa3957670dac9584f197cc46f6390d667;p=plcapi.git reconcile accessors and db-config tags scripts --- diff --git a/PLC/Accessors/Accessors_standard.py b/PLC/Accessors/Accessors_standard.py index 9d3c1e1f..a5f42d9d 100644 --- a/PLC/Accessors/Accessors_standard.py +++ b/PLC/Accessors/Accessors_standard.py @@ -10,14 +10,15 @@ from PLC.Sites import Site from PLC.Persons import Person #from PLC.Ilinks import Ilink -from PLC.Accessors.Factory import define_accessors, all_roles, tech_roles +from PLC.Accessors.Factory import define_accessors, admin_roles, all_roles, tech_roles import sys current_module = sys.modules[__name__] # NOTE. -# most of these tag types are defined in MyPLC/db-config, so any details here in the -# description/category area is unlikely to make it into the database +# The 'Get' and 'Set' accessors defined here automagically create the corresponding TagType in the database +# for safety, some crucial tags are forced to be created at plc startup time, through the db-config.d mechanism +# You might wish to keep this roughly in sync with db-config.d/011-standard_tags # # @@ -93,8 +94,7 @@ define_accessors(current_module, Interface, "Driver", "driver", define_accessors(current_module, Interface, "Alias", "alias", "interface/config", "interface alias", get_roles=all_roles, set_roles=tech_roles) +define_accessors(current_module, Interface, "Backdoor", "backdoor", + "interface/hidden", "For testing new settings", + get_roles=all_roles, set_roles=admin_roles) -# site -define_accessors(current_module, Site, "Foo", "foo", - "site/test", "some name", - get_roles=all_roles, set_roles=all_roles, expose_in_api=True) diff --git a/PLC/Accessors/Factory.py b/PLC/Accessors/Factory.py index 2dd2a733..abd34fda 100644 --- a/PLC/Accessors/Factory.py +++ b/PLC/Accessors/Factory.py @@ -47,6 +47,7 @@ taggable_classes = { Node : {'table_class' : Nodes, } # xxx probably defined someplace else +admin_roles = ['admin'] all_roles = [ 'admin', 'pi', 'tech', 'user', 'node' ] tech_roles = [ 'admin', 'pi', 'tech' ] diff --git a/db-config.d/011-node_tags b/db-config.d/011-node_tags deleted file mode 100644 index 3d035210..00000000 --- a/db-config.d/011-node_tags +++ /dev/null @@ -1,21 +0,0 @@ -# -*-python-*- -# $Id$ -# $URL$ -#################### node tags -default_node_tags = [ - { 'tagname' : 'arch', - 'description' : 'architecture name', - 'category' : 'node/config', - 'min_role_id' : 40} , - { 'tagname' : 'pldistro', - 'description' : 'PlanetLab distribution', - 'category' : 'node/config', - 'min_role_id' : 10} , - { 'tagname' : 'deployment', - 'description' : 'typically "alpha", "beta", or "production"', - 'category' : 'node/operation', - 'min_role_id' : 10} , - - ] - -for node_type in default_node_tags: SetTagType (node_type) diff --git a/db-config.d/011-standard_tags b/db-config.d/011-standard_tags new file mode 100644 index 00000000..64d0ddfb --- /dev/null +++ b/db-config.d/011-standard_tags @@ -0,0 +1,35 @@ +# -*-python-*- +# $Id$ +# $URL$ + +# force creation of tags defined as accessors + +#################### slice tags +GetSliceVref(0) +GetSliceArch(0) +GetSlicePldistro(0) +GetSliceFcdistro(0) + +#################### node tags +# +GetNodeArch(0) +GetNodePldistro(0) +GetNodeFcdistro(0) +GetNodeDeployment(0) +GetNodeExtensions(0) +GetNodePlainBootstrapfs(0) +GetNodeSerial(0) +GetNodeCramfs(0) +GetNodeKvariant(0) +GetNodeKargs(0) +GetNodeNoHangcheck(0) + +#################### interface settings + +# force creation of tags defined as accessors + +GetInterfaceIfname(0) +GetInterfaceDriver(0) +GetInterfaceAlias(0) +GetInterfaceBackdoor(0) + diff --git a/db-config.d/012-interface_tags b/db-config.d/012-interface_tags deleted file mode 100644 index e184c399..00000000 --- a/db-config.d/012-interface_tags +++ /dev/null @@ -1,26 +0,0 @@ -# -*-python-*- -# $Id$ -# $URL$ -#################### interface settings -# xxx this should move to PLC/Accessors - -default_interface_types = \ -[ - {'category' : "interface/general", - 'tagname' : "ifname", - 'description': "Set interface name, instead of eth0 or the like", - 'min_role_id' : 40}, - - {'category' : "interface/multihome", - 'tagname' : "alias", - 'description': "Specifies that the network is used for multihoming", - 'min_role_id' : 40}, - - {'category' : "interface/hidden", - 'tagname' : "backdoor", - 'description': "For testing new settings", - 'min_role_id' : 10}, -] - -for setting_type in default_interface_types: - SetTagType(setting_type) diff --git a/db-config.d/012-wireless_tags b/db-config.d/012-wireless_tags new file mode 100644 index 00000000..9bf1f96d --- /dev/null +++ b/db-config.d/012-wireless_tags @@ -0,0 +1,21 @@ +# -*-python-*- +# $Id: 012-interface_tags -1 $ +# $URL: svn+ssh://thierry@svn.planet-lab.org/svn/MyPLC/trunk/db-config.d/012-interface_tags $ +#################### interface settings + +# force creation of tags defined as accessors +GetInterfaceMode(0) +GetInterfaceEssid(0) +GetInterfaceNw(0) +GetInterfaceFreq(0) +GetInterfaceChannel(0) +GetInterfaceSens(0) +GetInterfaceRate(0) +GetInterfaceKey(0) +GetInterfaceKey1(0) +GetInterfaceKey2(0) +GetInterfaceKey3(0) +GetInterfaceKey4(0) +GetInterfaceSecurityMode(0) +GetInterfaceIwconfig(0) +GetInterfaceIwpriv(0) diff --git a/db-config.d/013-wireless_tags b/db-config.d/013-wireless_tags deleted file mode 100644 index 77c66838..00000000 --- a/db-config.d/013-wireless_tags +++ /dev/null @@ -1,48 +0,0 @@ -# -*-python-*- -# $Id: 012-interface_tags -1 $ -# $URL: svn+ssh://thierry@svn.planet-lab.org/svn/MyPLC/trunk/db-config.d/012-interface_tags $ -#################### interface settings -# xxx this should move to PLC/Accessors - -wireless_interface_types = [ - - { 'category' : "interface/wifi", - 'tagname' : x, - 'description' : "802.11 %s -- see %s"%(y,z), - 'min_role_id' : 40 } for (x,y,z) in [ - - ("mode","Mode","iwconfig"), - - ("essid","ESSID","iwconfig"), - - ("nw","Network Id","iwconfig"), - - ("freq","Frequency","iwconfig"), - - ("channel","Channel","iwconfig"), - - ("sens","sensitivity threshold","iwconfig"), - - ("rate","Rate","iwconfig"), - - ("key","key","iwconfig key"), - - ("key1","key1","iwconfig key [1]"), - - ("key2","key2","iwconfig key [2]"), - - ("key3","key3","iwconfig key [3]"), - - ("key4","key4","iwconfig key [4]"), - - ("securitymode","Security mode","iwconfig enc"), - - ("iwconfig","Additional parameters to iwconfig","ifup-wireless"), - - ("iwpriv","Additional parameters to iwpriv","ifup-wireless"), - - ] - ] - -for setting_type in wireless_interface_types: - SetTagType(setting_type)