Commit 62238a8f authored by Marco Mariani's avatar Marco Mariani

step with lambda

parent c4e0924e
...@@ -143,15 +143,20 @@ class SoftwareReleaseTester(RPCRetry): ...@@ -143,15 +143,20 @@ class SoftwareReleaseTester(RPCRetry):
self.request_kw = request_kw self.request_kw = request_kw
self.state = TESTER_STATE_INITIAL self.state = TESTER_STATE_INITIAL
self.transition_dict = { self.transition_dict = {
# step function
# delay
# next_state
# software_state
# instance_state
TESTER_STATE_INITIAL: ( TESTER_STATE_INITIAL: (
None, lambda t: None,
None, None,
TESTER_STATE_NOTHING, TESTER_STATE_NOTHING,
None, None,
None, None,
), ),
TESTER_STATE_NOTHING: ( TESTER_STATE_NOTHING: (
'install', lambda t: t.install(),
max_install_duration, max_install_duration,
request_kw is None and TESTER_STATE_INSTANCE_UNINSTALLED or \ request_kw is None and TESTER_STATE_INSTANCE_UNINSTALLED or \
TESTER_STATE_SOFTWARE_INSTALLED, TESTER_STATE_SOFTWARE_INSTALLED,
...@@ -159,21 +164,21 @@ class SoftwareReleaseTester(RPCRetry): ...@@ -159,21 +164,21 @@ class SoftwareReleaseTester(RPCRetry):
None, None,
), ),
TESTER_STATE_SOFTWARE_INSTALLED: ( TESTER_STATE_SOFTWARE_INSTALLED: (
'request', lambda t: t.request(),
max_request_duration, max_request_duration,
TESTER_STATE_INSTANCE_STARTED, TESTER_STATE_INSTANCE_STARTED,
None, None,
INSTANCE_STATE_STARTED, INSTANCE_STATE_STARTED,
), ),
TESTER_STATE_INSTANCE_STARTED: ( TESTER_STATE_INSTANCE_STARTED: (
'destroy', lambda t: t.destroy(),
max_destroy_duration, max_destroy_duration,
TESTER_STATE_INSTANCE_UNINSTALLED, TESTER_STATE_INSTANCE_UNINSTALLED,
None, None,
INSTANCE_STATE_UNKNOWN, INSTANCE_STATE_UNKNOWN,
), ),
TESTER_STATE_INSTANCE_UNINSTALLED: ( TESTER_STATE_INSTANCE_UNINSTALLED: (
'uninstall', lambda t: t.uninstall(),
max_uninstall_duration, max_uninstall_duration,
None, None,
SOFTWARE_STATE_UNKNOWN, SOFTWARE_STATE_UNKNOWN,
...@@ -301,9 +306,9 @@ class SoftwareReleaseTester(RPCRetry): ...@@ -301,9 +306,9 @@ class SoftwareReleaseTester(RPCRetry):
self._logger.debug('Going to state %i (%r, %r)', state, self._logger.debug('Going to state %i (%r, %r)', state,
software_state, instance_state) software_state, instance_state)
self.state = state self.state = state
step, delay, _, _, _ = self.transition_dict[state] stepfunc, delay, _, _, _ = self.transition_dict[state]
self.deadline = now + delay self.deadline = now + delay
getattr(self, step)() stepfunc(self)
return self.deadline return self.deadline
class TestMap(object): class TestMap(object):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment