Browse Source

[1451] add stub DDNSSession object and some spec data

Jelte Jansen 13 years ago
parent
commit
0bddf9ffef
2 changed files with 51 additions and 15 deletions
  1. 15 6
      src/bin/ddns/ddns.py.in
  2. 36 9
      src/bin/ddns/ddns.spec.pre.in

+ 15 - 6
src/bin/ddns/ddns.py.in

@@ -59,6 +59,21 @@ class DDNSSessionError(Exception):
     '''
     pass
 
+class DDNSSession:
+    """Class to handle one DDNS update"""
+    
+    def __init__(self):
+        self._handle()
+
+    def _handle(self):
+        '''
+        Handle a DDNS update.
+        This should be called from the initializer, and should contain the
+        logic for doing the checks, handling the update, and responding with
+        the result.
+        '''
+        pass
+
 class DDNSServer:
     def __init__(self):
         self._cc = isc.config.ModuleCCSession(SPECFILE_LOCATION,
@@ -71,14 +86,8 @@ class DDNSServer:
     def config_handler(self, new_config):
         '''Update config data.'''
         answer = create_answer(0)
-        for key in new_config:
-            if key not in self._config_data:
-                answer = create_answer(1, "Unknown config data: " + str(key))
-                continue
-            self._config_data[key] = new_config[key]
         return answer
 
-
     def command_handler(self, cmd, args):
         if cmd == "shutdown":
             logger.info(DDNS_RECEIVED_SHUTDOWN_COMMAND)

+ 36 - 9
src/bin/ddns/ddns.spec.pre.in

@@ -1,15 +1,42 @@
 {
   "module_spec": {
-     "module_name": "DDNS",
-     "config_data": [
-      ],
-      "commands": [
-        {
-          "command_name": "shutdown",
-          "command_description": "Shut down DDNS",
-          "command_args": []
+    "module_name": "DDNS",
+    "config_data": [
+      {
+        "item_name": "zones",
+        "item_type": "named_set",
+        "item_optional": false,
+        "item_default": {},
+        "named_set_item_spec": {
+          "item_name": "entry",
+          "item_type": "map",
+          "item_optional": true,
+          "item_default": {
+            "update_acls": [{"action": "ACCEPT", "from": "127.0.0.1"},
+                            {"action": "ACCEPT", "from": "::1"}]
+          },
+          "map_item_spec": [
+            {
+              "item_name": "update_acls",
+              "item_type": "list",
+              "item_optional": false,
+              "list_item_spec": {
+                "item_name": "acl_element",
+                "item_type": "any",
+                "item_optional": true
+              }
+            }
+          ]
         }
-      ]
+      }
+    ],
+    "commands": [
+      {
+        "command_name": "shutdown",
+        "command_description": "Shut down DDNS",
+        "command_args": []
+      }
+    ]
   }
 }