Provide versioned myplc so versioned Requires will work correctly.
[myplc.git] / db-config
index 1eed60c..0457887 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()
@@ -240,7 +241,7 @@ def main():
          'category' : 'slice/rspec',
          'min_role_id': 10},
 
-               # Vsys
+        # Vsys
         {'tagname': "vsys",
          'description': "Bind vsys script fd's to a slice's vsys directory.",
          'category' : 'slice/rspec',
@@ -252,8 +253,28 @@ def main():
          'category' : 'slice/rspec',
          'min_role_id': 10},
 
+        # Delegation
+        {'tagname': "delegations",
+         'description': "Coma seperated list of slices to give delegation authority to.",
+         'category' : 'slice/rspec',
+         'min_role_id': 10}
+
         ]
 
+    # add in the platform supported rlimits to the default_attribute_types
+    for entry in resource.__dict__.keys() + ["VLIMIT_OPENFD"]:
+        if entry.find("LIMIT_")==1:
+            rlim = entry[len("RLIMIT_"):]
+            rlim = rlim.lower()
+            for ty in ("min","soft","hard"):
+                attribute = {
+                    'tagname': "%s_%s"%(rlim,ty),
+                    'description': "Per sliver RLIMIT %s_%s."%(rlim,ty),
+                    'category': 'slice/limit',
+                    'min_role_id': 10 #admin
+                    }
+                default_attribute_types.append(attribute)
+
     # Get list of existing tag types
     known_tag_types = [tag_type['tagname'] for tag_type in GetTagTypes()]
 
@@ -357,16 +378,27 @@ def main():
 
         # YUM configuration
         {'enabled': True,
-         'source': 'PlanetLabConf/yum.conf.php?gpgcheck=1',
+         'source': 'yum/myplc.repo.php?gpgcheck=1',
+         'dest': '/etc/yum.myplc.d/myplc.repo',
+         'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
+         'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
+         'ignore_cmd_errors': False,
+         'always_update': False},
+        {'enabled': True,
+         'source': 'yum/yum.conf',
          'dest': '/etc/yum.conf',
-         'file_permissions': '644',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
+         'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
+         'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
          'ignore_cmd_errors': False,
          'always_update': False},
+        {'enabled': True,
+         'source': 'yum/stock.repo',
+         'dest': '/etc/yum.myplc.d/stock.repo',
+         'file_permissions': '644', 'file_owner': 'root', 'file_group': 'root',
+         'preinstall_cmd': '', 'postinstall_cmd': '', 'error_cmd': '',
+         'ignore_cmd_errors': False,
+         'always_update': False},
+
         {'enabled': True,
          'source': 'PlanetLabConf/delete-rpm-list-production',
          'dest': '/etc/planetlab/delete-rpm-list',
@@ -467,17 +499,6 @@ def main():
          'always_update': False},
 
         # Firewall configuration
-        {'enabled': True,
-         'source': 'PlanetLabConf/iptables',
-         'dest': '/etc/sysconfig/iptables',
-         'file_permissions': '600',
-         'file_owner': 'root',
-         'file_group': 'root',
-         'preinstall_cmd': '',
-         'postinstall_cmd': '',
-         'error_cmd': '',
-         'ignore_cmd_errors': False,
-         'always_update': False},
         {'enabled': True,
          'source': 'PlanetLabConf/blacklist.php',
          'dest': '/etc/planetlab/blacklist',
@@ -643,7 +664,7 @@ def main():
          'expires': 0x7fffffff - (60 * 60 * 24),
          'attributes': [('system', "1"),
                         ('vref', "planetflow"),
-                                               ('vsys', "pfmount")]},
+                        ('vsys', "pfmount")]},
           # Sirius
         {'name': plc['slice_prefix'] + "_sirius",
          'description': 'The Sirius Calendar Service.\n\nSirius provides system-wide reservations of 25% CPU and 2Mb/s outgoing\nbandwidth.  Sign up for hour-long slots using the Web GUI at the\nPlanetLab website.\n\nThis slice should not generate traffic external to PlanetLab.\n',
@@ -671,11 +692,11 @@ def main():
         if slice['slice_attribute_ids']:
             # Delete unknown attributes
             for slice_attribute in GetSliceAttributes(slice['slice_attribute_ids']):
-                if (slice_attribute['name'], slice_attribute['value']) \
+                if (slice_attribute['tagname'], slice_attribute['value']) \
                    not in default_slice['attributes']:
                     DeleteSliceAttribute(slice_attribute['slice_attribute_id'])
                 else:
-                    slice_attributes.append((slice_attribute['name'], slice_attribute['value']))
+                    slice_attributes.append((slice_attribute['tagname'], slice_attribute['value']))
 
         for (name, value) in default_slice['attributes']:
             if (name, value) not in slice_attributes:
@@ -706,6 +727,8 @@ username %(email)s by visiting:
 
 https://%(PLC_WWW_HOST)s:%(PLC_WWW_SSL_PORT)d/db/persons/register.php?id=%(person_id)d&key=%(verification_key)s
 
+You must wait for this account to be approved before you can begin using it, please be patient.
+
 If you did not register for a %(PLC_NAME)s account, please ignore this
 message, or contact %(PLC_NAME)s Support <%(PLC_MAIL_SUPPORT_ADDRESS)s>.
 """
@@ -1055,6 +1078,40 @@ message, please reply so that we may investigate the problem.
             for ptype in protocol_types:
                 AddPCUProtocolType(id, ptype)
 
+    default_boot_states = [
+        'boot',
+        'failboot',
+        'safeboot',
+        'install',
+        'reinstall',
+        'disabled',
+    ]
+    current_boot_states = GetBootStates()
+    for state in default_boot_states:
+        if state not in current_boot_states:
+            AddBootState(state)
+
+    # TODO: Delete old boot states. 
+    # NOTE: Only do this if all federating peers have the new default boot states above.
+    #for state in current_boot_states:
+    #    if state not in default_boot_states:
+    #        DeleteBootState(state)
+
+    # Run local db-config snippets
+    files = []
+    dir = "/etc/planetlab/db-config.d"
+    try:
+        files = os.listdir(dir)
+    except:
+        pass
+
+    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))
+
 
 if __name__ == '__main__':
     main()