Removed unused filtering in get_plugins

Filtering by base class for plugins was never required. The unused
imports removed as well.

This is one of the initial refactoring steps for sahara and plugins into
different projects.

Partially-implements bp: move-plugins-to-separate-repo
Change-Id: I20e83fd432b95c6e86ae218fa1a8e13766e8a461
This commit is contained in:
Nikita Konovalov 2015-06-10 14:27:47 +03:00
parent a951d2a044
commit 93a6a5822d
4 changed files with 5 additions and 12 deletions

View File

@ -114,11 +114,8 @@ class PluginManager(object):
_("Plugins couldn't be loaded: %s") % _("Plugins couldn't be loaded: %s") %
", ".join(requested_plugins - loaded_plugins)) ", ".join(requested_plugins - loaded_plugins))
def get_plugins(self, base): def get_plugins(self):
return [ return [self.plugins[plugin] for plugin in CONF.plugins]
self.plugins[plugin] for plugin in CONF.plugins
if not base or issubclass(self.plugins[plugin].__class__, base)
]
def get_plugin(self, plugin_name): def get_plugin(self, plugin_name):
return self.plugins.get(plugin_name) return self.plugins.get(plugin_name)

View File

@ -22,7 +22,6 @@ from six.moves.urllib import parse as urlparse
from sahara import conductor as c from sahara import conductor as c
from sahara import context from sahara import context
from sahara.plugins import base as plugin_base from sahara.plugins import base as plugin_base
from sahara.plugins import provisioning
from sahara.service import quotas from sahara.service import quotas
from sahara.utils import general as g from sahara.utils import general as g
from sahara.utils.notification import sender from sahara.utils.notification import sender
@ -182,8 +181,7 @@ def update_node_group_template(id, values):
# Plugins ops # Plugins ops
def get_plugins(): def get_plugins():
return plugin_base.PLUGINS.get_plugins( return plugin_base.PLUGINS.get_plugins()
base=provisioning.ProvisioningPluginBase)
def get_plugin(plugin_name, version=None): def get_plugin(plugin_name, version=None):

View File

@ -22,7 +22,6 @@ from sahara import context
from sahara import exceptions as ex from sahara import exceptions as ex
from sahara.i18n import _LE from sahara.i18n import _LE
from sahara.plugins import base as plugin_base from sahara.plugins import base as plugin_base
from sahara.plugins import provisioning
from sahara.service.edp.binary_retrievers import dispatch from sahara.service.edp.binary_retrievers import dispatch
from sahara.service.edp import job_manager as manager from sahara.service.edp import job_manager as manager
from sahara.utils import edp from sahara.utils import edp
@ -54,8 +53,7 @@ def get_job_types(**kwargs):
hints = kwargs.get("hints", ["false"])[0].lower() == "true" hints = kwargs.get("hints", ["false"])[0].lower() == "true"
plugin_names = kwargs.get("plugin", []) plugin_names = kwargs.get("plugin", [])
all_plugins = plugin_base.PLUGINS.get_plugins( all_plugins = plugin_base.PLUGINS.get_plugins()
base=provisioning.ProvisioningPluginBase)
if plugin_names: if plugin_names:
plugins = filter(lambda x: x.name in plugin_names, all_plugins) plugins = filter(lambda x: x.name in plugin_names, all_plugins)
else: else:

View File

@ -25,6 +25,6 @@ class BasePluginsSupportTest(testtools.TestCase):
pb.setup_plugins() pb.setup_plugins()
def test_plugins_loaded(self): def test_plugins_loaded(self):
plugins = [p.name for p in pb.PLUGINS.get_plugins(pb.PluginInterface)] plugins = [p.name for p in pb.PLUGINS.get_plugins()]
self.assertIn('vanilla', plugins) self.assertIn('vanilla', plugins)
self.assertIn('hdp', plugins) self.assertIn('hdp', plugins)