BIND 10 trac1484, updated. d2f1ad06d2beb7ab5f51357bf191a9aaf56ddb2f [1484] Documentation

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Dec 19 18:32:42 UTC 2011


The branch, trac1484 has been updated
       via  d2f1ad06d2beb7ab5f51357bf191a9aaf56ddb2f (commit)
       via  137405d030cfdcdec5b1a247e42dd8c4ec83e538 (commit)
      from  321a37a11088881f57df5088571f9ac7c919daf7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d2f1ad06d2beb7ab5f51357bf191a9aaf56ddb2f
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Dec 19 19:32:27 2011 +0100

    [1484] Documentation

commit 137405d030cfdcdec5b1a247e42dd8c4ec83e538
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Dec 19 18:21:16 2011 +0100

    [1484] Provide the find_all for an updater

-----------------------------------------------------------------------

Summary of changes:
 src/lib/python/isc/datasrc/finder_inc.cc         |   28 +++++++++++++++-----
 src/lib/python/isc/datasrc/finder_python.cc      |    2 +-
 src/lib/python/isc/datasrc/tests/datasrc_test.py |   30 ++++++++++++++++++++++
 src/lib/python/isc/datasrc/updater_python.cc     |   10 +++++++
 4 files changed, 62 insertions(+), 8 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/datasrc/finder_inc.cc b/src/lib/python/isc/datasrc/finder_inc.cc
index 82c5fdc..f0c0b86 100644
--- a/src/lib/python/isc/datasrc/finder_inc.cc
+++ b/src/lib/python/isc/datasrc/finder_inc.cc
@@ -46,9 +46,8 @@ Return the RR class of the zone.\n\
 // - Return type: use tuple instead of the dedicated FindResult type
 // - NULL->None
 // - exceptions
-// - description of the 'target' parameter (must be None for now)
 const char* const ZoneFinder_find_doc = "\
-find(name, type, target=None, options=FIND_DEFAULT) -> (integer, RRset)\n\
+find(name, type, options=FIND_DEFAULT) -> (integer, RRset)\n\
 \n\
 Search the zone for a given pair of domain name and RR type.\n\
 \n\
@@ -72,10 +71,6 @@ answer for the search key. Specifically,\n\
   and the code of SUCCESS will be returned.\n\
 - If the search name matches a delegation point of DNAME, it returns\n\
   the code of DNAME and that DNAME RR.\n\
-- If the target isn't None, all RRsets under the domain are inserted\n\
-  there and SUCCESS (or NXDOMAIN, in case of empty domain) is returned\n\
-  instead of normall processing. This is intended to handle ANY query.\n\
-  (Note: the Python version doesn't support this feature yet)\n\
 \n\
 Note: This behavior is controversial as we discussed in\n\
 https://lists.isc.org/pipermail/bind10-dev/2011-January/001918.html We\n\
@@ -107,13 +102,32 @@ internal error in the datasource.\n\
 Parameters:\n\
   name       The domain name to be searched for.\n\
   type       The RR type to be searched for.\n\
-  target     Must be None.\n\
   options    The search options.\n\
 \n\
 Return Value(s): A tuple of a result code (integer) and an RRset object\n\
 enclosing the search result (see above).\n\
 ";
 
+const char* const ZoneFinder_find_all_doc = "\
+find_all(isc.dns.Name, options=FIND_DEFAULT) -> (integer, RRset) | (integer, [RRset])\
+\n\
+This acts mostly the same as the find method. The main difference is,\n\
+when the lookup is successful (eg. the first part of the result is either\n\
+SUCCESS or WILDCARD), the second part is list of all RRsets in the given name\n\
+instead of a single RRset as in case of find.\n\
+\n\
+This method raises an isc.datasrc.Error exception if there is an\n\
+internal error in the datasource.\n\
+\n\
+Parameters:\n\
+  name       The domain name to be searched for.\n\
+  options    The search options.\n\
+\n\
+Return Value(s): A tuple of a result code (integer) and an either RRset object,\n\
+for cases where the result is some kind of delegation, CNAME or similar, or list\n\
+of RRset objects, containing all the results.\n\
+";
+
 const char* const ZoneFinder_find_previous_name_doc = "\
 find_previous_name(isc.dns.Name) -> isc.dns.Name\n\
 \n\
diff --git a/src/lib/python/isc/datasrc/finder_python.cc b/src/lib/python/isc/datasrc/finder_python.cc
index ae1a0c4..e65e6de 100644
--- a/src/lib/python/isc/datasrc/finder_python.cc
+++ b/src/lib/python/isc/datasrc/finder_python.cc
@@ -265,7 +265,7 @@ PyMethodDef ZoneFinder_methods[] = {
        ZoneFinder_getOrigin_doc },
     { "get_class", ZoneFinder_getClass, METH_NOARGS, ZoneFinder_getClass_doc },
     { "find", ZoneFinder_find, METH_VARARGS, ZoneFinder_find_doc },
-    { "find_all", ZoneFinder_find_all, METH_VARARGS, "TODO" },
+    { "find_all", ZoneFinder_find_all, METH_VARARGS, ZoneFinder_find_all_doc },
     { "find_previous_name", ZoneFinder_findPreviousName, METH_VARARGS,
       ZoneFinder_find_previous_name_doc },
     { NULL, NULL, 0, NULL }
diff --git a/src/lib/python/isc/datasrc/tests/datasrc_test.py b/src/lib/python/isc/datasrc/tests/datasrc_test.py
index c9f837f..b682652 100644
--- a/src/lib/python/isc/datasrc/tests/datasrc_test.py
+++ b/src/lib/python/isc/datasrc/tests/datasrc_test.py
@@ -305,6 +305,36 @@ class DataSrcClient(unittest.TestCase):
         self.assertEqual(sorted(map(lambda rdata: rdata.to_text(), rdatas)),
                          sorted(["192.0.2.1", "192.0.2.2", "2001:db8::1",
                                  "2001:db8::2"]))
+        # The same, but on an updater
+        dsc = isc.datasrc.DataSourceClient("sqlite3", WRITE_ZONE_DB_CONFIG)
+        updater = dsc.get_updater(isc.dns.Name("example.com"), False)
+
+        # Some "failure" responses
+        result, rrset = updater.find_all(isc.dns.Name("www.sql1.example.com"),
+                                        finder.FIND_DEFAULT)
+        self.assertEqual(finder.DELEGATION, result)
+        self.assertEqual("sql1.example.com. 3600 IN NS dns01.example.com.\n" +
+                         "sql1.example.com. 3600 IN NS dns02.example.com.\n" +
+                         "sql1.example.com. 3600 IN NS dns03.example.com.\n",
+                         rrset.to_text())
+
+        result, rrset = updater.find_all(isc.dns.Name("nxdomain.example.com"),
+                                         finder.FIND_DEFAULT)
+        self.assertEqual(finder.NXDOMAIN, result)
+        self.assertIsNone(None, rrset)
+
+        # A success. It should return the list now.
+        result, rrsets = updater.find_all(isc.dns.Name("mix.example.com."))
+        self.assertEqual(ZoneFinder.SUCCESS, result)
+        self.assertEqual(2, len(rrsets))
+        self.assertEqual(sorted(map(lambda rrset: rrset.get_type().to_text(),
+                                    rrsets)), sorted(["A", "AAAA"]))
+        rdatas = []
+        for rrset in rrsets:
+            rdatas.extend(rrset.get_rdata())
+        self.assertEqual(sorted(map(lambda rdata: rdata.to_text(), rdatas)),
+                         sorted(["192.0.2.1", "192.0.2.2", "2001:db8::1",
+                                 "2001:db8::2"]))
 
     def test_find(self):
         dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
diff --git a/src/lib/python/isc/datasrc/updater_python.cc b/src/lib/python/isc/datasrc/updater_python.cc
index 29d2ffe..00b8940 100644
--- a/src/lib/python/isc/datasrc/updater_python.cc
+++ b/src/lib/python/isc/datasrc/updater_python.cc
@@ -48,6 +48,7 @@ using namespace isc::datasrc::python;
 namespace isc_datasrc_internal {
 // See finder_python.cc
 PyObject* ZoneFinder_helper(ZoneFinder* finder, PyObject* args);
+PyObject* ZoneFinder_helper_all(ZoneFinder* finder, PyObject* args);
 }
 
 namespace {
@@ -185,6 +186,13 @@ ZoneUpdater_find(PyObject* po_self, PyObject* args) {
                                                     args));
 }
 
+PyObject*
+ZoneUpdater_find_all(PyObject* po_self, PyObject* args) {
+    s_ZoneUpdater* const self = static_cast<s_ZoneUpdater*>(po_self);
+    return (isc_datasrc_internal::ZoneFinder_helper_all(
+        &self->cppobj->getFinder(), args));
+}
+
 // This list contains the actual set of functions we have in
 // python. Each entry has
 // 1. Python method name
@@ -208,6 +216,8 @@ PyMethodDef ZoneUpdater_methods[] = {
       METH_NOARGS, ZoneFinder_getClass_doc },
     { "find", reinterpret_cast<PyCFunction>(ZoneUpdater_find), METH_VARARGS,
       ZoneFinder_find_doc },
+    { "find_all", ZoneUpdater_find_all, METH_VARARGS,
+      ZoneFinder_find_all_doc },
     { NULL, NULL, 0, NULL }
 };
 




More information about the bind10-changes mailing list