summaryrefslogtreecommitdiffstats
path: root/ipapython/install
diff options
context:
space:
mode:
authorMartin Babinsky <mbabinsk@redhat.com>2016-09-20 15:12:30 +0200
committerMartin Basti <mbasti@redhat.com>2016-09-26 18:38:37 +0200
commit347f5ca0e145491d387f60f95b67ef59e7c28316 (patch)
tree0e61ee57630bce83b102fd5c8926feed41ab637b /ipapython/install
parent07ff1f619c001181563886b5a0b5f1886b6638a1 (diff)
downloadfreeipa-347f5ca0e145491d387f60f95b67ef59e7c28316.tar.gz
freeipa-347f5ca0e145491d387f60f95b67ef59e7c28316.tar.xz
freeipa-347f5ca0e145491d387f60f95b67ef59e7c28316.zip
use separate exception handlers for executors and validators
installer framework has been modified to allow for different error handling during validation and execution phases. https://fedorahosted.org/freeipa/ticket/5725 Reviewed-By: Petr Spacek <pspacek@redhat.com>
Diffstat (limited to 'ipapython/install')
-rw-r--r--ipapython/install/core.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/ipapython/install/core.py b/ipapython/install/core.py
index 9582852b8..881d3c6e3 100644
--- a/ipapython/install/core.py
+++ b/ipapython/install/core.py
@@ -322,7 +322,9 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
Coroutine which runs the validation part of the configurable.
"""
- return self.__runner(_VALIDATE_PENDING, _VALIDATE_RUNNING)
+ return self.__runner(_VALIDATE_PENDING,
+ _VALIDATE_RUNNING,
+ self._handle_validate_exception)
def execute(self):
"""
@@ -337,7 +339,9 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
Coroutine which runs the execution part of the configurable.
"""
- return self.__runner(_EXECUTE_PENDING, _EXECUTE_RUNNING)
+ return self.__runner(_EXECUTE_PENDING,
+ _EXECUTE_RUNNING,
+ self._handle_execute_exception)
def done(self):
"""
@@ -353,7 +357,7 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
except StopIteration:
break
- def __runner(self, pending_state, running_state):
+ def __runner(self, pending_state, running_state, exc_handler):
self.__transition(pending_state, running_state)
step = lambda: next(self.__gen)
@@ -369,7 +373,7 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
except BaseException:
exc_info = sys.exc_info()
try:
- self._handle_exception(exc_info)
+ exc_handler(exc_info)
except BaseException:
raise
else:
@@ -393,6 +397,16 @@ class Configurable(six.with_metaclass(abc.ABCMeta, object)):
six.reraise(*exc_info)
+ def _handle_validate_exception(self, exc_info):
+ assert not hasattr(super(Configurable, self),
+ '_handle_validate_exception')
+ self._handle_exception(exc_info)
+
+ def _handle_execute_exception(self, exc_info):
+ assert not hasattr(super(Configurable, self),
+ '_handle_execute_exception')
+ self._handle_exception(exc_info)
+
def __transition(self, from_state, to_state):
if self.__state != from_state:
raise InvalidStateError(self.__state)