expects the 'interfaces' key in GetSlivers - review logs to always mention module
[nodemanager.git] / plugins / vsys.py
index d26ee4a..ee806e7 100644 (file)
@@ -10,12 +10,16 @@ from sets import Set
 VSYSCONF="/etc/vsys.conf"
 VSYSBKEND="/vsys"
 
 VSYSCONF="/etc/vsys.conf"
 VSYSBKEND="/vsys"
 
-def start(options, config):
-    pass
+def start(options, conf):
+    logger.log("vsys: plugin starting up...")
 
 
-
-def GetSlivers(data):
+def GetSlivers(data, config=None, plc=None):
     """For each sliver with the vsys attribute, set the script ACL, create the vsys directory in the slice, and restart vsys."""
     """For each sliver with the vsys attribute, set the script ACL, create the vsys directory in the slice, and restart vsys."""
+
+    if 'slivers' not in data:
+        logger.log_missing_data("vsys.GetSlivers",'slivers')
+        return
+
     # Touch ACLs and create dict of available
     scripts = {}
     for script in touchAcls(): scripts[script] = []
     # Touch ACLs and create dict of available
     scripts = {}
     for script in touchAcls(): scripts[script] = []
@@ -23,6 +27,9 @@ def GetSlivers(data):
     slices = []
     _restart = False
     # Parse attributes and update dict of scripts
     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':
     for sliver in data['slivers']:
         for attribute in sliver['attributes']:
             if attribute['tagname'] == 'vsys':
@@ -38,7 +45,7 @@ def GetSlivers(data):
     # Write out the ACLs
     if writeAcls(scripts, parseAcls()) or _restart:
         logger.log("vsys: restarting vsys service")
     # Write out the ACLs
     if writeAcls(scripts, parseAcls()) or _restart:
         logger.log("vsys: restarting vsys service")
-        os.system("/etc/init.d/vsys restart")
+        logger.log_call("/etc/init.d/vsys", "restart")
 
 
 def createVsysDir(sliver):
 
 
 def createVsysDir(sliver):
@@ -138,5 +145,5 @@ def parseConf():
             (path, slice) = line.split()
             slicesinconf.append(slice)
         f.close()
             (path, slice) = line.split()
             slicesinconf.append(slice)
         f.close()
-    except: logger.log_exc()
+    except: logger.log_exc("vsys: failed parseConf")
     return slicesinconf
     return slicesinconf