updated default config path
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Wed, 12 Sep 2012 20:29:18 +0000 (16:29 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Wed, 12 Sep 2012 20:29:18 +0000 (16:29 -0400)
PLC/API.py

index 9f13f38..33fd120 100644 (file)
@@ -123,7 +123,7 @@ class PLCAPI:
 
     all_methods = native_methods + other_methods_map.keys()
 
-    def __init__(self, config = "/etc/planetlab/plc_config", encoding = "utf-8"):
+    def __init__(self, config = "/etc/planetlab/plcapi_config", encoding = "utf-8"):
         self.encoding = encoding
 
         # Better just be documenting the API
@@ -133,48 +133,19 @@ class PLCAPI:
         # Load configuration
         self.config = Config(config)
 
-        # Initialize database connection
-        if self.config.PLC_DB_TYPE == "postgresql":
-            from PLC.PostgreSQL import PostgreSQL
-            self.db = PostgreSQL(self)
-        else:
-            raise PLCAPIError, "Unsupported database type " + self.config.PLC_DB_TYPE
-
         # Aspects modify the API by injecting code before, after or
         # around method calls. -- http://github.com/baris/pyaspects/blob/master/README
         # 
         # As of now we only have aspects for OMF integration, that's
         # why we enable aspects only if PLC_OMF is set to true.
-        if self.config.PLC_OMF_ENABLED:
+        if self.config.api_omf_enabled:
             from aspects import apply_omf_aspect
             apply_omf_aspect()
         
-        if self.config.PLC_RATELIMIT_ENABLED:
+        if self.config.api_ratelimit_enabled:
             from aspects import apply_ratelimit_aspect
             apply_ratelimit_aspect()
 
-
-        # Enable Caching. Only for GetSlivers for the moment.
-        # TODO: we may consider to do this in an aspect like the ones above.
-        try:
-            if self.config.PLC_GETSLIVERS_CACHE:
-                getslivers_cache = True
-        except AttributeError:
-            getslivers_cache = False
-
-        if getslivers_cache:
-            os.environ['DJANGO_SETTINGS_MODULE']='plc_django_settings'
-            from cache_utils.decorators import cached
-            from PLC.Methods.GetSlivers import GetSlivers
-
-            @cached(7200)
-            def cacheable_call(cls, auth, node_id_or_hostname):
-                return cls.raw_call(auth, node_id_or_hostname)
-            
-            GetSlivers.call = cacheable_call
-            
-
-
     def callable(self, method):
         """
         Return a new instance of the specified method.