Browse Source

[213] Return something from config_handler

Even when there's an error
Michal 'vorner' Vaner 13 years ago
parent
commit
e7a16b2735
2 changed files with 9 additions and 8 deletions
  1. 6 4
      src/bin/bind10/bind10_src.py.in
  2. 3 4
      src/bin/bind10/tests/bind10_test.py.in

+ 6 - 4
src/bin/bind10/bind10_src.py.in

@@ -283,10 +283,12 @@ class BoB:
             return
         logger.debug(DBG_COMMANDS, BIND10_RECEIVED_NEW_CONFIGURATION,
                      new_config)
-        if 'components' in new_config:
-            self.__propagate_component_config(new_config['components'])
-        answer = isc.config.ccsession.create_answer(0)
-        return answer
+        try:
+            if 'components' in new_config:
+                self.__propagate_component_config(new_config['components'])
+            return isc.config.ccsession.create_answer(0)
+        except Exception as e:
+            return isc.config.ccsession.create_answer(1, str(e))
 
     def get_processes(self):
         pids = list(self.processes.keys())

+ 3 - 4
src/bin/bind10/tests/bind10_test.py.in

@@ -298,10 +298,9 @@ class TestBossComponents(unittest.TestCase):
         # Check a configuration that messes up the core components is rejected.
         compconf = dict(self.__compconfig)
         compconf['msgq'] = { 'process': 'echo' }
-        # Is it OK to raise, or should it catch also and convert to error
-        # answer?
-        self.assertRaises(Exception, bob.config_handler,
-                          {'components': compconf})
+        result = bob.config_handler({'components': compconf})
+        # Check it rejected it
+        self.assertEqual(1, result['result'][0])
 
         # Stop it
         orig = bob._component_configurator.shutdown