reverting Scott's change - he is to use aspects instead
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Sat, 25 May 2013 17:52:19 +0000 (19:52 +0200)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Sat, 25 May 2013 17:52:19 +0000 (19:52 +0200)
PLC/Methods/AddSliceToNodes.py
PLC/Methods/DeleteSliceFromNodes.py
PLC/Plugins.py [deleted file]

index a7124d8..db074ca 100644 (file)
@@ -5,7 +5,6 @@ from PLC.Nodes import Node, Nodes
 from PLC.Slices import Slice, Slices
 from PLC.Persons import Person, Persons
 from PLC.Auth import Auth
-from PLC.Plugins import PluginManager
 
 class AddSliceToNodes(Method):
     """
@@ -70,6 +69,4 @@ class AddSliceToNodes(Method):
                               'Slice': [slice['slice_id']]}
         self.message = 'Slice %d added to nodes %s' % (slice['slice_id'], nodeids)
 
-        PluginManager(self.api, auth).notify("slice.AddToNodes", self.event_objects)
-
         return 1
index 2c15d58..1a82ad1 100644 (file)
@@ -4,7 +4,6 @@ from PLC.Parameter import Parameter, Mixed
 from PLC.Nodes import Node, Nodes
 from PLC.Slices import Slice, Slices
 from PLC.Auth import Auth
-from PLC.Plugins import PluginManager
 
 class DeleteSliceFromNodes(Method):
     """
@@ -59,6 +58,4 @@ class DeleteSliceFromNodes(Method):
         self.event_objects = {'Node': [node['node_id'] for node in nodes],
                               'Slice': [slice['slice_id']]}
 
-        PluginManager(self.api, auth).notify("slice.DeleteFromNodes", self.event_objects)
-
         return 1
diff --git a/PLC/Plugins.py b/PLC/Plugins.py
deleted file mode 100644 (file)
index 375ec11..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-import sys
-import pkg_resources
-import traceback
-
-from PLC.Debug import log
-
-"""
-from PLC.Plugins import PluginManager
-pm = PluginManager(None, None)
-pm.dump()
-pm.notify("who", {"what": "this!"})
-"""
-
-class PluginManager:
-    def __init__(self, api, auth):
-        self.api = api
-        self.auth = auth
-        self.plugins = []
-
-        for entrypoint in pkg_resources.iter_entry_points("plcapi.plugin","api_notify"):
-            save = sys.path
-            try:
-                # pkg_resources looks for modules in sys.path. Make sure it can
-                # find our plugins.
-                sys.path.append("/usr/share/plc_api")
-
-                try:
-                    pluginclass = entrypoint.load()
-                    plugin = pluginclass()
-                    self.plugins.append(plugin)
-                except Exception, exc:
-                    print >>log, "WARNING: failed to load plugin %s" % str(entrypoint)
-                    traceback.print_exc(5,log)
-            finally:
-                sys.path = save
-
-    def notify(self, action, info={}):
-        for plugin in self.plugins:
-            try:
-                plugin.notify(self.api, self.auth, action, info)
-            except Exception, exc:
-                print >>log, "WARNING: failed to run plugin during action %s" % str(action)
-                traceback.print_exc(5,log)
-
-    def dump(self):
-        for plugin in self.plugins:
-            print plugin.__class__.__name__
-