Browse Source

[2964] added data_sources for necessary remote config. it's nop for now.

JINMEI Tatuya 12 years ago
parent
commit
42213653b8
2 changed files with 17 additions and 3 deletions
  1. 10 1
      src/bin/xfrin/tests/xfrin_test.py
  2. 7 2
      src/bin/xfrin/xfrin.py.in

+ 10 - 1
src/bin/xfrin/tests/xfrin_test.py

@@ -135,9 +135,11 @@ class MockCC(MockModuleCCSession, ConfigData):
         module_spec = isc.config.module_spec_from_file(
             xfrin.SPECFILE_LOCATION)
         ConfigData.__init__(self, module_spec)
+        # For inspection
+        self.added_remote_modules = []
 
     def add_remote_config_by_name(self, name, callback):
-        pass
+        self.added_remote_modules.append((name, callback))
 
     def get_remote_config_value(self, module, identifier):
         if module == 'tsig_keys' and identifier == 'keys':
@@ -2461,6 +2463,13 @@ class TestXfrin(unittest.TestCase):
         sys.stderr.close()
         sys.stderr = self.stderr_backup
 
+    def test_init(self):
+        """Check some initial configuration after construction"""
+        # data source "module" should have been registrered as a necessary
+        # remote config
+        self.assertEqual([('data_sources', self.xfr._datasrc_config_handler)],
+                         self.xfr._module_cc.added_remote_modules)
+
     def _do_parse_zone_name_class(self):
         return self.xfr._parse_zone_name_and_class(self.args)
 

+ 7 - 2
src/bin/xfrin/xfrin.py.in

@@ -1462,6 +1462,8 @@ class Xfrin:
         self._cc_setup()
         config_data = self._module_cc.get_full_config()
         self.config_handler(config_data)
+        self._module_cc.add_remote_config_by_name('data_sources',
+                                                  self._datasrc_config_handler)
         init_keyring(self._module_cc)
 
     def _cc_setup(self):
@@ -1473,8 +1475,8 @@ class Xfrin:
         # listening session will block the send operation.
         self._send_cc_session = isc.cc.Session()
         self._module_cc = isc.config.ModuleCCSession(SPECFILE_LOCATION,
-                                              self.config_handler,
-                                              self.command_handler)
+                                                     self.config_handler,
+                                                     self.command_handler)
         self._module_cc.start()
         # TBD: this will be removed in this branch
         self._module_cc.add_remote_config(AUTH_SPECFILE_LOCATION,
@@ -1530,6 +1532,9 @@ class Xfrin:
         # Config handler for changes in Auth configuration
         self._set_db_file()
 
+    def _datasrc_config_handler(self, new_config, config_data):
+        pass
+
     def shutdown(self):
         ''' shutdown the xfrin process. the thread which is doing xfrin should be
         terminated.