Browse Source

[213] Log when the plan is interrupted in the middle

Michal 'vorner' Vaner 13 years ago
parent
commit
68ac89fcb9
2 changed files with 28 additions and 17 deletions
  1. 5 0
      src/bin/bind10/bind10_messages.mes
  2. 23 17
      src/lib/python/isc/bind10/component.py

+ 5 - 0
src/bin/bind10/bind10_messages.mes

@@ -54,6 +54,11 @@ A debug message. This indicates that the configurator is building a plan
 how to change configuration from the older one to newer one. This does no
 real work yet, it just does the planning what needs to be done.
 
+% BIND10_CONFIGURATOR_PLAN_INTERRUPTED configurator plan interrupted, only %1 of %2 done
+There was an exception during some planned task. The plan will not continue and
+only some tasks of the plan were completed. The rest is aborted. The exception
+will propagate.
+
 % BIND10_CONFIGURATOR_RECONFIGURE reconfiguring running components
 A different configuration of which components should be running is being
 installed. All components that are no longer needed will be stopped and

+ 23 - 17
src/lib/python/isc/bind10/component.py

@@ -422,20 +422,26 @@ class Configurator:
         * start
         * stop
         """
-        logger.debug(DBG_TRACE_DATA, BIND10_CONFIGURATOR_RUN, len(plan))
-        for task in plan:
-            component = task['component']
-            command = task['command']
-            logger.debug(DBG_TRACE_DETAILED, BIND10_CONFIGURATOR_TASK, command,
-                         component.name())
-            if command == 'start':
-                component.start()
-                self._components[task['name']] = component
-            elif command == 'stop':
-                if component.running():
-                    component.stop()
-                del self._components[task['name']]
-            else:
-                # Can Not Happen (as the plans are generated by ourself).
-                # Therefore not tested.
-                raise NotImplementedError("Command unknown: " + command)
+        done = 0
+        try:
+            logger.debug(DBG_TRACE_DATA, BIND10_CONFIGURATOR_RUN, len(plan))
+            for task in plan:
+                component = task['component']
+                command = task['command']
+                logger.debug(DBG_TRACE_DETAILED, BIND10_CONFIGURATOR_TASK, command,
+                             component.name())
+                if command == 'start':
+                    component.start()
+                    self._components[task['name']] = component
+                elif command == 'stop':
+                    if component.running():
+                        component.stop()
+                    del self._components[task['name']]
+                else:
+                    # Can Not Happen (as the plans are generated by ourself).
+                    # Therefore not tested.
+                    raise NotImplementedError("Command unknown: " + command)
+                done += 1
+        except:
+            logger.error(BIND10_CONFIGURATOR_PLAN_INTERRUPTED, done, len(plan))
+            raise