BIND 10 master, updated. b41b7dc34a8a14339a1ff9daf1d705997d9abc43 [master] Merge branch 'trac1369'
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Dec 7 23:17:24 UTC 2011
The branch, master has been updated
via b41b7dc34a8a14339a1ff9daf1d705997d9abc43 (commit)
via b7b90e50531bcbd2caaffe6b51aea8917a56f40d (commit)
via fd5713eae0276a3d623953c88fc6281aab0b71d3 (commit)
via 4c0fd2ba248e5f925566e02724b34c85179a8c51 (commit)
from 6bda5426c6f8b4e9faefc2075575e1c98bc3907c (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 b41b7dc34a8a14339a1ff9daf1d705997d9abc43
Merge: 6bda542 b7b90e5
Author: JINMEI Tatuya <jinmei at isc.org>
Date: Wed Dec 7 15:15:17 2011 -0800
[master] Merge branch 'trac1369'
-----------------------------------------------------------------------
Summary of changes:
src/bin/xfrin/tests/xfrin_test.py | 7 +--
src/bin/xfrout/tests/xfrout_test.py.in | 2 +-
src/lib/python/isc/datasrc/finder_inc.cc | 5 +-
src/lib/python/isc/datasrc/finder_python.cc | 29 +++++++------
src/lib/python/isc/datasrc/tests/datasrc_test.py | 48 ++++++++++++++++++++++
src/lib/python/isc/notify/notify_out.py | 15 ++-----
6 files changed, 76 insertions(+), 30 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/xfrin/tests/xfrin_test.py b/src/bin/xfrin/tests/xfrin_test.py
index fa1da07..eb2c747 100644
--- a/src/bin/xfrin/tests/xfrin_test.py
+++ b/src/bin/xfrin/tests/xfrin_test.py
@@ -158,7 +158,7 @@ class MockDataSourceClient():
return (DataSourceClient.PARTIALMATCH, self)
raise ValueError('Unexpected input to mock client: bug in test case?')
- def find(self, name, rrtype, target, options):
+ def find(self, name, rrtype, target=None, options=ZoneFinder.FIND_DEFAULT):
'''Mock ZoneFinder.find().
It returns the predefined SOA RRset to queries for SOA of the common
@@ -1751,8 +1751,7 @@ class TestXFRSessionWithSQLite3(TestXfrinConnection):
def get_zone_serial(self):
result, finder = self.conn._datasrc_client.find_zone(TEST_ZONE_NAME)
self.assertEqual(DataSourceClient.SUCCESS, result)
- result, soa = finder.find(TEST_ZONE_NAME, RRType.SOA(),
- None, ZoneFinder.FIND_DEFAULT)
+ result, soa = finder.find(TEST_ZONE_NAME, RRType.SOA())
self.assertEqual(ZoneFinder.SUCCESS, result)
self.assertEqual(1, soa.get_rdata_count())
return get_soa_serial(soa.get_rdata()[0])
@@ -1760,7 +1759,7 @@ class TestXFRSessionWithSQLite3(TestXfrinConnection):
def record_exist(self, name, type):
result, finder = self.conn._datasrc_client.find_zone(TEST_ZONE_NAME)
self.assertEqual(DataSourceClient.SUCCESS, result)
- result, soa = finder.find(name, type, None, ZoneFinder.FIND_DEFAULT)
+ result, soa = finder.find(name, type)
return result == ZoneFinder.SUCCESS
def test_do_ixfrin_sqlite3(self):
diff --git a/src/bin/xfrout/tests/xfrout_test.py.in b/src/bin/xfrout/tests/xfrout_test.py.in
index 8373e15..ea4de27 100644
--- a/src/bin/xfrout/tests/xfrout_test.py.in
+++ b/src/bin/xfrout/tests/xfrout_test.py.in
@@ -95,7 +95,7 @@ class MockDataSrcClient:
return (isc.datasrc.DataSourceClient.NOTFOUND, None)
return (isc.datasrc.DataSourceClient.SUCCESS, self)
- def find(self, name, rrtype, target, options):
+ def find(self, name, rrtype, target=None, options=ZoneFinder.FIND_DEFAULT):
'''Mock ZoneFinder.find().
(At the moment) this method only handles query for type SOA.
diff --git a/src/lib/python/isc/datasrc/finder_inc.cc b/src/lib/python/isc/datasrc/finder_inc.cc
index 4a00e78..82c5fdc 100644
--- a/src/lib/python/isc/datasrc/finder_inc.cc
+++ b/src/lib/python/isc/datasrc/finder_inc.cc
@@ -46,6 +46,7 @@ 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\
\n\
@@ -74,6 +75,7 @@ answer for the search key. Specifically,\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\
@@ -105,8 +107,7 @@ 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 If target is not None, insert all RRs under the domain\n\
- into it.\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\
diff --git a/src/lib/python/isc/datasrc/finder_python.cc b/src/lib/python/isc/datasrc/finder_python.cc
index 6585049..7f74133 100644
--- a/src/lib/python/isc/datasrc/finder_python.cc
+++ b/src/lib/python/isc/datasrc/finder_python.cc
@@ -53,26 +53,29 @@ namespace isc_datasrc_internal {
PyObject* ZoneFinder_helper(ZoneFinder* finder, PyObject* args) {
if (finder == NULL) {
PyErr_SetString(getDataSourceException("Error"),
- "Internal error in find() wrapper; finder object NULL");
+ "Internal error in find() wrapper; "
+ "finder object NULL");
return (NULL);
}
- PyObject *name;
- PyObject *rrtype;
- PyObject *target;
- int options_int;
- if (PyArg_ParseTuple(args, "O!O!OI", &name_type, &name,
+ PyObject* name;
+ PyObject* rrtype;
+ PyObject* target = Py_None;
+ unsigned int options_int = ZoneFinder::FIND_DEFAULT;
+ if (PyArg_ParseTuple(args, "O!O!|OI", &name_type, &name,
&rrtype_type, &rrtype,
&target, &options_int)) {
try {
+ if (target != Py_None) {
+ PyErr_SetString(PyExc_TypeError,
+ "find(): target must be None in this version");
+ return (NULL);
+ }
ZoneFinder::FindOptions options =
static_cast<ZoneFinder::FindOptions>(options_int);
- ZoneFinder::FindResult find_result(
- finder->find(PyName_ToName(name),
- PyRRType_ToRRType(rrtype),
- NULL,
- options
- ));
- ZoneFinder::Result r = find_result.code;
+ const ZoneFinder::FindResult find_result(
+ finder->find(PyName_ToName(name), PyRRType_ToRRType(rrtype),
+ NULL, options));
+ const ZoneFinder::Result r = find_result.code;
isc::dns::ConstRRsetPtr rrsp = find_result.rrset;
if (rrsp) {
// Use N instead of O so the refcount isn't increased twice
diff --git a/src/lib/python/isc/datasrc/tests/datasrc_test.py b/src/lib/python/isc/datasrc/tests/datasrc_test.py
index e46c177..3e4a1d7 100644
--- a/src/lib/python/isc/datasrc/tests/datasrc_test.py
+++ b/src/lib/python/isc/datasrc/tests/datasrc_test.py
@@ -285,6 +285,24 @@ class DataSrcClient(unittest.TestCase):
self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
rrset.to_text())
+ # Check the optional parameters are optional
+ result, rrset = finder.find(isc.dns.Name("www.example.com"),
+ isc.dns.RRType.A())
+ self.assertEqual(finder.SUCCESS, result)
+ self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
+ rrset.to_text())
+
+ result, rrset = finder.find(isc.dns.Name("www.example.com"),
+ isc.dns.RRType.A(), None)
+ self.assertEqual(finder.SUCCESS, result)
+ self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
+ rrset.to_text())
+
+ # Invalid value for the "target"
+ self.assertRaises(TypeError, finder.find,
+ isc.dns.Name("www.example.com"),
+ isc.dns.RRType.A(), True)
+
result, rrset = finder.find(isc.dns.Name("www.sql1.example.com"),
isc.dns.RRType.A(),
None,
@@ -385,6 +403,36 @@ class DataSrcUpdater(unittest.TestCase):
# can't construct directly
self.assertRaises(TypeError, isc.datasrc.ZoneUpdater)
+ def test_update_finder(self):
+ # Check basic behavior of updater's finder
+ dsc = isc.datasrc.DataSourceClient("sqlite3", WRITE_ZONE_DB_CONFIG)
+ updater = dsc.get_updater(isc.dns.Name("example.com"), False)
+ result, rrset = updater.find(isc.dns.Name("www.example.com"),
+ isc.dns.RRType.A(),
+ None,
+ ZoneFinder.FIND_DEFAULT)
+ self.assertEqual(ZoneFinder.SUCCESS, result)
+ self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
+ rrset.to_text())
+
+ # Omit optional parameters
+ result, rrset = updater.find(isc.dns.Name("www.example.com"),
+ isc.dns.RRType.A())
+ self.assertEqual(ZoneFinder.SUCCESS, result)
+ self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
+ rrset.to_text())
+
+ result, rrset = updater.find(isc.dns.Name("www.example.com"),
+ isc.dns.RRType.A(), None)
+ self.assertEqual(ZoneFinder.SUCCESS, result)
+ self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
+ rrset.to_text())
+
+ # Invalid value for 'target'
+ self.assertRaises(TypeError, updater.find,
+ isc.dns.Name("www.example.com"),
+ isc.dns.RRType.A(), 1)
+
def test_update_delete_commit(self):
dsc = isc.datasrc.DataSourceClient("sqlite3", WRITE_ZONE_DB_CONFIG)
diff --git a/src/lib/python/isc/notify/notify_out.py b/src/lib/python/isc/notify/notify_out.py
index af79b7c..64a4b3e 100644
--- a/src/lib/python/isc/notify/notify_out.py
+++ b/src/lib/python/isc/notify/notify_out.py
@@ -284,14 +284,12 @@ class NotifyOut:
format_zone_str(zone_name, zone_class))
return []
- result, ns_rrset = finder.find(zone_name, RRType.NS(), None,
- finder.FIND_DEFAULT)
+ result, ns_rrset = finder.find(zone_name, RRType.NS())
if result is not finder.SUCCESS or ns_rrset is None:
logger.warn(NOTIFY_OUT_ZONE_NO_NS,
format_zone_str(zone_name, zone_class))
return []
- result, soa_rrset = finder.find(zone_name, RRType.SOA(), None,
- finder.FIND_DEFAULT)
+ result, soa_rrset = finder.find(zone_name, RRType.SOA())
if result is not finder.SUCCESS or soa_rrset is None or \
soa_rrset.get_rdata_count() != 1:
logger.warn(NOTIFY_OUT_ZONE_BAD_SOA,
@@ -304,13 +302,11 @@ class NotifyOut:
ns_name = Name(ns_rdata.to_text())
if soa_mname == ns_name:
continue
- result, rrset = finder.find(ns_name, RRType.A(), None,
- finder.FIND_DEFAULT)
+ result, rrset = finder.find(ns_name, RRType.A())
if result is finder.SUCCESS and rrset is not None:
addrs.extend([a.to_text() for a in rrset.get_rdata()])
- result, rrset = finder.find(ns_name, RRType.AAAA(), None,
- finder.FIND_DEFAULT)
+ result, rrset = finder.find(ns_name, RRType.AAAA())
if result is finder.SUCCESS and rrset is not None:
addrs.extend([aaaa.to_text() for aaaa in rrset.get_rdata()])
@@ -504,8 +500,7 @@ class NotifyOut:
zone_name.to_text() + '/' +
zone_class.to_text() + ' not found')
- result, soa_rrset = finder.find(zone_name, RRType.SOA(), None,
- finder.FIND_DEFAULT)
+ result, soa_rrset = finder.find(zone_name, RRType.SOA())
if result is not finder.SUCCESS or soa_rrset is None or \
soa_rrset.get_rdata_count() != 1:
raise NotifyOutDataSourceError('_get_zone_soa: Zone ' +
More information about the bind10-changes
mailing list