Browse Source

[1643] Small fixes

* The get_remote_config_value returns tupple.
* The config callback should be called after the module is ready.
Michal 'vorner' Vaner 13 years ago
parent
commit
719a5941f5

+ 4 - 2
src/lib/python/isc/config/ccsession.py

@@ -344,17 +344,19 @@ class ModuleCCSession(ConfigData):
             raise ModuleCCSessionError("No answer from ConfigManager when "
             raise ModuleCCSessionError("No answer from ConfigManager when "
                                        "asking about Remote module " +
                                        "asking about Remote module " +
                                        module_name)
                                        module_name)
+        call_callback = False
         if answer:
         if answer:
             rcode, value = parse_answer(answer)
             rcode, value = parse_answer(answer)
             if rcode == 0:
             if rcode == 0:
                 if value != None and module_spec.validate_config(False, value):
                 if value != None and module_spec.validate_config(False, value):
                     module_cfg.set_local_config(value)
                     module_cfg.set_local_config(value)
-                    if config_update_callback is not None:
+                    call_callback = True
-                        config_update_callback(value, module_cfg)
 
 
         # all done, add it
         # all done, add it
         self._remote_module_configs[module_name] = module_cfg
         self._remote_module_configs[module_name] = module_cfg
         self._remote_module_callbacks[module_name] = config_update_callback
         self._remote_module_callbacks[module_name] = config_update_callback
+        if call_callback and config_update_callback is not None:
+            config_update_callback(value, module_cfg)
 
 
     def add_remote_config_by_name(self, module_name,
     def add_remote_config_by_name(self, module_name,
                                   config_update_callback=None):
                                   config_update_callback=None):

+ 1 - 1
src/lib/python/isc/server_common/tests/tsig_keyring_test.py

@@ -43,7 +43,7 @@ class Session(MockModuleCCSession):
     def get_remote_config_value(self, module, name):
     def get_remote_config_value(self, module, name):
         if module != 'tsig_keys' or name != 'keys':
         if module != 'tsig_keys' or name != 'keys':
             raise Exception("Asked for bad data element")
             raise Exception("Asked for bad data element")
-        return self._data
+        return (self._data, False)
 
 
 class TSIGKeyRingTest(unittest.TestCase):
 class TSIGKeyRingTest(unittest.TestCase):
     """
     """

+ 6 - 2
src/lib/python/isc/server_common/tsig_keyring.py

@@ -50,15 +50,19 @@ class Updater:
         session.add_remote_config_by_name('tsig_keys', self._update)
         session.add_remote_config_by_name('tsig_keys', self._update)
         self._update()
         self._update()
 
 
-    def _update(self):
+    def _update(self, value=None, module_cfg=None):
         """
         """
         Update the key ring by the configuration.
         Update the key ring by the configuration.
 
 
         Note that this function is used as a callback, but can raise
         Note that this function is used as a callback, but can raise
         on bad data. The bad data is expected to be handled by the
         on bad data. The bad data is expected to be handled by the
         configuration plugin and not be allowed as far as here.
         configuration plugin and not be allowed as far as here.
+
+        The parameters are there just to match the signature which
+        the callback should have (eg. they are ignored).
         """
         """
-        data = self._session.get_remote_config_value('tsig_keys', 'keys')
+        (data, default) = self._session.get_remote_config_value('tsig_keys',
+                                                                'keys')
         if data is not None: # There's an update
         if data is not None: # There's an update
             keyring = isc.dns.TSIGKeyRing()
             keyring = isc.dns.TSIGKeyRing()
             for key_data in data:
             for key_data in data: