From: Thierry Parmentelat Date: Sat, 25 May 2013 17:52:19 +0000 (+0200) Subject: reverting Scott's change - he is to use aspects instead X-Git-Tag: plcapi-5.2-3~3 X-Git-Url: http://git.onelab.eu/?p=plcapi.git;a=commitdiff_plain;h=45ce8eea321e3fe32ac0c031df1ea0553cc249f5 reverting Scott's change - he is to use aspects instead --- diff --git a/PLC/Methods/AddSliceToNodes.py b/PLC/Methods/AddSliceToNodes.py index a7124d8..db074ca 100644 --- a/PLC/Methods/AddSliceToNodes.py +++ b/PLC/Methods/AddSliceToNodes.py @@ -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 diff --git a/PLC/Methods/DeleteSliceFromNodes.py b/PLC/Methods/DeleteSliceFromNodes.py index 2c15d58..1a82ad1 100644 --- a/PLC/Methods/DeleteSliceFromNodes.py +++ b/PLC/Methods/DeleteSliceFromNodes.py @@ -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 index 375ec11..0000000 --- a/PLC/Plugins.py +++ /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__ -