summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2016-06-27 09:32:55 +0200
committerJan Cholasta <jcholast@redhat.com>2016-06-30 16:32:20 +0200
commit390fd3d305daf3844dd7c5e36b2d9e7b3c651e3d (patch)
tree9c49eb42ce18e40c85284a397747779e82f8971b
parent1a03bd322df65ecb9302f0cd70ec2b9bbfa3812e (diff)
downloadfreeipa-390fd3d305daf3844dd7c5e36b2d9e7b3c651e3d.tar.gz
freeipa-390fd3d305daf3844dd7c5e36b2d9e7b3c651e3d.tar.xz
freeipa-390fd3d305daf3844dd7c5e36b2d9e7b3c651e3d.zip
plugable: add option to ignore override errors
Add new `no_fail` option to API.add_plugin. When set to True, override errors are ignored and the affected plugins are skipped. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
-rw-r--r--ipalib/plugable.py32
1 files changed, 19 insertions, 13 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index d55a8f7a4..26fbeaa26 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -638,7 +638,7 @@ class API(ReadOnly):
raise errors.PluginModuleError(name=module.__name__)
- def add_plugin(self, plugin, override=False):
+ def add_plugin(self, plugin, override=False, no_fail=False):
"""
Add the plugin ``plugin``.
@@ -662,23 +662,29 @@ class API(ReadOnly):
prev = self.__plugins_by_key.get(plugin.full_name)
if prev:
if not override:
- # Must use override=True to override:
- raise errors.PluginOverrideError(
- base=base.__name__,
- name=plugin.name,
- plugin=plugin,
- )
+ if no_fail:
+ return
+ else:
+ # Must use override=True to override:
+ raise errors.PluginOverrideError(
+ base=base.__name__,
+ name=plugin.name,
+ plugin=plugin,
+ )
self.__plugins.remove(prev)
self.__next[plugin] = prev
else:
if override:
- # There was nothing already registered to override:
- raise errors.PluginMissingOverrideError(
- base=base.__name__,
- name=plugin.name,
- plugin=plugin,
- )
+ if no_fail:
+ return
+ else:
+ # There was nothing already registered to override:
+ raise errors.PluginMissingOverrideError(
+ base=base.__name__,
+ name=plugin.name,
+ plugin=plugin,
+ )
# The plugin is okay, add to sub_d:
self.__plugins.add(plugin)