reconcile accessors and db-config tags scripts
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 26 Jan 2010 19:50:20 +0000 (19:50 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 26 Jan 2010 19:50:20 +0000 (19:50 +0000)
PLC/Accessors/Accessors_standard.py
PLC/Accessors/Factory.py
db-config.d/011-node_tags [deleted file]
db-config.d/011-standard_tags [new file with mode: 0644]
db-config.d/012-interface_tags [deleted file]
db-config.d/012-wireless_tags [new file with mode: 0644]
db-config.d/013-wireless_tags [deleted file]

index 9d3c1e1..a5f42d9 100644 (file)
@@ -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)
index 2dd2a73..abd34fd 100644 (file)
@@ -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 (file)
index 3d03521..0000000
+++ /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 (file)
index 0000000..64d0ddf
--- /dev/null
@@ -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 (file)
index e184c39..0000000
+++ /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 (file)
index 0000000..9bf1f96
--- /dev/null
@@ -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 (file)
index 77c6683..0000000
+++ /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)