[node-patches] Change in ovirt-node[master]: app: Raise exception on duplicate plugin name
fabiand at fedoraproject.org
fabiand at fedoraproject.org
Fri May 24 08:46:39 UTC 2013
Fabian Deutsch has uploaded a new change for review.
Change subject: app: Raise exception on duplicate plugin name
......................................................................
app: Raise exception on duplicate plugin name
Just a check to prevent that two plugins use the same name in the UI.
Change-Id: Ia316f33a6984d72a478db5ee5112eb46001c8d5c
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/Makefile.am
M src/ovirt/node/app.py
M src/ovirt/node/installer/core/__init__.py
M src/ovirt/node/plugins.py
4 files changed, 21 insertions(+), 9 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/47/15047/1
diff --git a/src/Makefile.am b/src/Makefile.am
index 4914d11..7635995 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -144,7 +144,7 @@
# Setup CIM Plugin
pyovirt_node_setup_cim_PYTHON = \
ovirt/node/setup/cim/cim_page.py \
- ovirt/node/setup/cim/cim_model.py \
+ ovirt/node/setup/cim/cim_model.py
# Setup SNMP Plugin
pyovirt_node_setup_snmp_PYTHON = \
diff --git a/src/ovirt/node/app.py b/src/ovirt/node/app.py
index 3ae0a9e..23ff4f5 100644
--- a/src/ovirt/node/app.py
+++ b/src/ovirt/node/app.py
@@ -388,6 +388,9 @@
plugin = m.Plugin(self)
self.logger.debug("Registering plugin '%s': %s" %
(plugin.name(), plugin))
+ if plugin.name() in self.__plugins:
+ raise RuntimeError(("Plugin with name '%s' is already " +
+ "registered" % plugin.name()))
self.__plugins[plugin.name()] = plugin
else:
self.logger.debug("Found no plugin in module: %s" % m)
diff --git a/src/ovirt/node/installer/core/__init__.py b/src/ovirt/node/installer/core/__init__.py
index 3909e81..ec31eaa 100644
--- a/src/ovirt/node/installer/core/__init__.py
+++ b/src/ovirt/node/installer/core/__init__.py
@@ -1,3 +1,3 @@
"""
Core Installer Plugins
-"""
\ No newline at end of file
+"""
diff --git a/src/ovirt/node/plugins.py b/src/ovirt/node/plugins.py
index f02c0c3..5213839 100644
--- a/src/ovirt/node/plugins.py
+++ b/src/ovirt/node/plugins.py
@@ -18,12 +18,16 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
+from ovirt.node import base, exceptions, ui
+import logging
+import pkgutil
"""
This contains much stuff related to plugins
"""
-from ovirt.node import base, exceptions, ui
-import pkgutil
+
+
+logger = logging.getLogger(__name__)
def __walk_plugins(module):
@@ -37,9 +41,13 @@
"""Load all plugins
"""
modules = []
+ logger.debug("Loading modules/plugins from module: %s" % basemodule)
for groupmodule in __get_plugin_groups(basemodule):
- for plugin in __get_plugins_for_group(groupmodule):
- modules.append(plugin)
+ logger.debug("Found plugin-group: %s" % groupmodule)
+ for pluginmodule in __get_plugins_for_group(groupmodule):
+ logger.debug("Found plugin: %s" % pluginmodule)
+ modules.append(pluginmodule)
+ logger.debug("Finished loading modules/plugins")
return modules
@@ -52,9 +60,10 @@
def __get_plugins_for_group(groupmodule):
for importer, modname, ispkg in __walk_plugins(groupmodule):
- if (not ispkg and
- not modname.startswith("_") and
- not modname.startswith(".")):
+ is_candidate = lambda: (not ispkg and
+ not modname.startswith("_") and
+ not modname.startswith("."))
+ if is_candidate():
modpath = groupmodule.__name__ + "." + modname
yield __import_by_modname(modpath)
--
To view, visit http://gerrit.ovirt.org/15047
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia316f33a6984d72a478db5ee5112eb46001c8d5c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>
More information about the node-patches
mailing list