Browse Source

'stub' call to CCSession from bob, and mini-sample-specfile

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@567 e5f2f494-b856-4b98-b285-d166d9295462
Jelte Jansen 15 years ago
parent
commit
6a70f64c5e
3 changed files with 52 additions and 1 deletions
  1. 1 1
      src/bin/bind10/bind10.in
  2. 24 0
      src/bin/bind10/bind10.py
  3. 27 0
      src/bin/bind10/bob.spec

+ 1 - 1
src/bin/bind10/bind10.in

@@ -8,7 +8,7 @@ BIND10_PATH=@abs_top_srcdir@/src/bin/bind10
 PATH=@abs_top_srcdir@/src/bin/msgq:@abs_top_srcdir@/src/bin/parkinglot:@abs_top_srcdir@/src/bin/bind-cfgd:@abs_top_srcdir@/src/bin/cmd-ctrld:$PATH
 export PATH
 
-PYTHONPATH=@abs_top_srcdir@/src/lib/cc/python:${abs_top_src_dir}/lib/cc/python/ISC
+PYTHONPATH=@abs_top_srcdir@/src/lib/cc/python:@abs_top_srcdir@/src/lib/config/python
 export PYTHONPATH
 
 cd ${BIND10_PATH}

+ 24 - 0
src/bin/bind10/bind10.py

@@ -33,6 +33,7 @@ import pprint
 from optparse import OptionParser, OptionValueError
 
 import ISC.CC
+import isc
 
 # This is the version that gets displayed to the user.
 __version__ = "v20091030 (Paving the DNS Parking Lot)"
@@ -88,6 +89,17 @@ class BoB:
         self.dead_processes = {}
         self.runnable = False
 
+    def config_handler(self, new_config):
+        if self.verbose:
+            print("[XX] handling new config:")
+            print(new_config)
+
+    def command_handler(self, command):
+        if self.verbose:
+            print("[XX] Boss got command:")
+            print(command)
+        return None
+    
     def startup(self):
         """Start the BoB instance.
  
@@ -133,6 +145,17 @@ class BoB:
         if self.verbose:
             sys.stdout.write("Started bind-cfgd (PID %d)\n" % bind_cfgd.pid)
 
+        # TODO: once this interface is done, replace self.cc_session
+        # by this one
+        # sleep until bind-cfgd is fully up and running, this is a good place
+        # to have a (short) timeout on synchronized groupsend/receive
+        time.sleep(1)
+        if self.verbose:
+            print("[XX] starting ccsession")
+        self.ccs = isc.config.CCSession("bob", "bob.spec", self.config_handler, self.command_handler)
+        if self.verbose:
+            print("[XX] ccsession started")
+
         # start the parking lot
         # XXX: this must be read from the configuration manager in the future
         # XXX: we hardcode port 5300
@@ -164,6 +187,7 @@ class BoB:
             sys.stdout.write("Started cmd-ctrld (PID %d)\n" % cmd_ctrld.pid)
 
         self.runnable = True
+
         return None
 
     def stop_all_processes(self):

+ 27 - 0
src/bin/bind10/bob.spec

@@ -0,0 +1,27 @@
+{
+  "data_specification": {
+    "module_name": "Boss",
+    "config_data": [
+      {
+        "item_name": "some_string",
+        "item_type": "string",
+        "item_optional": False,
+        "item_default": "Hi, shane!"
+      }
+    ],
+    "commands": [
+      {
+        "command_name": "print_message",
+        "command_description": "Print the given message to stdout",
+        "command_args": [ {
+          "item_name": "message",
+          "item_type": "string",
+          "item_optional": False,
+          "item_default": ""
+        } ]
+      }
+    ]
+  }
+}
+
+