BIND 10 vorner-tmp-sync, updated. 0498d715dbc69612877f5b5c9d27b18642adbdec TMP COMMIT
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jul 16 13:53:43 UTC 2012
The branch, vorner-tmp-sync has been updated
discards 4152bc4b9b40e4ccb6a44f9c692224eb07e77ae6 (commit)
via 0498d715dbc69612877f5b5c9d27b18642adbdec (commit)
via f0ce2e2039b298dc4a64e64da86b82f78dbb3a70 (commit)
via 9aaaaca8c1dd8e735d8695bf2cbab95965e3bd2b (commit)
This update added new revisions after undoing existing revisions. That is
to say, the old revision is not a strict subset of the new revision. This
situation occurs when you --force push a change and generate a repository
containing something like this:
* -- * -- B -- O -- O -- O (4152bc4b9b40e4ccb6a44f9c692224eb07e77ae6)
\
N -- N -- N (0498d715dbc69612877f5b5c9d27b18642adbdec)
When this happens we assume that you've already had alert emails for all
of the O revisions, and so we here report only the revisions in the N
branch from the common base, B.
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 0498d715dbc69612877f5b5c9d27b18642adbdec
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date: Mon Jul 16 15:53:15 2012 +0200
TMP COMMIT
-----------------------------------------------------------------------
Summary of changes:
src/lib/python/isc/datasrc/Makefile.am | 3 +
.../isc/datasrc/configurableclientlist_inc.cc | 13 +++
.../isc/datasrc/configurableclientlist_python.cc | 84 +++++++++++++++---
src/lib/python/isc/datasrc/datasrc.cc | 6 ++
src/lib/python/isc/datasrc/tests/Makefile.am | 3 +-
.../python/isc/datasrc/tests/clientlist_test.py | 92 ++++++++++++++++++++
6 files changed, 188 insertions(+), 13 deletions(-)
create mode 100644 src/lib/python/isc/datasrc/configurableclientlist_inc.cc
create mode 100644 src/lib/python/isc/datasrc/tests/clientlist_test.py
-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/datasrc/Makefile.am b/src/lib/python/isc/datasrc/Makefile.am
index 1d862db..a51bdb8 100644
--- a/src/lib/python/isc/datasrc/Makefile.am
+++ b/src/lib/python/isc/datasrc/Makefile.am
@@ -18,6 +18,8 @@ datasrc_la_SOURCES += iterator_python.cc iterator_python.h
datasrc_la_SOURCES += finder_python.cc finder_python.h
datasrc_la_SOURCES += updater_python.cc updater_python.h
datasrc_la_SOURCES += journal_reader_python.cc journal_reader_python.h
+datasrc_la_SOURCES += configurableclientlist_python.cc
+datasrc_la_SOURCES += configurableclientlist_python.h
datasrc_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
datasrc_la_CXXFLAGS = $(AM_CXXFLAGS) $(PYTHON_CXXFLAGS)
@@ -33,6 +35,7 @@ EXTRA_DIST += finder_inc.cc
EXTRA_DIST += iterator_inc.cc
EXTRA_DIST += updater_inc.cc
EXTRA_DIST += journal_reader_inc.cc
+EXTRA_DIST += configurableclientlist_inc.cc
CLEANDIRS = __pycache__
diff --git a/src/lib/python/isc/datasrc/configurableclientlist_inc.cc b/src/lib/python/isc/datasrc/configurableclientlist_inc.cc
new file mode 100644
index 0000000..230e53a
--- /dev/null
+++ b/src/lib/python/isc/datasrc/configurableclientlist_inc.cc
@@ -0,0 +1,13 @@
+namespace {
+
+const char* const ConfigurableClientList_doc = "\
+The list of data source clients\n\
+\n\
+The purpose is to have several data source clients of the same class\
+and then be able to search through them to identify the one containing\
+a given zone.\n\
+\n\
+Unlike the C++ version, we don't have the abstract base class. Abstract\
+classes are not needed due to the duck typing nature of python.\
+";
+} // unnamed namespace
diff --git a/src/lib/python/isc/datasrc/configurableclientlist_python.cc b/src/lib/python/isc/datasrc/configurableclientlist_python.cc
index ada7276..5713ae9 100644
--- a/src/lib/python/isc/datasrc/configurableclientlist_python.cc
+++ b/src/lib/python/isc/datasrc/configurableclientlist_python.cc
@@ -26,10 +26,13 @@
#include <util/python/pycppwrapper_util.h>
#include <dns/python/rrclass_python.h>
+#include <dns/python/name_python.h>
#include <datasrc/client_list.h>
#include "configurableclientlist_python.h"
+#include "datasrc.h"
+#include "configurableclientlist_inc.cc"
using namespace std;
using namespace isc::util::python;
@@ -45,24 +48,24 @@ s_ConfigurableClientList::s_ConfigurableClientList() : cppobj(NULL) {
}
namespace {
-// Shortcut type which would be convenient for adding class variables safely.
-typedef CPPPyObjectContainer<s_ConfigurableClientList, ConfigurableClientList>
- ConfigurableClientListContainer;
int
ConfigurableClientList_init(PyObject* po_self, PyObject* args, PyObject*) {
s_ConfigurableClientList* self =
static_cast<s_ConfigurableClientList*>(po_self);
try {
- isc::dns::RRClass rrclass;
- if (PyArg_ParseTuple(args, "O!", &rrclass_type, &rrclass)) {
- self->cppobj = new ConfigurableClientList(rrclass);
+ const PyObject* rrclass;
+ if (PyArg_ParseTuple(args, "O!", &isc::dns::python::rrclass_type,
+ &rrclass)) {
+ self->cppobj =
+ new ConfigurableClientList(isc::dns::python::
+ PyRRClass_ToRRClass(rrclass));
return (0);
}
} catch (const exception& ex) {
const string ex_what = "Failed to construct ConfigurableClientList object: " +
string(ex.what());
- PyErr_SetString(po_IscException, ex_what.c_str());
+ PyErr_SetString(getDataSourceException("Error"), ex_what.c_str());
return (-1);
} catch (...) {
PyErr_SetString(PyExc_SystemError, "Unexpected C++ exception");
@@ -81,6 +84,61 @@ ConfigurableClientList_destroy(PyObject* po_self) {
Py_TYPE(self)->tp_free(self);
}
+PyObject*
+ConfigurableClientList_configure(PyObject* po_self, PyObject* args) {
+ s_ConfigurableClientList* self =
+ static_cast<s_ConfigurableClientList*>(po_self);
+ try {
+ const char* configuration;
+ int allow_cache;
+ if (PyArg_ParseTuple(args, "si", &configuration, &allow_cache)) {
+ const isc::data::ConstElementPtr
+ element(isc::data::Element::fromJSON(string(configuration)));
+ self->cppobj->configure(*element, allow_cache);
+ Py_RETURN_NONE;
+ } else {
+ return (NULL);
+ }
+ } catch (const std::exception& exc) {
+ PyErr_SetString(getDataSourceException("Error"), exc.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(getDataSourceException("Error"),
+ "Unknown C++ exception");
+ return (NULL);
+ }
+}
+
+PyObject*
+ConfigurableClientList_find(PyObject* po_self, PyObject* args) {
+ s_ConfigurableClientList* self =
+ static_cast<s_ConfigurableClientList*>(po_self);
+ try {
+ PyObject* name_obj;
+ int want_exact_match = 0;
+ int want_finder = 1;
+ if (PyArg_ParseTuple(args, "O!|ii", &isc::dns::python::name_type,
+ &name_obj, &want_exact_match, &want_finder)) {
+ const isc::dns::Name
+ name(isc::dns::python::PyName_ToName(name_obj));
+ const ClientList::FindResult
+ result(self->cppobj->find(name, want_exact_match,
+ want_finder));
+ // TODO: Exception safety here, please
+
+ } else {
+ return (NULL);
+ }
+ } catch (const std::exception& exc) {
+ PyErr_SetString(getDataSourceException("Error"), exc.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(getDataSourceException("Error"),
+ "Unknown C++ exception");
+ return (NULL);
+ }
+}
+
// This list contains the actual set of functions we have in
// python. Each entry has
// 1. Python method name
@@ -88,6 +146,8 @@ ConfigurableClientList_destroy(PyObject* po_self) {
// 3. Argument type
// 4. Documentation
PyMethodDef ConfigurableClientList_methods[] = {
+ { "configure", ConfigurableClientList_configure, METH_VARARGS,
+ "TODO: Docs" },
{ NULL, NULL, 0, NULL }
};
} // end of unnamed namespace
@@ -158,15 +218,14 @@ initModulePart_ConfigurableClientList(PyObject* mod) {
return (false);
}
void* p = &configurableclientlist_type;
- if (PyModule_AddObject(mod, "ConfigurableClientList", static_cast<PyObject*>(p)) < 0) {
+ if (PyModule_AddObject(mod, "ConfigurableClientList",
+ static_cast<PyObject*>(p)) < 0) {
return (false);
}
Py_INCREF(&configurableclientlist_type);
- @REMOVE_THIS_ON_RELEASE@
- // The following template is the typical procedure for installing class
- // variables. If the class doesn't have a class variable, remove the
- // entire try-catch clauses.
+#if 0
+ TODO: The return states, etc.
try {
// Constant class variables
installClassVariable(configurableclientlist_type, "REPLACE_ME",
@@ -182,6 +241,7 @@ initModulePart_ConfigurableClientList(PyObject* mod) {
"Unexpected failure in ConfigurableClientList initialization");
return (false);
}
+#endif
return (true);
}
diff --git a/src/lib/python/isc/datasrc/datasrc.cc b/src/lib/python/isc/datasrc/datasrc.cc
index f31d10a..533a08c 100644
--- a/src/lib/python/isc/datasrc/datasrc.cc
+++ b/src/lib/python/isc/datasrc/datasrc.cc
@@ -28,6 +28,7 @@
#include "iterator_python.h"
#include "updater_python.h"
#include "journal_reader_python.h"
+#include "configurableclientlist_python.h"
#include <util/python/pycppwrapper_util.h>
#include <dns/python/pydnspp_common.h>
@@ -284,6 +285,11 @@ PyInit_datasrc(void) {
return (NULL);
}
+ if (!initModulePart_ConfigurableClientList(mod)) {
+ Py_DECREF(mod);
+ return (NULL);
+ }
+
try {
po_DataSourceError = PyErr_NewException("isc.datasrc.Error", NULL,
NULL);
diff --git a/src/lib/python/isc/datasrc/tests/Makefile.am b/src/lib/python/isc/datasrc/tests/Makefile.am
index c996f2a..34af092 100644
--- a/src/lib/python/isc/datasrc/tests/Makefile.am
+++ b/src/lib/python/isc/datasrc/tests/Makefile.am
@@ -1,7 +1,7 @@
PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
# old tests, TODO remove or change to use new API?
#PYTESTS = master_test.py
-PYTESTS = datasrc_test.py sqlite3_ds_test.py
+PYTESTS = datasrc_test.py sqlite3_ds_test.py clientlist_test.py
EXTRA_DIST = $(PYTESTS)
EXTRA_DIST += testdata/brokendb.sqlite3
@@ -36,6 +36,7 @@ endif
PYTHONPATH=:$(COMMON_PYTHON_PATH):$(abs_top_builddir)/src/lib/python/isc/log:$(abs_top_builddir)/src/lib/python/isc/datasrc/.libs:$(abs_top_builddir)/src/lib/dns/python/.libs \
TESTDATA_PATH=$(abs_srcdir)/testdata \
TESTDATA_WRITE_PATH=$(abs_builddir) \
+ GLOBAL_TESTDATA_PATH=$(abs_top_srcdir)/src/lib/testutils/testdata \
B10_FROM_BUILD=$(abs_top_builddir) \
$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done
diff --git a/src/lib/python/isc/datasrc/tests/clientlist_test.py b/src/lib/python/isc/datasrc/tests/clientlist_test.py
new file mode 100644
index 0000000..775a318
--- /dev/null
+++ b/src/lib/python/isc/datasrc/tests/clientlist_test.py
@@ -0,0 +1,92 @@
+# Copyright (C) 2012 Internet Systems Consortium.
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+import isc.log
+import isc.datasrc
+import isc.dns
+import unittest
+import os
+
+TESTDATA_PATH = os.environ['GLOBAL_TESTDATA_PATH'] + os.sep
+
+class ClientListTest(unittest.TestCase):
+ """
+ Test cases for the client lists. Currently, the python wrappers
+ contain the ConfigurableClientList only.
+ """
+
+ def test_constructors(self):
+ """
+ Test the constructor. It should accept an RRClass. Check it
+ reject invalid inputs.
+ """
+ isc.datasrc.ConfigurableClientList(isc.dns.RRClass.IN())
+ isc.datasrc.ConfigurableClientList(isc.dns.RRClass.CH())
+ # Not enough arguments
+ self.assertRaises(TypeError, isc.datasrc.ConfigurableClientList)
+ # Bad types of arguments
+ self.assertRaises(TypeError, isc.datasrc.ConfigurableClientList, 0)
+ self.assertRaises(TypeError, isc.datasrc.ConfigurableClientList, "IN")
+ # Too many arguments
+ self.assertRaises(TypeError, isc.datasrc.ConfigurableClientList,
+ isc.dns.RRClass.IN(), isc.dns.RRClass.IN())
+
+ def test_configure(self):
+ """
+ Test we can configure the client list. This tests if the valid
+ ones are acceptend and invalid rejected. We check the changes
+ have effect.
+ """
+ clist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.IN())
+ # This should be NOP now
+ clist.configure("[]", True)
+ # Check the zone is not there yet
+ dsrc, finder, exact = clist.find(isc.dns.Name("example.org"))
+ self.assertIsNone(dsrc)
+ self.assertIsNone(finder)
+ self.assertFalse(exact)
+ self.checkName("example.org", True)
+ # We can use this type, as it is not loaded dynamically.
+ clist.configure('''[{
+ "type": "MasterFiles",
+ "params": {
+ "example.org": "''' + TESTDATA_PATH + '''example.org.zone"
+ },
+ "cache-enable": true
+ }]''', True)
+ # Check the zone is there now. Proper tests of find are in other
+ # test methods.
+ dsrc, finder, exact = clist.find(isc.dns.Name("example.org"))
+ self.assertIsNotNone(dsrc)
+ self.assertTrue(isinstance(dsrc, isc.datasrc.DataSourceClient))
+ self.assertIsNotNone(finder)
+ self.assertTrue(isinstance(finder, isc.datasrc.ZoneFinder))
+ self.assertTrue(exact)
+ self.assertRaises(isc.datasrc.Error, clist.configure, '"bad type"',
+ True)
+ self.assertRaises(isc.datasrc.Error, clist.configure, '''[{
+ "type": "bad type"
+ }]''', True)
+ self.assertRaises(isc.datasrc.Error, clist.configure, '''[{
+ bad JSON,
+ }]''', True)
+ self.assertRaises(TypeError, clist.configure, [], True)
+ self.assertRaises(TypeError, clist.configure, "[]")
+ self.assertRaises(TypeError, clist.configure, "[]", "true")
+
+if __name__ == "__main__":
+ isc.log.init("bind10")
+ isc.log.resetUnitTestRootLogger()
+ unittest.main()
More information about the bind10-changes
mailing list