Make it easier to have deployment-specific db-config additions.
[myplc.git] / db-config
index 419fbae..f664044 100755 (executable)
--- a/db-config
+++ b/db-config
@@ -12,6 +12,7 @@
 
 from plc_config import PLCConfiguration
 import sys
+import resource
 
 def main():
     cfg = PLCConfiguration()
@@ -521,8 +522,26 @@ def main():
          'description': "Demux HTTP between slices using localhost ports. Value in the form 'host, localhost port'.",
          'min_role_id': 10},
 
+        # Delegation
+        {'name': "delegations",
+         'description': "Comma-seperated list of slices to give delegation authority to.",
+         'min_role_id': 10},
+
         ]
 
+    # add in the platform supported rlimits to the default_attribute_types
+    for entry in resource.__dict__.keys():
+        if entry.find("RLIMIT_")==0:
+            rlim = entry[len("RLIMIT_"):]
+            rlim = rlim.lower()
+            for ty in ("min","soft","hard"):
+                attribute = {
+                    'name': "%s_%s'%(rlim,ty)",
+                    'description': "Per sliver RLIMIT %s_%s."%(rlim,ty),
+                    'min_role_id': 40 #admin
+                    }
+                default_attribute_types.append(attribute)
+
     # Get list of existing attribute types
     attribute_types = GetSliceAttributeTypes()
     attribute_types = [attribute_type['name'] for attribute_type in attribute_types]
@@ -1018,6 +1037,19 @@ message, please reply so that we may investigate the problem.
             for ptype in protocol_types:
                 AddPCUProtocolType(id, ptype)
 
+    # Run local db-config snippets
+    try:
+        dir = "/etc/planetlab/db-config.d"
+        files = os.listdir(dir)
+        for file in files:
+            if (file.endswith(".bak") or file.endswith("~") or
+                file.endswith(".rpmsave") or file.endswith(".rpmnew") or
+                file.endswith(".orig")):
+                continue
+            execfile(os.path.join(dir, file))
+    except:
+        pass
+
 
 if __name__ == '__main__':
     main()