make plc.py simpler to reduce the dependencies for plc_hosts_to_nagios.
[monitor.git] / monitor / wrapper / plc.py
index 5e6fb7f..8eba805 100644 (file)
@@ -12,7 +12,6 @@ import xml, xmlrpclib
 import logging
 import time
 import traceback
-from monitor import database
 
 # note: this needs to be consistent with the value in PLEWWW/planetlab/includes/plc_functions.php
 PENDING_CONSORTIUM_ID = 0
@@ -90,54 +89,7 @@ class PLC:
                return self.api.__repr__()
 
 
-class CachedPLC(PLC):
-
-       def _param_to_str(self, name, *params):
-               fields = len(params)
-               retstr = ""
-               retstr += "%s-" % name
-               for x in params:
-                       retstr += "%s-" % x
-               return retstr[:-1]
-
-       def __getattr__(self, name):
-               method = getattr(self.api, name)
-               if method is None:
-                       raise AssertionError("method does not exist")
-
-               def run_or_returncached(*params):
-                       cachename = self._param_to_str(name, *params)
-                       #print "cachename is %s" % cachename
-                       if hasattr(config, 'refresh'):
-                               refresh = config.refresh
-                       else:
-                               refresh = False
-
-                       if 'Get' in name:
-                               if not database.cachedRecently(cachename):
-                                       load_old_cache = False
-                                       try:
-                                               values = method(self.auth, *params)
-                                       except:
-                                               print "Call %s FAILED: Using old cached data" % cachename
-                                               load_old_cache = True
-
-                                       if load_old_cache:
-                                               values = database.dbLoad(cachename)
-                                       else:
-                                               database.dbDump(cachename, values)
-
-                                       return values
-                               else:
-                                       values = database.dbLoad(cachename)
-                                       return values
-                       else:
-                               return method(self.auth, *params)
-
-               return run_or_returncached
-
 api = PLC(auth.auth, auth.server)
-cacheapi = CachedPLC(auth.auth, auth.server)
 
 
 def getAPI(url):