Browse Source

[2020] cleanup: use module name to get remote config for auth instead of fname.

using module name is more generic, and we can avoid differentiating various
setups whether it's for unit test or running from source or as an installed
system.  previously I thought it was more fragile in terms of start up
timing, but on looking it further I realized it's not different from the
case we use the module file.
JINMEI Tatuya 13 years ago
parent
commit
57c8937e29
2 changed files with 5 additions and 14 deletions
  1. 5 8
      src/bin/ddns/ddns.py.in
  2. 0 6
      src/bin/ddns/tests/ddns_test.py

+ 5 - 8
src/bin/ddns/ddns.py.in

@@ -67,26 +67,23 @@ else:
     SPECFILE_PATH = SPECFILE_PATH.replace("${prefix}", PREFIX)
     SPECFILE_PATH = SPECFILE_PATH.replace("${prefix}", PREFIX)
 
 
 if "B10_FROM_BUILD" in os.environ:
 if "B10_FROM_BUILD" in os.environ:
-    AUTH_SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/auth"
     if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
     if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
         SOCKET_FILE_PATH = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
         SOCKET_FILE_PATH = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"]
     else:
     else:
         SOCKET_FILE_PATH = os.environ["B10_FROM_BUILD"]
         SOCKET_FILE_PATH = os.environ["B10_FROM_BUILD"]
 else:
 else:
     SOCKET_FILE_PATH = bind10_config.DATA_PATH
     SOCKET_FILE_PATH = bind10_config.DATA_PATH
-    AUTH_SPECFILE_PATH = SPECFILE_PATH
 
 
 SPECFILE_LOCATION = SPECFILE_PATH + "/ddns.spec"
 SPECFILE_LOCATION = SPECFILE_PATH + "/ddns.spec"
 SOCKET_FILE = SOCKET_FILE_PATH + '/ddns_socket'
 SOCKET_FILE = SOCKET_FILE_PATH + '/ddns_socket'
-AUTH_SPECFILE_LOCATION = AUTH_SPECFILE_PATH + '/auth.spec'
+
+# Cooperating or dependency modules
+AUTH_MODULE_NAME = 'Auth'
+XFROUT_MODULE_NAME = 'Xfrout'
 ZONEMGR_MODULE_NAME = 'Zonemgr'
 ZONEMGR_MODULE_NAME = 'Zonemgr'
 
 
 isc.util.process.rename()
 isc.util.process.rename()
 
 
-# Cooperating modules
-XFROUT_MODULE_NAME = 'Xfrout'
-AUTH_MODULE_NAME = 'Auth'
-
 class DDNSConfigError(Exception):
 class DDNSConfigError(Exception):
     '''An exception indicating an error in updating ddns configuration.
     '''An exception indicating an error in updating ddns configuration.
 
 
@@ -186,7 +183,7 @@ class DDNSServer:
         self._secondary_zones = None
         self._secondary_zones = None
 
 
         # Get necessary configurations from remote modules.
         # Get necessary configurations from remote modules.
-        self._cc.add_remote_config(AUTH_SPECFILE_LOCATION)
+        self._cc.add_remote_config_by_name(AUTH_MODULE_NAME)
         self._cc.add_remote_config_by_name(ZONEMGR_MODULE_NAME,
         self._cc.add_remote_config_by_name(ZONEMGR_MODULE_NAME,
                                            self.__zonemgr_config_handler)
                                            self.__zonemgr_config_handler)
         isc.server_common.tsig_keyring.init_keyring(self._cc)
         isc.server_common.tsig_keyring.init_keyring(self._cc)

+ 0 - 6
src/bin/ddns/tests/ddns_test.py

@@ -233,9 +233,6 @@ class MyCCSession(isc.config.ConfigData):
         """
         """
         return FakeSocket(1)
         return FakeSocket(1)
 
 
-    def add_remote_config(self, spec_file_name, update_callback=None):
-        pass
-
     def add_remote_config_by_name(self, module_name, update_callback=None):
     def add_remote_config_by_name(self, module_name, update_callback=None):
         if update_callback is not None:
         if update_callback is not None:
             self.__callbacks[module_name] = update_callback
             self.__callbacks[module_name] = update_callback
@@ -1251,9 +1248,6 @@ class TestConfig(unittest.TestCase):
                          ddns.SOCKET_FILE)
                          ddns.SOCKET_FILE)
         self.assertEqual(os.environ["B10_FROM_SOURCE"] +
         self.assertEqual(os.environ["B10_FROM_SOURCE"] +
                          "/src/bin/ddns/ddns.spec", ddns.SPECFILE_LOCATION)
                          "/src/bin/ddns/ddns.spec", ddns.SPECFILE_LOCATION)
-        self.assertEqual(os.environ["B10_FROM_BUILD"] +
-                         "/src/bin/auth/auth.spec",
-                         ddns.AUTH_SPECFILE_LOCATION)
 
 
     def test_get_datasrc_client(self):
     def test_get_datasrc_client(self):
         # The test sqlite DB should contain the example.org zone.
         # The test sqlite DB should contain the example.org zone.