diff options
Diffstat (limited to 'scripts/lib/mic/plugin.py')
-rw-r--r-- | scripts/lib/mic/plugin.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/scripts/lib/mic/plugin.py b/scripts/lib/mic/plugin.py index 7c296e9765..df03c15081 100644 --- a/scripts/lib/mic/plugin.py +++ b/scripts/lib/mic/plugin.py | |||
@@ -19,13 +19,12 @@ import os, sys | |||
19 | 19 | ||
20 | from mic import msger | 20 | from mic import msger |
21 | from mic import pluginbase | 21 | from mic import pluginbase |
22 | from mic.conf import configmgr | ||
23 | from mic.utils import errors | 22 | from mic.utils import errors |
24 | 23 | ||
25 | 24 | ||
26 | __ALL__ = ['PluginMgr', 'pluginmgr'] | 25 | __ALL__ = ['PluginMgr', 'pluginmgr'] |
27 | 26 | ||
28 | PLUGIN_TYPES = ["imager", "backend"] # TODO "hook" | 27 | PLUGIN_TYPES = ["imager", "source"] # TODO "hook" |
29 | 28 | ||
30 | 29 | ||
31 | class PluginMgr(object): | 30 | class PluginMgr(object): |
@@ -99,4 +98,24 @@ class PluginMgr(object): | |||
99 | 98 | ||
100 | return pluginbase.get_plugins(ptype) | 99 | return pluginbase.get_plugins(ptype) |
101 | 100 | ||
101 | def get_source_plugin_methods(self, source_name, methods): | ||
102 | """ | ||
103 | The methods param is a dict with the method names to find. On | ||
104 | return, the dict values will be filled in with pointers to the | ||
105 | corresponding methods. If one or more methods are not found, | ||
106 | None is returned. | ||
107 | """ | ||
108 | return_methods = None | ||
109 | for _source_name, klass in self.get_plugins('source').iteritems(): | ||
110 | if _source_name == source_name: | ||
111 | for _method_name in methods.keys(): | ||
112 | if not hasattr(klass, _method_name): | ||
113 | msger.warning("Unimplemented %s source interface for: %s"\ | ||
114 | % (_method_name, _source_name)) | ||
115 | return None | ||
116 | func = getattr(klass, _method_name) | ||
117 | methods[_method_name] = func | ||
118 | return_methods = methods | ||
119 | return return_methods | ||
120 | |||
102 | pluginmgr = PluginMgr() | 121 | pluginmgr = PluginMgr() |