Browse Source

[213] Raise when reconfiguring a component

Michal 'vorner' Vaner 13 years ago
parent
commit
b235b396ae

+ 11 - 3
src/lib/python/isc/bind10/component.py

@@ -229,6 +229,16 @@ class Configurator:
                         'command': 'stop',
                         'component': component
                     })
+        # Handle transitions of configuration of what is here
+        for cname in new.keys():
+            if cname in old:
+                for option in ['special', 'process', 'kind']:
+                    if new[cname].get(option) != old[cname].get(option):
+                        raise NotImplementedError('Changing configuration of' +
+                                                  ' a running component is ' +
+                                                  'not yet supported. Remove' +
+                                                  ' and re-add ' + cname +
+                                                  'to get the same effect')
         # Handle introduction of new components
         plan_add = []
         for cname in new.keys():
@@ -240,9 +250,7 @@ class Configurator:
                     creator = specials[params['special']]
                 component = creator(params['process'], self.__boss,
                                     params['kind'])
-                priority = 0
-                if 'priority' in params:
-                    priority = params['priority']
+                priority = params.get('priority', 0)
                 # We store tuples, priority first, so we can easily sort
                 plan_add.append((priority, {
                     'component': component,

+ 6 - 3
src/lib/python/isc/bind10/tests/component_test.py

@@ -612,15 +612,18 @@ class ConfiguratorTest(BossUtils, unittest.TestCase):
         Test changing a configuration of one component. This is not yet
         implemented and should therefore throw.
         """
-        self.assertRaises(NotImplemented, self.__do_switch, 'kind',
+        self.assertRaises(NotImplementedError, self.__do_switch, 'kind',
                           'dispensable')
-        self.assertRaises(NotImplemented, self.__do_switch, 'special',
+        self.assertRaises(NotImplementedError, self.__do_switch, 'special',
                           'not_a_test')
-        self.assertRaises(NotImplemented, self.__do_switch, 'process',
+        self.assertRaises(NotImplementedError, self.__do_switch, 'process',
                           'different')
         # This does not change anything on running component, so no need to
         # raise
         self.assertEqual([], self.__do_switch('priority', 5))
+        # Check against false positive, if the data are the same, but different
+        # instance
+        self.assertEqual([], self.__do_switch('special', 'test'))
 
     def test_startup(self):
         """