From 9fe08b5200dc92216a234a7c919a3ad0e0209f99 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Wed, 12 Sep 2012 16:29:18 -0400 Subject: [PATCH] updated default config path --- PLC/API.py | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/PLC/API.py b/PLC/API.py index 9f13f383..33fd1209 100644 --- a/PLC/API.py +++ b/PLC/API.py @@ -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. -- 2.47.0