logs for when PLC is unreachable
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 28 Jan 2010 17:24:03 +0000 (17:24 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 28 Jan 2010 17:24:03 +0000 (17:24 +0000)
conf_files.py
logger.py
plugins/codemux.py
plugins/rawdisk.py
plugins/sliverauth.py
plugins/specialaccounts.py
plugins/vsys.py
plugins/vsys_privs.py
sm.py

index bccf20a..9e2c257 100644 (file)
@@ -79,7 +79,8 @@ class conf_files:
             for f in data['conf_files']:
                 try: self.update_conf_file(f)
                 except: logger.log_exc("failed to update conf_file")
-        else: logger.log("conf_files: No conf_files found or API failure.  Skipping")
+        else: 
+            logger.log_missing_data("conf_files.run_once",'conf_files')
 
 
 def start(options, config): pass
index 7dff05e..eff93e6 100644 (file)
--- a/logger.py
+++ b/logger.py
@@ -58,6 +58,12 @@ def log_exc(msg="",name=None):
     else:
         log("EXCEPTION caught <%s> \n %s" %(msg, traceback.format_exc()))
 
+# for some reason the various modules are still triggered even when the
+# data from PLC cannot be reached
+# we show this message instead of the exception stack instead in this case
+def log_missing_data (msg,key):
+    log("%s: could not find the %s key in data (PLC connection down?) - IGNORED"%(msg,key))
+
 def log_data_in_file (data, file, message=""):
     import pprint, time
     try:
index 84b0f4e..731b74d 100644 (file)
@@ -36,6 +36,9 @@ def GetSlivers(data, config, plc = None):
     else: _writeconf = True
 
     # Parse attributes and update dict of scripts
+    if 'slivers' not in data:
+        logger.log_missing_data("codemux.GetSlivers", 'slivers')
+        return
     for sliver in data['slivers']:
         for attribute in sliver['attributes']:
             if attribute['tagname'] == 'codemux':
index ad84761..641bc69 100644 (file)
@@ -51,7 +51,7 @@ def get_unused_devices():
 
 def GetSlivers(data, config=None, plc=None):
     if 'slivers' not in data: 
-        logger.log("sliverauth: getslivers data lack's sliver information. IGNORING!")
+        logger.log_missing_data("rawdisk.GetSlivers",'slivers')
         return
 
     devices = get_unused_devices()
index ad813b8..bf35830 100644 (file)
@@ -46,7 +46,7 @@ def GetSlivers(data, config, plc):
             return
 
     if 'slivers' not in data:
-        logger.log("sliverauth: getslivers data lack's sliver information. IGNORING!")
+        logger.log_missing_data("sliverauth.GetSlivers", 'slivers')
         return
 
     for sliver in data['slivers']:
index 9396062..cef877e 100644 (file)
@@ -27,7 +27,7 @@ def start(options, conf):
 
 def GetSlivers(data, conf = None, plc = None):
     if 'accounts' not in data: 
-        logger.log("specialaccounts: No account information found.  DISABLED!")
+        logger.log_missing_data("specialaccounts.GetSlivers",'accounts')
         return
 
     for account in data['accounts']:
index f33d11b..05b87cd 100644 (file)
@@ -22,6 +22,9 @@ def GetSlivers(data, config=None, plc=None):
     slices = []
     _restart = False
     # Parse attributes and update dict of scripts
+    if 'slivers' not in data:
+        logger.log_missing_data("vsys.GetSlivers",'slivers')
+        return
     for sliver in data['slivers']:
         for attribute in sliver['attributes']:
             if attribute['tagname'] == 'vsys':
index f30012d..5cd40a2 100755 (executable)
@@ -23,6 +23,9 @@ def GetSlivers(data, config=None, plc=None):
     privs = {}
 
     # Parse attributes and update dict of scripts
+    if 'slivers' not in data:
+        logger.log_missing_data("vsys_privs.GetSlivers",'slivers')
+        return
     for sliver in data['slivers']:
         slice = sliver['name']
         for attribute in sliver['attributes']:
diff --git a/sm.py b/sm.py
index 25b5e87..8c04760 100644 (file)
--- a/sm.py
+++ b/sm.py
@@ -82,6 +82,9 @@ def GetSlivers(data, config = None, plc=None, fullupdate=True):
                 DEFAULT_ALLOCATION['net_max_rate'] = network['bwlimit'] / 1000
 
     # Take intscripts (global) returned by API, make dict
+    if 'initscripts' not in data:
+        logger.log_missing_data("sm.GetSlivers",'initscripts')
+        return
     initscripts = {}
     for is_rec in data['initscripts']:
         logger.verbose("initscript: %s" % is_rec['name'])