Browse Source

[1429] The command_handler handles get_socket

Michal 'vorner' Vaner 13 years ago
parent
commit
b8d14d2e45
2 changed files with 28 additions and 0 deletions
  1. 9 0
      src/bin/bind10/bind10_src.py.in
  2. 19 0
      src/bin/bind10/tests/bind10_test.py.in

+ 9 - 0
src/bin/bind10/bind10_src.py.in

@@ -318,6 +318,8 @@ class BoB:
             elif command == "show_processes":
                 answer = isc.config.ccsession. \
                     create_answer(0, self.get_processes())
+            elif command == "get_socket":
+                answer = self._get_socket(args)
             else:
                 answer = isc.config.ccsession.create_answer(1,
                                                             "Unknown command")
@@ -815,6 +817,13 @@ class BoB:
 
         return next_restart_time
 
+    def _get_socket(self, args):
+        """
+        Implementation of the get_socket CC command. It asks the cache
+        to provide the token and sends the information back.
+        """
+        pass
+
     def socket_request_handler(self, token, unix_socket):
         """
         This function handles a token that comes over a unix_domain socket.

+ 19 - 0
src/bin/bind10/tests/bind10_test.py.in

@@ -293,6 +293,25 @@ class TestBoB(unittest.TestCase):
         self.assertEqual(bob.command_handler("__UNKNOWN__", None),
                          isc.config.ccsession.create_answer(1, "Unknown command"))
 
+        # Fake the _get_socket, which is complicated and tested elsewhere
+        # We just want to pass the parameters in and let it create a response
+        def get_socket(args):
+            return isc.config.ccsession.create_answer(0, args)
+
+        bob._get_socket = get_socket
+        args = {
+            "port": 53,
+            "address": "0.0.0.0",
+            "protocol": "UDP",
+            "share_mode": "ANY",
+            "share_name": "app"
+        }
+        # Test it just returns whatever it got. The real function doesn't
+        # work like this, but we don't want the command_handler to touch it
+        # at all and this is the easiest way to check.
+        self.assertEqual({'result': [0, args]},
+                         bob.command_handler("get_socket", args))
+
 # Class for testing the BoB without actually starting processes.
 # This is used for testing the start/stop components routines and
 # the BoB commands.