Browse Source

Merge branch 'master' into trac2672

Conflicts:
	src/lib/python/isc/ddns/session.py
Mukund Sivaraman 12 years ago
parent
commit
660a0d164f
64 changed files with 2366 additions and 1777 deletions
  1. 16 0
      ChangeLog
  2. 16 1
      configure.ac
  3. 900 71
      doc/guide/bind10-guide.xml
  4. 1 1
      src/bin/auth/auth_config.cc
  5. 1 1
      src/bin/auth/tests/config_unittest.cc
  6. 10 3
      src/bin/bind10/bind10.in
  7. 1 0
      src/bin/bind10/init.py.in
  8. 1 1
      src/bin/bind10/tests/Makefile.am
  9. 1 1
      src/bin/bind10/tests/bind10_test.py.in
  10. 1 1
      src/bin/bindctl/bindcmd.py
  11. 1 1
      src/bin/bindctl/run_bindctl.sh.in
  12. 2 2
      src/bin/ddns/ddns.py.in
  13. 17 17
      src/bin/ddns/tests/ddns_test.py
  14. 1 1
      src/bin/loadzone/loadzone.py.in
  15. 3 3
      src/bin/loadzone/tests/loadzone_test.py
  16. 8 1
      src/bin/sockcreator/tests/sockcreator_tests.cc
  17. 2 1
      src/bin/stats/stats.py.in
  18. 1 13
      src/bin/sysinfo/run_sysinfo.sh.in
  19. 147 149
      src/bin/xfrin/tests/xfrin_test.py
  20. 31 31
      src/bin/xfrin/xfrin.py.in
  21. 61 61
      src/bin/xfrout/tests/xfrout_test.py.in
  22. 33 33
      src/bin/xfrout/xfrout.py.in
  23. 4 0
      src/lib/dns/Makefile.am
  24. 92 26
      src/lib/dns/gen-rdatacode.py.in
  25. 0 140
      src/lib/dns/python/opcode_python.cc
  26. 164 66
      src/lib/dns/python/pydnspp.cc
  27. 0 146
      src/lib/dns/python/rcode_python.cc
  28. 0 43
      src/lib/dns/python/rrclass_python.cc
  29. 0 144
      src/lib/dns/python/rrtype_python.cc
  30. 3 3
      src/lib/dns/python/tests/edns_python_test.py
  31. 17 17
      src/lib/dns/python/tests/message_python_test.py
  32. 4 4
      src/lib/dns/python/tests/messagerenderer_python_test.py
  33. 23 23
      src/lib/dns/python/tests/nsec3hash_python_test.py
  34. 41 41
      src/lib/dns/python/tests/opcode_python_test.py
  35. 30 30
      src/lib/dns/python/tests/rcode_python_test.py
  36. 10 10
      src/lib/dns/python/tests/rrclass_python_test.py
  37. 23 23
      src/lib/dns/python/tests/rrset_collection_python_test.py
  38. 22 22
      src/lib/dns/python/tests/rrtype_python_test.py
  39. 18 18
      src/lib/dns/python/tests/tsig_python_test.py
  40. 13 13
      src/lib/dns/python/tests/tsigerror_python_test.py
  41. 29 32
      src/lib/dns/python/tests/zone_checker_python_test.py
  42. 4 0
      src/lib/dns/rdata/template.h
  43. 0 14
      src/lib/dns/rrclass-placeholder.h
  44. 0 30
      src/lib/dns/rrtype-placeholder.h
  45. 25 0
      src/lib/dns/tests/rrclass_unittest.cc
  46. 1 1
      src/lib/dns/tests/rrset_unittest.cc
  47. 53 0
      src/lib/dns/tests/rrtype_unittest.cc
  48. 3 7
      src/lib/python/isc/__init__.py
  49. 5 5
      src/lib/python/isc/datasrc/tests/clientlist_test.py
  50. 70 70
      src/lib/python/isc/datasrc/tests/datasrc_test.py
  51. 3 2
      src/lib/python/isc/datasrc/tests/zone_loader_test.py
  52. 57 57
      src/lib/python/isc/ddns/session.py
  53. 306 309
      src/lib/python/isc/ddns/tests/session_tests.py
  54. 7 7
      src/lib/python/isc/ddns/tests/zone_config_tests.py
  55. 9 9
      src/lib/python/isc/notify/notify_out.py
  56. 7 7
      src/lib/python/isc/notify/tests/notify_out_test.py
  57. 3 3
      src/lib/python/isc/statistics/tests/counters_test.py
  58. 9 6
      src/lib/python/isc/sysinfo/sysinfo.py
  59. 13 13
      src/lib/python/isc/testutils/rrset_utils.py
  60. 5 5
      src/lib/python/isc/xfrin/diff.py
  61. 30 30
      src/lib/python/isc/xfrin/tests/diff_tests.py
  62. 5 5
      src/lib/util/unittests/fork.cc
  63. 2 2
      src/lib/util/unittests/fork.h
  64. 1 1
      tools/query_cmp/src/lib/handledns.py

+ 16 - 0
ChangeLog

@@ -1,3 +1,19 @@
+567.	[doc]		marcin, stephen, tomek
+	Update DHCP sections of the BIND 10 guide.
+	(Trac #2657, git 1d0c2004865d1bf322bf78d13630d992e39179fd)
+
+566.	[func]*		jinmei
+	libdns++/Python isc.dns: In Python isc.dns, function style
+	constants for RRType, RRClass, Rcode and Opcode were deprecated
+	and replaced with straightforward object constants, e.g., from
+	RRType.AAAA() to RRType.AAAA.  This is a backward incompatible
+	change (see the Trac ticket for a conversion script if needed).
+	Also, these constants are now more consistent between C++
+	and Python, and RRType constants for all currently standardized
+	types are now supported (even if Rdata for these are not yet
+	available).
+	(Trac #1866 and #2409, git e5005185351cf73d4a611407c2cfcd163f80e428)
+
 565.	[func]*		jelte
 	The main initializer script (formerly known as either 'bind10',
 	'boss', or 'bob'), has been renamed to b10-init (and Init in

+ 16 - 1
configure.ac

@@ -238,6 +238,21 @@ AM_CONDITIONAL(SET_ENV_LIBRARY_PATH, test $SET_ENV_LIBRARY_PATH = yes)
 AC_SUBST(SET_ENV_LIBRARY_PATH)
 AC_SUBST(ENV_LIBRARY_PATH)
 
+# Our experiments have shown Solaris 10 has broken support for the
+# IPV6_USE_MIN_MTU socket option for getsockopt(); it doesn't return the value
+# previously set via setsockopt().  We know it doesn't happen on one instance
+# on Solaris 11, but we don't know whether it happens for any Solaris 10
+# implementations or for earlier versions of Solaris.  In any case, at the
+# moment this matters for only one unittest case, so we'll simply disable
+# the affected test using the following definition with the specific hardcoding
+# of that version of Solaris.
+case "$host" in
+*-solaris2.10)
+	AC_DEFINE([HAVE_BROKEN_GET_IPV6_USE_MIN_MTU], [1],
+	[Define to 1 if getsockopt(IPV6_USE_MIN_MTU) does not work])
+	;;
+esac
+
 m4_define([_AM_PYTHON_INTERPRETER_LIST], [python python3.3 python3.2 python3.1 python3])
 AC_ARG_WITH([pythonpath],
 AC_HELP_STRING([--with-pythonpath=PATH],
@@ -1319,7 +1334,7 @@ AC_OUTPUT([doc/version.ent
            src/bin/stats/stats_httpd.py
            src/bin/bind10/init.py
            src/bin/bind10/run_bind10.sh
-           src/bin/bind10/tests/bind10_test.py
+           src/bin/bind10/tests/init_test.py
            src/bin/bindctl/run_bindctl.sh
            src/bin/bindctl/bindctl_main.py
            src/bin/bindctl/tests/bindctl_test

File diff suppressed because it is too large
+ 900 - 71
doc/guide/bind10-guide.xml


+ 1 - 1
src/bin/auth/auth_config.cc

@@ -106,7 +106,7 @@ public:
         rollbackAddresses_ = old;
     }
     virtual void commit() {
-        rollbackAddresses_.release();
+        rollbackAddresses_.reset();
     }
 private:
     AuthSrv& server_;

+ 1 - 1
src/bin/auth/tests/config_unittest.cc

@@ -130,7 +130,7 @@ TEST_F(AuthConfigTest, invalidListenAddressConfig) {
     isc::testutils::portconfig::invalidListenAddressConfig(server);
 }
 
-// Try setting addresses trough config
+// Try setting addresses through config
 TEST_F(AuthConfigTest, listenAddressConfig) {
     isc::testutils::portconfig::listenAddressConfig(server);
 

+ 10 - 3
src/bin/bind10/bind10.in

@@ -1,4 +1,11 @@
 #!/bin/sh
-prefix=@prefix@
-exec_prefix=@exec_prefix@
-exec @libexecdir@/@PACKAGE@/b10-init $*
+
+# We use this wrapper script both for production and in-source tests; in
+# the latter case B10_FROM_BUILD environment is expected to be defined.
+if test -n "${B10_FROM_BUILD}"; then
+	exec ${B10_FROM_BUILD}/src/bin/bind10/b10-init $*
+else
+	prefix=@prefix@
+	exec_prefix=@exec_prefix@
+	exec @libexecdir@/@PACKAGE@/b10-init $*
+fi

+ 1 - 0
src/bin/bind10/init.py.in

@@ -72,6 +72,7 @@ import isc.cc
 import isc.util.process
 import isc.net.parse
 import isc.log
+import isc.config
 from isc.log_messages.init_messages import *
 import isc.bind10.component
 import isc.bind10.special_component

+ 1 - 1
src/bin/bind10/tests/Makefile.am

@@ -1,7 +1,7 @@
 PYCOVERAGE_RUN = @PYCOVERAGE_RUN@
 #PYTESTS = args_test.py bind10_test.py
 # NOTE: this has a generated test found in the builddir
-PYTESTS = bind10_test.py
+PYTESTS = init_test.py
 noinst_SCRIPTS = $(PYTESTS)
 
 # If necessary (rare cases), explicitly specify paths to dynamic libraries

+ 1 - 1
src/bin/bind10/tests/bind10_test.py.in

@@ -31,8 +31,8 @@ import signal
 import socket
 from isc.net.addr import IPAddr
 import time
-import isc
 import isc.log
+import isc.config
 import isc.bind10.socket_cache
 import errno
 import random

+ 1 - 1
src/bin/bindctl/bindcmd.py

@@ -25,7 +25,7 @@ from bindctl.moduleinfo import *
 from bindctl.cmdparse import BindCmdParser
 from bindctl import command_sets
 from xml.dom import minidom
-import isc
+import isc.config
 import isc.cc.data
 import http.client
 import json

+ 1 - 1
src/bin/bindctl/run_bindctl.sh.in

@@ -23,7 +23,7 @@ BINDCTL_PATH=@abs_top_builddir@/src/bin/bindctl
 # Note: lib/dns/python/.libs is necessary because __init__.py of isc package
 # automatically imports isc.datasrc, which then requires the DNS loadable
 # module.  #2145 should eliminate the need for it.
-PYTHONPATH=@abs_top_srcdir@/src/bin:@abs_top_builddir@/src/lib/python/isc/log_messages:@abs_top_builddir@/src/lib/python:@abs_top_builddir@/src/bin:@abs_top_srcdir@/src/lib/python:@abs_top_builddir@/src/lib/dns/python/.libs
+PYTHONPATH=@abs_top_srcdir@/src/bin:@abs_top_builddir@/src/lib/python/isc/log_messages:@abs_top_builddir@/src/lib/python:@abs_top_builddir@/src/bin:@abs_top_srcdir@/src/lib/python
 export PYTHONPATH
 
 # If necessary (rare cases), explicitly specify paths to dynamic libraries

+ 2 - 2
src/bin/ddns/ddns.py.in

@@ -134,7 +134,7 @@ def get_datasrc_client(cc_session):
     function will simply be removed.
 
     '''
-    HARDCODED_DATASRC_CLASS = RRClass.IN()
+    HARDCODED_DATASRC_CLASS = RRClass.IN
     file, is_default = cc_session.get_remote_config_value("Auth",
                                                           "database_file")
     # See xfrout.py:get_db_file() for this trick:
@@ -469,7 +469,7 @@ class DDNSServer:
             self.__request_msg.clear(Message.PARSE)
             # specify PRESERVE_ORDER as we need to handle each RR separately.
             self.__request_msg.from_wire(req_data, Message.PRESERVE_ORDER)
-            if self.__request_msg.get_opcode() != Opcode.UPDATE():
+            if self.__request_msg.get_opcode() != Opcode.UPDATE:
                 raise self.InternalError('Update request has unexpected '
                                          'opcode: ' +
                                          str(self.__request_msg.get_opcode()))

+ 17 - 17
src/bin/ddns/tests/ddns_test.py

@@ -39,9 +39,9 @@ TESTDATA_PATH = os.environ['TESTDATA_PATH'] + os.sep
 READ_ZONE_DB_FILE = TESTDATA_PATH + "rwtest.sqlite3" # original, to be copied
 TEST_ZONE_NAME = Name('example.org')
 TEST_ZONE_NAME_STR = TEST_ZONE_NAME.to_text()
-UPDATE_RRTYPE = RRType.SOA()
+UPDATE_RRTYPE = RRType.SOA
 TEST_QID = 5353                 # arbitrary chosen
-TEST_RRCLASS = RRClass.IN()
+TEST_RRCLASS = RRClass.IN
 TEST_RRCLASS_STR = TEST_RRCLASS.to_text()
 TEST_SERVER6 = ('2001:db8::53', 53, 0, 0)
 TEST_CLIENT6 = ('2001:db8::1', 53000, 0, 0)
@@ -169,9 +169,9 @@ class FakeUpdateSession:
         self.__msg.make_response()
         self.__msg.clear_section(SECTION_ZONE)
         if self.__faked_result == UPDATE_SUCCESS:
-            self.__msg.set_rcode(Rcode.NOERROR())
+            self.__msg.set_rcode(Rcode.NOERROR)
         else:
-            self.__msg.set_rcode(Rcode.REFUSED())
+            self.__msg.set_rcode(Rcode.REFUSED)
         return self.__msg
 
 class FakeKeyringModule:
@@ -478,7 +478,7 @@ class TestDDNSServer(unittest.TestCase):
         # By default (in our faked config) it should be derived from the
         # test data source
         rrclass, datasrc_client = self.ddns_server._datasrc_info
-        self.assertEqual(RRClass.IN(), rrclass)
+        self.assertEqual(RRClass.IN, rrclass)
         self.assertEqual(DataSourceClient.SUCCESS,
                          datasrc_client.find_zone(Name('example.org'))[0])
 
@@ -491,7 +491,7 @@ class TestDDNSServer(unittest.TestCase):
             {'database_file': './notexistentdir/somedb.sqlite3'}
         self.__cc_session.add_remote_config_by_name('Auth')
         rrclass, datasrc_client = self.ddns_server._datasrc_info
-        self.assertEqual(RRClass.IN(), rrclass)
+        self.assertEqual(RRClass.IN, rrclass)
         self.assertRaises(isc.datasrc.Error,
                           datasrc_client.find_zone, Name('example.org'))
 
@@ -887,12 +887,12 @@ class TestDDNSServer(unittest.TestCase):
         self.__select_answer = ([], [10], [])
         self.assertRaises(KeyError, self.ddns_server.run)
 
-def create_msg(opcode=Opcode.UPDATE(), zones=[TEST_ZONE_RECORD], prereq=[],
+def create_msg(opcode=Opcode.UPDATE, zones=[TEST_ZONE_RECORD], prereq=[],
                tsigctx=None):
     msg = Message(Message.RENDER)
     msg.set_qid(TEST_QID)
     msg.set_opcode(opcode)
-    msg.set_rcode(Rcode.NOERROR())
+    msg.set_rcode(Rcode.NOERROR)
     for z in zones:
         msg.add_question(z)
     for p in prereq:
@@ -936,7 +936,7 @@ class TestDDNSSession(unittest.TestCase):
         return FakeUpdateSession(req_message, client_addr, zone_config,
                                  self.__faked_result)
 
-    def check_update_response(self, resp_wire, expected_rcode=Rcode.NOERROR(),
+    def check_update_response(self, resp_wire, expected_rcode=Rcode.NOERROR,
                               tsig_ctx=None, tcp=False):
         '''Check if given wire data are valid form of update response.
 
@@ -963,7 +963,7 @@ class TestDDNSSession(unittest.TestCase):
             self.assertNotEqual(None, tsig_record)
             self.assertEqual(TSIGError.NOERROR,
                              tsig_ctx.verify(tsig_record, resp_wire))
-        self.assertEqual(Opcode.UPDATE(), msg.get_opcode())
+        self.assertEqual(Opcode.UPDATE, msg.get_opcode())
         self.assertEqual(expected_rcode, msg.get_rcode())
         self.assertEqual(TEST_QID, msg.get_qid())
         for section in [SECTION_ZONE, SECTION_PREREQUISITE, SECTION_UPDATE]:
@@ -977,7 +977,7 @@ class TestDDNSSession(unittest.TestCase):
         server_addr = TEST_SERVER6 if ipv6 else TEST_SERVER4
         client_addr = TEST_CLIENT6 if ipv6 else TEST_CLIENT4
         tsig = TSIGContext(tsig_key) if tsig_key is not None else None
-        rcode = Rcode.NOERROR() if result == UPDATE_SUCCESS else Rcode.REFUSED()
+        rcode = Rcode.NOERROR if result == UPDATE_SUCCESS else Rcode.REFUSED
         has_response = (result != UPDATE_DROP)
 
         self.assertEqual(has_response,
@@ -1015,7 +1015,7 @@ class TestDDNSSession(unittest.TestCase):
 
         # Opcode is not UPDATE
         self.assertFalse(self.server.handle_request(
-                (self.__sock, None, None, create_msg(opcode=Opcode.QUERY()))))
+                (self.__sock, None, None, create_msg(opcode=Opcode.QUERY))))
         self.assertEqual((None, None), (s._sent_data, s._sent_addr))
 
         # TSIG verification error.  We use UPDATE_DROP to signal check_session
@@ -1031,7 +1031,7 @@ class TestDDNSSession(unittest.TestCase):
                                                      TEST_CLIENT6,
                                                      create_msg())))
         # this check ensures sendto() was really attempted.
-        self.check_update_response(self.__sock._sent_data, Rcode.NOERROR())
+        self.check_update_response(self.__sock._sent_data, Rcode.NOERROR)
 
     def test_tcp_request(self):
         # A simple case using TCP: all resopnse data are sent out at once.
@@ -1040,7 +1040,7 @@ class TestDDNSSession(unittest.TestCase):
         self.assertTrue(self.server.handle_request((s, TEST_SERVER6,
                                                     TEST_CLIENT6,
                                                     create_msg())))
-        self.check_update_response(s._sent_data, Rcode.NOERROR(), tcp=True)
+        self.check_update_response(s._sent_data, Rcode.NOERROR, tcp=True)
         # In the current implementation, the socket should be closed
         # immedidately after a successful send.
         self.assertEqual(1, s._close_called)
@@ -1071,7 +1071,7 @@ class TestDDNSSession(unittest.TestCase):
         s.make_send_ready()
         self.assertEqual(DNSTCPContext.SEND_DONE,
                          self.server._tcp_ctxs[s.fileno()][0].send_ready())
-        self.check_update_response(s._sent_data, Rcode.NOERROR(), tcp=True)
+        self.check_update_response(s._sent_data, Rcode.NOERROR, tcp=True)
 
     def test_tcp_request_error(self):
         # initial send() on the TCP socket will fail.  The request handling
@@ -1127,9 +1127,9 @@ class TestDDNSSession(unittest.TestCase):
         self.__faked_result = UPDATE_DROP
         # Put the same RR twice in the prerequisite section.  We should see
         # them as separate RRs.
-        dummy_record = RRset(TEST_ZONE_NAME, TEST_RRCLASS, RRType.NS(),
+        dummy_record = RRset(TEST_ZONE_NAME, TEST_RRCLASS, RRType.NS,
                              RRTTL(0))
-        dummy_record.add_rdata(Rdata(RRType.NS(), TEST_RRCLASS, "ns.example."))
+        dummy_record.add_rdata(Rdata(RRType.NS, TEST_RRCLASS, "ns.example."))
         self.server.handle_request((self.__sock, TEST_SERVER6, TEST_CLIENT6,
                                     create_msg(prereq=[dummy_record,
                                                        dummy_record])))

+ 1 - 1
src/bin/loadzone/loadzone.py.in

@@ -164,7 +164,7 @@ class LoadZoneRunner:
             self._zone_class = RRClass(options.zone_class)
         except isc.dns.InvalidRRClass as ex:
             raise BadArgument('Invalid zone class: ' + str(ex))
-        if self._zone_class != RRClass.IN():
+        if self._zone_class != RRClass.IN:
             raise BadArgument("RR class is not supported: " +
                               str(self._zone_class))
 

+ 3 - 3
src/bin/loadzone/tests/loadzone_test.py

@@ -79,7 +79,7 @@ class TestLoadZoneRunner(unittest.TestCase):
         self.assertEqual(DATASRC_CONFIG, self.__runner._datasrc_config)
         self.assertEqual('sqlite3', self.__runner._datasrc_type) # default
         self.assertEqual(10000, self.__runner._report_interval) # default
-        self.assertEqual(RRClass.IN(), self.__runner._zone_class) # default
+        self.assertEqual(RRClass.IN, self.__runner._zone_class) # default
         self.assertEqual('INFO', self.__runner._log_severity) # default
         self.assertEqual(0, self.__runner._log_debuglevel)
 
@@ -135,7 +135,7 @@ class TestLoadZoneRunner(unittest.TestCase):
                           'memory')
 
     def __common_load_setup(self):
-        self.__runner._zone_class = RRClass.IN()
+        self.__runner._zone_class = RRClass.IN
         self.__runner._zone_name = TEST_ZONE_NAME
         self.__runner._zone_file = NEW_ZONE_TXT_FILE
         self.__runner._datasrc_type = 'sqlite3'
@@ -159,7 +159,7 @@ class TestLoadZoneRunner(unittest.TestCase):
             self.assertEqual(client.NOTFOUND, result)
             return
         self.assertEqual(client.SUCCESS, result)
-        result, rrset, _ = finder.find(zone_name, RRType.SOA())
+        result, rrset, _ = finder.find(zone_name, RRType.SOA)
         if soa_txt:
             self.assertEqual(finder.SUCCESS, result)
             self.assertEqual(soa_txt, rrset.to_text())

+ 8 - 1
src/bin/sockcreator/tests/sockcreator_tests.cc

@@ -12,6 +12,8 @@
 // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 // PERFORMANCE OF THIS SOFTWARE.
 
+#include <config.h>
+
 #include "../sockcreator.h"
 
 #include <util/unittests/fork.h>
@@ -195,7 +197,12 @@ TEST(get_sock, tcp4_create) {
     testAnyCreate<sockaddr_in>(SOCK_STREAM, tcpCheck);
 }
 
-TEST(get_sock, udp6_create) {
+#ifdef HAVE_BROKEN_GET_IPV6_USE_MIN_MTU
+TEST(get_sock, DISABLED_udp6_create)
+#else
+TEST(get_sock, udp6_create)
+#endif
+{
     testAnyCreate<sockaddr_in6>(SOCK_DGRAM, udpCheck<sockaddr_in6>);
 }
 

+ 2 - 1
src/bin/stats/stats.py.in

@@ -26,7 +26,8 @@ from optparse import OptionParser, OptionValueError
 import errno
 import select
 
-import isc
+import isc.cc
+import isc.config
 import isc.util.process
 import isc.log
 from isc.log_messages.stats_messages import *

+ 1 - 13
src/bin/sysinfo/run_sysinfo.sh.in

@@ -20,20 +20,8 @@ export PYTHON_EXEC
 
 SYSINFO_PATH=@abs_top_builddir@/src/bin/sysinfo
 
-# Note: we shouldn't need log_messages and lib/dns except for the seemingly
-# necessary dependency due to the automatic import in the isc package (its
-# __init__.py imports some other modules)
-# #2145 should eliminate the need for them.
-PYTHONPATH=@abs_top_builddir@/src/lib/python:@abs_top_srcdir@/src/lib/python:@abs_top_builddir@/src/lib/python/isc/log_messages:@abs_top_builddir@/src/lib/dns/python/.libs
+PYTHONPATH=@abs_top_builddir@/src/lib/python:@abs_top_srcdir@/src/lib/python
 export PYTHONPATH
 
-# Likewise, we need only because isc.log requires some loadable modules.
-# sysinfo itself shouldn't need any of them.
-SET_ENV_LIBRARY_PATH=@SET_ENV_LIBRARY_PATH@
-if test $SET_ENV_LIBRARY_PATH = yes; then
-	@ENV_LIBRARY_PATH@=@abs_top_builddir@/src/lib/dns/.libs:@abs_top_builddir@/src/lib/dns/python/.libs:@abs_top_builddir@/src/lib/cryptolink/.libs:@abs_top_builddir@/src/lib/cc/.libs:@abs_top_builddir@/src/lib/config/.libs:@abs_top_builddir@/src/lib/log/.libs:@abs_top_builddir@/src/lib/acl/.libs:@abs_top_builddir@/src/lib/util/.libs:@abs_top_builddir@/src/lib/util/io/.libs:@abs_top_builddir@/src/lib/exceptions/.libs:@abs_top_builddir@/src/lib/datasrc/.libs:$@ENV_LIBRARY_PATH@
-	export @ENV_LIBRARY_PATH@
-fi
-
 cd ${SYSINFO_PATH}
 exec ${PYTHON_EXEC} -O sysinfo.py "$@"

File diff suppressed because it is too large
+ 147 - 149
src/bin/xfrin/tests/xfrin_test.py


+ 31 - 31
src/bin/xfrin/xfrin.py.in

@@ -78,7 +78,7 @@ DBG_XFRIN_TRACE = logger.DBGLVL_TRACE_BASIC
 # (TODO: have similar support to get default values for command
 # arguments as we do for config options)
 DEFAULT_MASTER_PORT = 53
-DEFAULT_ZONE_CLASS = RRClass.IN()
+DEFAULT_ZONE_CLASS = RRClass.IN
 
 __version__ = 'BIND10'
 
@@ -135,7 +135,7 @@ def _check_zone_class(zone_class_str):
     """If the given argument is a string: checks if the given class is
        a valid one, and returns an RRClass object if so.
        Raises XfrinZoneInfoException if not.
-       If it is None, this function returns the default RRClass.IN()"""
+       If it is None, this function returns the default RRClass.IN"""
     if zone_class_str is None:
         return DEFAULT_ZONE_CLASS
     try:
@@ -316,12 +316,12 @@ class XfrinState:
 
 class XfrinInitialSOA(XfrinState):
     def handle_rr(self, conn, rr):
-        if rr.get_type() != RRType.SOA():
+        if rr.get_type() != RRType.SOA:
             raise XfrinProtocolError('First RR in zone transfer must be SOA ('
                                      + rr.get_type().to_text() + ' received)')
         conn._end_serial = get_soa_serial(rr.get_rdata()[0])
 
-        if conn._request_type == RRType.IXFR() and \
+        if conn._request_type == RRType.IXFR and \
                 conn._end_serial <= conn._request_serial:
             logger.info(XFRIN_IXFR_UPTODATE, conn.zone_str(),
                         conn._request_serial, conn._end_serial)
@@ -364,8 +364,8 @@ class XfrinFirstData(XfrinState):
         http://www.ietf.org/mail-archive/web/dnsext/current/msg07908.html
 
         '''
-        if conn._request_type == RRType.IXFR() and \
-                rr.get_type() == RRType.SOA() and \
+        if conn._request_type == RRType.IXFR and \
+                rr.get_type() == RRType.SOA and \
                 conn._request_serial == get_soa_serial(rr.get_rdata()[0]):
             logger.debug(DBG_XFRIN_TRACE, XFRIN_GOT_INCREMENTAL_RESP,
                          conn.zone_str())
@@ -382,7 +382,7 @@ class XfrinFirstData(XfrinState):
 
 class XfrinIXFRDeleteSOA(XfrinState):
     def handle_rr(self, conn, rr):
-        if rr.get_type() != RRType.SOA():
+        if rr.get_type() != RRType.SOA:
             # this shouldn't happen; should this occur it means an internal
             # bug.
             raise XfrinException(rr.get_type().to_text() +
@@ -402,7 +402,7 @@ class XfrinIXFRDeleteSOA(XfrinState):
 
 class XfrinIXFRDelete(XfrinState):
     def handle_rr(self, conn, rr):
-        if rr.get_type() == RRType.SOA():
+        if rr.get_type() == RRType.SOA:
             # This is the only place where current_serial is set
             conn._current_serial = get_soa_serial(rr.get_rdata()[0])
             self.set_xfrstate(conn, XfrinIXFRAddSOA())
@@ -413,7 +413,7 @@ class XfrinIXFRDelete(XfrinState):
 
 class XfrinIXFRAddSOA(XfrinState):
     def handle_rr(self, conn, rr):
-        if rr.get_type() != RRType.SOA():
+        if rr.get_type() != RRType.SOA:
             # this shouldn't happen; should this occur it means an internal
             # bug.
             raise XfrinException(rr.get_type().to_text() +
@@ -425,7 +425,7 @@ class XfrinIXFRAddSOA(XfrinState):
 
 class XfrinIXFRAdd(XfrinState):
     def handle_rr(self, conn, rr):
-        if rr.get_type() == RRType.SOA():
+        if rr.get_type() == RRType.SOA:
             # This SOA marks the end of a difference sequence
             conn.get_transfer_stats().ixfr_changeset_count += 1
             soa_serial = get_soa_serial(rr.get_rdata()[0])
@@ -480,7 +480,7 @@ class XfrinAXFR(XfrinState):
         Handle the RR by putting it into the zone.
         """
         conn._diff.add_data(rr)
-        if rr.get_type() == RRType.SOA():
+        if rr.get_type() == RRType.SOA:
             # SOA means end.  Don't commit it yet - we need to perform
             # post-transfer checks
 
@@ -662,7 +662,7 @@ class XfrinConnection(asyncore.dispatcher):
             result, finder = self._datasrc_client.find_zone(self._zone_name)
         if result != DataSourceClient.SUCCESS:
             return None
-        result, soa_rrset, _ = finder.find(self._zone_name, RRType.SOA())
+        result, soa_rrset, _ = finder.find(self._zone_name, RRType.SOA)
         if result != ZoneFinder.SUCCESS:
             logger.info(XFRIN_ZONE_NO_SOA, self.zone_str())
             return None
@@ -714,8 +714,8 @@ class XfrinConnection(asyncore.dispatcher):
         query_id = random.randint(0, 0xFFFF)
         self._query_id = query_id
         msg.set_qid(query_id)
-        msg.set_opcode(Opcode.QUERY())
-        msg.set_rcode(Rcode.NOERROR())
+        msg.set_opcode(Opcode.QUERY)
+        msg.set_rcode(Rcode.NOERROR)
         msg.add_question(Question(self._zone_name, self._rrclass, query_type))
 
         # Remember our serial, if known
@@ -723,7 +723,7 @@ class XfrinConnection(asyncore.dispatcher):
             if self._zone_soa is not None else None
 
         # Set the authority section with our SOA for IXFR
-        if query_type == RRType.IXFR():
+        if query_type == RRType.IXFR:
             if self._zone_soa is None:
                 # (incremental) IXFR doesn't work without known SOA
                 raise XfrinException('Failed to create IXFR query due to no ' +
@@ -855,7 +855,7 @@ class XfrinConnection(asyncore.dispatcher):
         resp_question = msg.get_question()[0]
         if resp_question.get_name() != self._zone_name or \
                 resp_question.get_class() != self._rrclass or \
-                resp_question.get_type() != RRType.SOA():
+                resp_question.get_type() != RRType.SOA:
             raise XfrinProtocolError('Invalid response to SOA query: '
                                      'question mismatch: ' +
                                      str(resp_question))
@@ -863,21 +863,21 @@ class XfrinConnection(asyncore.dispatcher):
         # Look into the answer section for SOA
         soa = None
         for rr in msg.get_section(Message.SECTION_ANSWER):
-            if rr.get_type() == RRType.SOA():
+            if rr.get_type() == RRType.SOA:
                 if soa is not None:
                     raise XfrinProtocolError('SOA response had multiple SOAs')
                 soa = rr
             # There should not be a CNAME record at top of zone.
-            if rr.get_type() == RRType.CNAME():
+            if rr.get_type() == RRType.CNAME:
                 raise XfrinProtocolError('SOA query resulted in CNAME')
 
         # If SOA is not found, try to figure out the reason then report it.
         if soa is None:
             # See if we have any SOA records in the authority section.
             for rr in msg.get_section(Message.SECTION_AUTHORITY):
-                if rr.get_type() == RRType.NS():
+                if rr.get_type() == RRType.NS:
                     raise XfrinProtocolError('SOA query resulted in referral')
-                if rr.get_type() == RRType.SOA():
+                if rr.get_type() == RRType.SOA:
                     raise XfrinProtocolError('SOA query resulted in NODATA')
             raise XfrinProtocolError('No SOA record found in response to ' +
                                      'SOA query')
@@ -901,7 +901,7 @@ class XfrinConnection(asyncore.dispatcher):
 
         '''
 
-        self._send_query(RRType.SOA())
+        self._send_query(RRType.SOA)
         data_len = self._get_request_response(2)
         msg_len = socket.htons(struct.unpack('H', data_len)[0])
         soa_response = self._get_request_response(msg_len)
@@ -925,7 +925,7 @@ class XfrinConnection(asyncore.dispatcher):
 
         return XFRIN_OK
 
-    def do_xfrin(self, check_soa, request_type=RRType.AXFR()):
+    def do_xfrin(self, check_soa, request_type=RRType.AXFR):
         '''Do an xfr session by sending xfr request and parsing responses.'''
 
         try:
@@ -933,7 +933,7 @@ class XfrinConnection(asyncore.dispatcher):
             self._request_type = request_type
             # Right now RRType.[IA]XFR().to_text() is 'TYPExxx', so we need
             # to hardcode here.
-            req_str = 'IXFR' if request_type == RRType.IXFR() else 'AXFR'
+            req_str = 'IXFR' if request_type == RRType.IXFR else 'AXFR'
             if check_soa:
                 self._check_soa_serial()
                 self.close()
@@ -1024,7 +1024,7 @@ class XfrinConnection(asyncore.dispatcher):
         # cause interoperability trouble with stricter checks.
 
         msg_rcode = msg.get_rcode()
-        if msg_rcode != Rcode.NOERROR():
+        if msg_rcode != Rcode.NOERROR:
             raise XfrinProtocolError('error response: %s' %
                                      msg_rcode.to_text())
 
@@ -1120,13 +1120,13 @@ def __process_xfrin(server, zone_name, rrclass, db_file,
             ret = XFRIN_FAIL
             if conn.connect_to_master():
                 ret = conn.do_xfrin(check_soa, request_type)
-                if ret == XFRIN_FAIL and request_type == RRType.IXFR():
+                if ret == XFRIN_FAIL and request_type == RRType.IXFR:
                     # IXFR failed for some reason. It might mean the server can't
                     # handle it, or we don't have the zone or we are out of sync or
                     # whatever else. So we retry with with AXFR, as it may succeed
                     # in many such cases.
                     retry = True
-                    request_type = RRType.AXFR()
+                    request_type = RRType.AXFR
                     logger.warn(XFRIN_XFR_TRANSFER_FALLBACK, conn.zone_str())
                     conn.close()
                     conn = None
@@ -1172,7 +1172,7 @@ def process_xfrin(server, xfrin_recorder, zone_name, rrclass, db_file,
     xfrin_recorder.decrement(zone_name)
 
     if exception is not None:
-        typestr = "AXFR" if request_type == RRType.AXFR() else "IXFR"
+        typestr = "AXFR" if request_type == RRType.AXFR else "IXFR"
         logger.error(XFRIN_XFR_PROCESS_FAILURE, typestr, zone_name.to_text(),
                      str(rrclass), str(exception))
 
@@ -1507,9 +1507,9 @@ class Xfrin:
                     logger.info(XFRIN_RETRANSFER_UNKNOWN_ZONE, zone_str)
                     answer = create_answer(1, errmsg)
                 else:
-                    request_type = RRType.AXFR()
+                    request_type = RRType.AXFR
                     if zone_info.use_ixfr:
-                        request_type = RRType.IXFR()
+                        request_type = RRType.IXFR
                     master_addr = zone_info.get_master_addr_info()
                     if notify_addr[0] == master_addr[0] and\
                        notify_addr[2] == master_addr[2]:
@@ -1538,11 +1538,11 @@ class Xfrin:
                                                           rrclass)
                 zone_info = self._get_zone_info(zone_name, rrclass)
                 tsig_key = None
-                request_type = RRType.AXFR()
+                request_type = RRType.AXFR
                 if zone_info:
                     tsig_key = zone_info.get_tsig_key()
                     if zone_info.use_ixfr:
-                        request_type = RRType.IXFR()
+                        request_type = RRType.IXFR
                 db_file = args.get('db_file') or self._get_db_file()
                 ret = self.xfrin_start(zone_name,
                                        rrclass,

+ 61 - 61
src/bin/xfrout/tests/xfrout_test.py.in

@@ -38,7 +38,7 @@ TSIG_KEY = TSIGKey("example.com:SFuWd/q99SzF8Yzd1QbB9g==")
 #
 TEST_ZONE_NAME_STR = "example.com."
 TEST_ZONE_NAME = Name(TEST_ZONE_NAME_STR)
-TEST_RRCLASS = RRClass.IN()
+TEST_RRCLASS = RRClass.IN
 IXFR_OK_VERSION = 2011111802
 IXFR_NG_VERSION = 2011111803
 SOA_CURRENT_VERSION = 2011112001
@@ -109,16 +109,16 @@ class MockDataSrcClient:
         zone names.
 
         '''
-        if name == Name('nosoa.example.com') and rrtype == RRType.SOA():
+        if name == Name('nosoa.example.com') and rrtype == RRType.SOA:
             return (ZoneFinder.NXDOMAIN, None, 0)
-        elif name == Name('multisoa.example.com') and rrtype == RRType.SOA():
+        elif name == Name('multisoa.example.com') and rrtype == RRType.SOA:
             soa_rrset = create_soa(SOA_CURRENT_VERSION)
             soa_rrset.add_rdata(soa_rrset.get_rdata()[0])
             return (ZoneFinder.SUCCESS, soa_rrset, 0)
         elif name == Name('maxserial.example.com'):
             soa_rrset = create_soa(0xffffffff)
             return (ZoneFinder.SUCCESS, soa_rrset, 0)
-        elif rrtype == RRType.SOA():
+        elif rrtype == RRType.SOA:
             return (ZoneFinder.SUCCESS, create_soa(SOA_CURRENT_VERSION), 0)
         raise ValueError('Unexpected input to mock finder: bug in test case?')
 
@@ -238,17 +238,17 @@ class TestXfroutSessionBase(unittest.TestCase):
         msg = Message(Message.RENDER)
         query_id = 0x1035
         msg.set_qid(query_id)
-        msg.set_opcode(Opcode.QUERY())
-        msg.set_rcode(Rcode.NOERROR())
-        req_type = RRType.AXFR() if ixfr is None else RRType.IXFR()
+        msg.set_opcode(Opcode.QUERY)
+        msg.set_rcode(Rcode.NOERROR)
+        req_type = RRType.AXFR if ixfr is None else RRType.IXFR
         if with_question:
-            msg.add_question(Question(zone_name, RRClass.IN(),
+            msg.add_question(Question(zone_name, RRClass.IN,
                                       req_type if qtype is None else qtype))
-        if req_type == RRType.IXFR():
-            soa = RRset(zone_name, soa_class, RRType.SOA(), RRTTL(0))
+        if req_type == RRType.IXFR:
+            soa = RRset(zone_name, soa_class, RRType.SOA, RRTTL(0))
             # In the RDATA only the serial matters.
             for i in range(0, num_soa):
-                soa.add_rdata(Rdata(RRType.SOA(), soa_class,
+                soa.add_rdata(Rdata(RRType.SOA, soa_class,
                                     'm. r. ' + str(ixfr) + ' 1 1 1 1'))
             msg.add_rrset(Message.SECTION_AUTHORITY, soa)
 
@@ -263,7 +263,7 @@ class TestXfroutSessionBase(unittest.TestCase):
 
     def set_request_type(self, type):
         self.xfrsess._request_type = type
-        if type == RRType.AXFR():
+        if type == RRType.AXFR:
             self.xfrsess._request_typestr = 'AXFR'
         else:
             self.xfrsess._request_typestr = 'IXFR'
@@ -280,7 +280,7 @@ class TestXfroutSessionBase(unittest.TestCase):
                                            [{"action": "ACCEPT"}]),
                                        {},
                                        **self._counters)
-        self.set_request_type(RRType.AXFR()) # test AXFR by default
+        self.set_request_type(RRType.AXFR) # test AXFR by default
         self.mdata = self.create_request_data()
         self.soa_rrset = create_soa(SOA_CURRENT_VERSION)
         # some test replaces a module-wide function.  We should ensure the
@@ -342,7 +342,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.xfrsess._request_data = self.mdata
         self.xfrsess._server.increase_transfers_counter = lambda : False
         XfroutSession._handle(self.xfrsess)
-        self.assertEqual(self.sock.read_msg().get_rcode(), Rcode.REFUSED())
+        self.assertEqual(self.sock.read_msg().get_rcode(), Rcode.REFUSED)
 
     def test_quota_ok(self):
         '''The default case in terms of the xfrout quota.
@@ -355,7 +355,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         # Replace the data source client to avoid datasrc related exceptions
         self.xfrsess.ClientClass = MockDataSrcClient
         XfroutSession._handle(self.xfrsess)
-        self.assertEqual(self.sock.read_msg().get_rcode(), Rcode.FORMERR())
+        self.assertEqual(self.sock.read_msg().get_rcode(), Rcode.FORMERR)
 
     def test_exception_from_session(self):
         '''Test the case where the main processing raises an exception.
@@ -372,14 +372,14 @@ class TestXfroutSession(TestXfroutSessionBase):
     def test_parse_query_message(self):
         # Valid AXFR
         [get_rcode, get_msg] = self.xfrsess._parse_query_message(self.mdata)
-        self.assertEqual(RRType.AXFR(), self.xfrsess._request_type)
+        self.assertEqual(RRType.AXFR, self.xfrsess._request_type)
         self.assertEqual(get_rcode.to_text(), "NOERROR")
 
         # Valid IXFR
         request_data = self.create_request_data(ixfr=2011111801)
         rcode, msg = self.xfrsess._parse_query_message(request_data)
-        self.assertEqual(RRType.IXFR(), self.xfrsess._request_type)
-        self.assertEqual(Rcode.NOERROR(), rcode)
+        self.assertEqual(RRType.IXFR, self.xfrsess._request_type)
+        self.assertEqual(Rcode.NOERROR, rcode)
 
         # Broken request: no question
         self.assertRaises(RuntimeError, self.xfrsess._parse_query_message,
@@ -387,7 +387,7 @@ class TestXfroutSession(TestXfroutSessionBase):
 
         # Broken request: invalid RR type (neither AXFR nor IXFR)
         self.assertRaises(RuntimeError, self.xfrsess._parse_query_message,
-                          self.create_request_data(qtype=RRType.A()))
+                          self.create_request_data(qtype=RRType.A))
 
         # NOERROR
         request_data = self.create_request_data(ixfr=IXFR_OK_VERSION)
@@ -554,7 +554,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         # should be used.
         self.xfrsess._acl = isc.acl.dns.REQUEST_LOADER.load([
                 {"from": "127.0.0.1", "action": "ACCEPT"}])
-        acl = self.xfrsess._get_transfer_acl(Name('example.com'), RRClass.IN())
+        acl = self.xfrsess._get_transfer_acl(Name('example.com'), RRClass.IN)
         self.assertEqual(acl, self.xfrsess._acl)
 
         # install a per zone config with transfer ACL for example.com.  Then
@@ -567,15 +567,15 @@ class TestXfroutSession(TestXfroutSessionBase):
             com_acl
         self.assertEqual(com_acl,
                          self.xfrsess._get_transfer_acl(Name('example.com'),
-                                                        RRClass.IN()))
+                                                        RRClass.IN))
         self.assertEqual(self.xfrsess._acl,
                          self.xfrsess._get_transfer_acl(Name('example.org'),
-                                                        RRClass.IN()))
+                                                        RRClass.IN))
 
         # Name matching should be case insensitive.
         self.assertEqual(com_acl,
                          self.xfrsess._get_transfer_acl(Name('EXAMPLE.COM'),
-                                                        RRClass.IN()))
+                                                        RRClass.IN))
 
     def test_send_data(self):
         self.xfrsess._send_data(self.sock, self.mdata)
@@ -600,9 +600,9 @@ class TestXfroutSession(TestXfroutSessionBase):
         msg = self.getmsg()
         msg.make_response()
         # SOA record data with different cases
-        soa_rrset = RRset(Name('Example.com.'), RRClass.IN(), RRType.SOA(),
+        soa_rrset = RRset(Name('Example.com.'), RRClass.IN, RRType.SOA,
                                RRTTL(3600))
-        soa_rrset.add_rdata(Rdata(RRType.SOA(), RRClass.IN(),
+        soa_rrset.add_rdata(Rdata(RRType.SOA, RRClass.IN,
                                   'master.Example.com. admin.exAmple.com. ' +
                                   '2011112001 3600 1800 2419200 7200'))
         msg.add_rrset(Message.SECTION_ANSWER, soa_rrset)
@@ -680,8 +680,8 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(get_msg.get_rr_count(Message.SECTION_AUTHORITY), 0)
 
     def test_trigger_send_message_with_last_soa(self):
-        rrset_a = RRset(Name("example.com"), RRClass.IN(), RRType.A(), RRTTL(3600))
-        rrset_a.add_rdata(Rdata(RRType.A(), RRClass.IN(), "192.0.2.1"))
+        rrset_a = RRset(Name("example.com"), RRClass.IN, RRType.A, RRTTL(3600))
+        rrset_a.add_rdata(Rdata(RRType.A, RRClass.IN, "192.0.2.1"))
 
         msg = self.getmsg()
         msg.make_response()
@@ -759,36 +759,36 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.xfrsess.ClientClass = MockDataSrcClient
         # Successful case.  A zone iterator should be set up.
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
+                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR)
         self.assertNotEqual(None, self.xfrsess._iterator)
 
         # Failure cases
         self.assertEqual(self.xfrsess._xfrout_setup(
                 self.getmsg(), Name('notauth.example.com'), TEST_RRCLASS),
-                         Rcode.NOTAUTH())
+                         Rcode.NOTAUTH)
         self.assertEqual(self.xfrsess._xfrout_setup(
                 self.getmsg(), Name('nosoa.example.com'), TEST_RRCLASS),
-                         Rcode.SERVFAIL())
+                         Rcode.SERVFAIL)
         self.assertEqual(self.xfrsess._xfrout_setup(
                 self.getmsg(), Name('multisoa.example.com'), TEST_RRCLASS),
-                         Rcode.SERVFAIL())
+                         Rcode.SERVFAIL)
 
     def test_xfrout_ixfr_setup(self):
         self.xfrsess.ClientClass = MockDataSrcClient
-        self.set_request_type(RRType.IXFR())
+        self.set_request_type(RRType.IXFR)
 
         # Successful case of pure IXFR.  A zone journal reader should be set
         # up.
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
+                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR)
         self.assertNotEqual(None, self.xfrsess._jnl_reader)
 
         # Successful case, but as a result of falling back to AXFR-style
         # IXFR.  A zone iterator should be set up instead of a journal reader.
         self.mdata = self.create_request_data(ixfr=IXFR_NG_VERSION)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
+                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR)
         self.assertNotEqual(None, self.xfrsess._iterator)
         self.assertEqual(None, self.xfrsess._jnl_reader)
 
@@ -797,7 +797,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         # indicating that the response will contain just one SOA.
         self.mdata = self.create_request_data(ixfr=SOA_CURRENT_VERSION+1)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
+                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR)
         self.assertEqual(None, self.xfrsess._iterator)
         self.assertEqual(None, self.xfrsess._jnl_reader)
 
@@ -805,7 +805,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         # the local SOA.
         self.mdata = self.create_request_data(ixfr=SOA_CURRENT_VERSION)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR())
+                self.getmsg(), TEST_ZONE_NAME, TEST_RRCLASS), Rcode.NOERROR)
         self.assertEqual(None, self.xfrsess._iterator)
         self.assertEqual(None, self.xfrsess._jnl_reader)
 
@@ -814,7 +814,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         zone_name = Name('maxserial.example.com') # whose SOA is 0xffffffff
         self.mdata = self.create_request_data(ixfr=1, zone_name=zone_name)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                 self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOERROR())
+                 self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOERROR)
         self.assertEqual(None, self.xfrsess._iterator)
         self.assertEqual(None, self.xfrsess._jnl_reader)
 
@@ -823,7 +823,7 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
                                               zone_name=zone_name)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOERROR())
+                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOERROR)
         self.assertNotEqual(None, self.xfrsess._iterator)
 
         # Failure cases
@@ -831,42 +831,42 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
                                               zone_name=zone_name)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOTAUTH())
+                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOTAUTH)
         # this is a strange case: zone's SOA will be found but the journal
         # reader won't be created due to 'no such zone'.
         zone_name = Name('notauth2.example.com')
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
                                               zone_name=zone_name)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOTAUTH())
+                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.NOTAUTH)
         zone_name = Name('nosoa.example.com')
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
                                               zone_name=zone_name)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.SERVFAIL())
+                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.SERVFAIL)
         zone_name = Name('multisoa.example.com')
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
                                               zone_name=zone_name)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.SERVFAIL())
+                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.SERVFAIL)
 
         # query name doesn't match the SOA's owner
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.FORMERR())
+                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.FORMERR)
 
         # query's RR class doesn't match the SOA's class
         zone_name = TEST_ZONE_NAME # make sure the name matches this time
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
-                                              soa_class=RRClass.CH())
+                                              soa_class=RRClass.CH)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.FORMERR())
+                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.FORMERR)
 
         # multiple SOA RRs
         self.mdata = self.create_request_data(ixfr=IXFR_OK_VERSION,
                                               num_soa=2)
         self.assertEqual(self.xfrsess._xfrout_setup(
-                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.FORMERR())
+                self.getmsg(), zone_name, TEST_RRCLASS), Rcode.FORMERR)
 
     def test_dns_xfrout_start_formerror(self):
         # formerror
@@ -876,7 +876,7 @@ class TestXfroutSession(TestXfroutSessionBase):
 
     def test_dns_xfrout_start_notauth(self):
         def notauth(msg, name, rrclass):
-            return Rcode.NOTAUTH()
+            return Rcode.NOTAUTH
         self.xfrsess._xfrout_setup = notauth
         self.xfrsess.dns_xfrout_start(self.sock, self.mdata)
         get_msg = self.sock.read_msg()
@@ -887,11 +887,11 @@ class TestXfroutSession(TestXfroutSessionBase):
             raise isc.datasrc.Error('exception for the sake of test')
         self.xfrsess.ClientClass = internal_raise
         self.xfrsess.dns_xfrout_start(self.sock, self.mdata)
-        self.assertEqual(self.sock.read_msg().get_rcode(), Rcode.SERVFAIL())
+        self.assertEqual(self.sock.read_msg().get_rcode(), Rcode.SERVFAIL)
 
     def test_dns_xfrout_start_noerror(self):
         def noerror(msg, name, rrclass):
-            return Rcode.NOERROR()
+            return Rcode.NOERROR
         self.xfrsess._xfrout_setup = noerror
 
         def myreply(msg, sock):
@@ -905,7 +905,7 @@ class TestXfroutSession(TestXfroutSessionBase):
 
     def test_dns_xfrout_start_with_notcallable_xfrreqdone(self):
         def noerror(msg, name, rrclass):
-            return Rcode.NOERROR()
+            return Rcode.NOERROR
         self.xfrsess._xfrout_setup = noerror
 
         def myreply(msg, sock):
@@ -925,9 +925,9 @@ class TestXfroutSession(TestXfroutSessionBase):
         self.assertEqual(reply_msg.get_rr_count(Message.SECTION_ANSWER), 2)
 
     def test_reply_xfrout_query_axfr_with_tsig(self):
-        rrset = RRset(Name('a.example.com'), RRClass.IN(), RRType.A(),
+        rrset = RRset(Name('a.example.com'), RRClass.IN, RRType.A,
                       RRTTL(3600))
-        rrset.add_rdata(Rdata(RRType.A(), RRClass.IN(), '192.0.2.1'))
+        rrset.add_rdata(Rdata(RRType.A, RRClass.IN, '192.0.2.1'))
         global xfrout
 
         def get_rrset_len(rrset):
@@ -1015,8 +1015,8 @@ class TestXfroutSession(TestXfroutSessionBase):
         algorithm = hmac-md5)
 
         '''
-        soa = RRset(Name('.'), RRClass.IN(), RRType.SOA(), RRTTL(3600))
-        soa.add_rdata(Rdata(RRType.SOA(), RRClass.IN(), '. . 0 0 0 0 0'))
+        soa = RRset(Name('.'), RRClass.IN, RRType.SOA, RRTTL(3600))
+        soa.add_rdata(Rdata(RRType.SOA, RRClass.IN, '. . 0 0 0 0 0'))
         self.mdata = self.create_request_data(zone_name=Name('.'))
         self.xfrsess._soa = soa
         if tsig:
@@ -1177,10 +1177,10 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
         self.assertEqual(self.get_counter('ixfr_ended'), 0)
         XfroutSession._handle(self.xfrsess)
         response = self.sock.read_msg(Message.PRESERVE_ORDER);
-        self.assertEqual(Rcode.NOERROR(), response.get_rcode())
+        self.assertEqual(Rcode.NOERROR, response.get_rcode())
         self.check_axfr_stream(response)
-        self.assertEqual(self.xfrsess._request_type, RRType.AXFR())
-        self.assertNotEqual(self.xfrsess._request_type, RRType.IXFR())
+        self.assertEqual(self.xfrsess._request_type, RRType.AXFR)
+        self.assertNotEqual(self.xfrsess._request_type, RRType.IXFR)
         self.assertEqual(self.get_counter('axfr_started'), 1)
         self.assertEqual(self.get_counter('axfr_ended'), 1)
         self.assertEqual(self.get_counter('ixfr_started'), 0)
@@ -1191,10 +1191,10 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
             self.create_request_data(ixfr=IXFR_NG_VERSION)
         XfroutSession._handle(self.xfrsess)
         response = self.sock.read_msg(Message.PRESERVE_ORDER);
-        self.assertEqual(Rcode.NOERROR(), response.get_rcode())
+        self.assertEqual(Rcode.NOERROR, response.get_rcode())
         # This is an AXFR-style IXFR.  So the question section should indicate
         # that it's an IXFR resposne.
-        self.assertEqual(RRType.IXFR(), response.get_question()[0].get_type())
+        self.assertEqual(RRType.IXFR, response.get_question()[0].get_type())
         self.check_axfr_stream(response)
 
     def test_ixfr_normal_session(self):
@@ -1222,8 +1222,8 @@ class TestXfroutSessionWithSQLite3(TestXfroutSessionBase):
         self.assertEqual(len(expected_records), len(actual_records))
         for (expected_rr, actual_rr) in zip(expected_records, actual_records):
             self.assertTrue(rrsets_equal(expected_rr, actual_rr))
-        self.assertNotEqual(self.xfrsess._request_type, RRType.AXFR())
-        self.assertEqual(self.xfrsess._request_type, RRType.IXFR())
+        self.assertNotEqual(self.xfrsess._request_type, RRType.AXFR)
+        self.assertEqual(self.xfrsess._request_type, RRType.IXFR)
         self.assertEqual(self.get_counter('axfr_started'), 0)
         self.assertEqual(self.get_counter('axfr_ended'), 0)
         self.assertEqual(self.get_counter('ixfr_started'), 1)

+ 33 - 33
src/bin/xfrout/xfrout.py.in

@@ -227,9 +227,9 @@ class XfroutSession():
                                                   self._tsig_key_ring)
             tsig_error = self._tsig_ctx.verify(tsig_record, request_data)
             if tsig_error != TSIGError.NOERROR:
-                return Rcode.NOTAUTH()
+                return Rcode.NOTAUTH
 
-        return Rcode.NOERROR()
+        return Rcode.NOERROR
 
     def _parse_query_message(self, mdata):
         ''' parse query message to [socket,message]'''
@@ -239,11 +239,11 @@ class XfroutSession():
             Message.from_wire(msg, mdata)
         except Exception as err: # Exception is too broad
             logger.error(XFROUT_PARSE_QUERY_ERROR, err)
-            return Rcode.FORMERR(), None
+            return Rcode.FORMERR, None
 
         # TSIG related checks
         rcode = self._check_request_tsig(msg, mdata)
-        if rcode != Rcode.NOERROR():
+        if rcode != Rcode.NOERROR:
             return rcode, msg
 
         # Make sure the question is valid.  This should be ensured by
@@ -257,9 +257,9 @@ class XfroutSession():
 
         # Identify the request type
         self._request_type = question.get_type()
-        if self._request_type == RRType.AXFR():
+        if self._request_type == RRType.AXFR:
             self._request_typestr = 'AXFR'
-        elif self._request_type == RRType.IXFR():
+        elif self._request_type == RRType.IXFR:
             self._request_typestr = 'IXFR'
         else:
             # Likewise, this should be impossible.
@@ -283,7 +283,7 @@ class XfroutSession():
             logger.debug(DBG_XFROUT_TRACE, XFROUT_QUERY_REJECTED,
                          self._request_type, format_addrinfo(self._remote),
                          format_zone_str(zone_name, zone_class))
-            return Rcode.REFUSED(), msg
+            return Rcode.REFUSED, msg
 
         return rcode, msg
 
@@ -351,16 +351,16 @@ class XfroutSession():
         '''
         result, finder = self._datasrc_client.find_zone(zone_name)
         if result != DataSourceClient.SUCCESS:
-            return (Rcode.NOTAUTH(), None)
-        result, soa_rrset, _ = finder.find(zone_name, RRType.SOA())
+            return (Rcode.NOTAUTH, None)
+        result, soa_rrset, _ = finder.find(zone_name, RRType.SOA)
         if result != ZoneFinder.SUCCESS:
-            return (Rcode.SERVFAIL(), None)
+            return (Rcode.SERVFAIL, None)
         # Especially for database-based zones, a working zone may be in
         # a broken state where it has more than one SOA RR.  We proactively
         # check the condition and abort the xfr attempt if we identify it.
         if soa_rrset.get_rdata_count() != 1:
-            return (Rcode.SERVFAIL(), None)
-        return (Rcode.NOERROR(), soa_rrset)
+            return (Rcode.SERVFAIL, None)
+        return (Rcode.NOERROR, soa_rrset)
 
     def __axfr_setup(self, zone_name):
         '''Setup a zone iterator for AXFR or AXFR-style IXFR.
@@ -379,16 +379,16 @@ class XfroutSession():
             # update get_iterator() API so that we can distinguish "no such
             # zone" and other cases (#1373).  For now we consider all these
             # cases as NOTAUTH.
-            return Rcode.NOTAUTH()
+            return Rcode.NOTAUTH
 
         # If we are an authoritative name server for the zone, but fail
         # to find the zone's SOA record in datasource, xfrout can't
         # provide zone transfer for it.
         self._soa = self._iterator.get_soa()
         if self._soa is None or self._soa.get_rdata_count() != 1:
-            return Rcode.SERVFAIL()
+            return Rcode.SERVFAIL
 
-        return Rcode.NOERROR()
+        return Rcode.NOERROR
 
     def __ixfr_setup(self, request_msg, zone_name, zone_class):
         '''Setup a zone journal reader for IXFR.
@@ -405,21 +405,21 @@ class XfroutSession():
             # Ignore data whose owner name is not the zone apex, and
             # ignore non-SOA or different class of records.
             if auth_rrset.get_name() != zone_name or \
-                    auth_rrset.get_type() != RRType.SOA() or \
+                    auth_rrset.get_type() != RRType.SOA or \
                     auth_rrset.get_class() != zone_class:
                 continue
             if auth_rrset.get_rdata_count() != 1:
                 logger.info(XFROUT_IXFR_MULTIPLE_SOA,
                             format_addrinfo(self._remote))
-                return Rcode.FORMERR()
+                return Rcode.FORMERR
             remote_soa = auth_rrset
         if remote_soa is None:
             logger.info(XFROUT_IXFR_NO_SOA, format_addrinfo(self._remote))
-            return Rcode.FORMERR()
+            return Rcode.FORMERR
 
         # Retrieve the local SOA
         rcode, self._soa = self._get_zone_soa(zone_name)
-        if rcode != Rcode.NOERROR():
+        if rcode != Rcode.NOERROR:
             return rcode
 
         # RFC1995 says "If an IXFR query with the same or newer version
@@ -437,7 +437,7 @@ class XfroutSession():
             logger.info(XFROUT_IXFR_UPTODATE, format_addrinfo(self._remote),
                         format_zone_str(zone_name, zone_class),
                         begin_serial, end_serial)
-            return Rcode.NOERROR()
+            return Rcode.NOERROR
 
         # Set up the journal reader or fall back to AXFR-style IXFR
         try:
@@ -462,12 +462,12 @@ class XfroutSession():
             # between these two operations.  We treat it as NOTAUTH.
             logger.warn(XFROUT_IXFR_NO_ZONE, format_addrinfo(self._remote),
                         format_zone_str(zone_name, zone_class))
-            return Rcode.NOTAUTH()
+            return Rcode.NOTAUTH
 
         # Use the reader as the iterator to generate the response.
         self._iterator = self._jnl_reader
 
-        return Rcode.NOERROR()
+        return Rcode.NOERROR
 
     def _xfrout_setup(self, request_msg, zone_name, zone_class):
         '''Setup a context for xfr responses according to the request type.
@@ -490,7 +490,7 @@ class XfroutSession():
             self._server.get_db_file() + '"}'
         self._datasrc_client = self.ClientClass('sqlite3', datasrc_config)
 
-        if self._request_type == RRType.AXFR():
+        if self._request_type == RRType.AXFR:
             return self.__axfr_setup(zone_name)
         else:
             return self.__ixfr_setup(request_msg, zone_name, zone_class)
@@ -500,17 +500,17 @@ class XfroutSession():
         #TODO. create query message and parse header
         if rcode_ is None: # Dropped by ACL
             return
-        elif rcode_ == Rcode.NOTAUTH() or rcode_ == Rcode.REFUSED():
+        elif rcode_ == Rcode.NOTAUTH or rcode_ == Rcode.REFUSED:
             return self._reply_query_with_error_rcode(msg, sock_fd, rcode_)
-        elif rcode_ != Rcode.NOERROR():
+        elif rcode_ != Rcode.NOERROR:
             return self._reply_query_with_error_rcode(msg, sock_fd,
-                                                      Rcode.FORMERR())
+                                                      Rcode.FORMERR)
         elif not quota_ok:
             logger.warn(XFROUT_QUERY_QUOTA_EXCCEEDED, self._request_typestr,
                         format_addrinfo(self._remote),
                         self._server._max_transfers_out)
             return self._reply_query_with_error_rcode(msg, sock_fd,
-                                                      Rcode.REFUSED())
+                                                      Rcode.REFUSED)
 
         question = msg.get_question()[0]
         zone_name = question.get_name()
@@ -522,15 +522,15 @@ class XfroutSession():
         except Exception as ex:
             logger.error(XFROUT_XFR_TRANSFER_CHECK_ERROR, self._request_typestr,
                          format_addrinfo(self._remote), zone_str, ex)
-            rcode_ = Rcode.SERVFAIL()
-        if rcode_ != Rcode.NOERROR():
+            rcode_ = Rcode.SERVFAIL
+        if rcode_ != Rcode.NOERROR:
             logger.info(XFROUT_XFR_TRANSFER_FAILED, self._request_typestr,
                         format_addrinfo(self._remote), zone_str, rcode_)
             return self._reply_query_with_error_rcode(msg, sock_fd, rcode_)
 
         try:
             # increment Xfr starts by RRType
-            if self._request_type == RRType.AXFR():
+            if self._request_type == RRType.AXFR:
                 self._inc_axfr_running()
             else:
                 self._inc_ixfr_running()
@@ -542,7 +542,7 @@ class XfroutSession():
                     format_addrinfo(self._remote), zone_str, err)
         finally:
             # decrement Xfr starts by RRType
-            if self._request_type == RRType.AXFR():
+            if self._request_type == RRType.AXFR:
                 self._dec_axfr_running()
             else:
                 self._dec_ixfr_running()
@@ -614,7 +614,7 @@ class XfroutSession():
 
             # For AXFR (or AXFR-style IXFR), in which case _jnl_reader is None,
             # we should skip SOAs from the iterator.
-            if self._jnl_reader is None and rrset.get_type() == RRType.SOA():
+            if self._jnl_reader is None and rrset.get_type() == RRType.SOA:
                 continue
 
             # We calculate the maximum size of the RRset (i.e. the
@@ -1215,7 +1215,7 @@ class XfroutServer:
             zone_name = args.get('zone_name')
             zone_class = args.get('zone_class')
             if not zone_class:
-                zone_class = str(RRClass.IN())
+                zone_class = str(RRClass.IN)
             if zone_name:
                 logger.info(XFROUT_NOTIFY_COMMAND, zone_name, zone_class)
                 if self.send_notify(zone_name, zone_class):

+ 4 - 0
src/lib/dns/Makefile.am

@@ -8,6 +8,10 @@ AM_CXXFLAGS = $(B10_CXXFLAGS)
 
 CLEANFILES = *.gcno *.gcda
 CLEANFILES += rrclass.h rrtype.h rrparamregistry.cc rdataclass.h rdataclass.cc
+# These two are created with rrtype/class.h, so not explicitly listed in
+# BUILT_SOURCES.
+CLEANFILES += python/rrtype_constants_inc.cc
+CLEANFILES += python/rrclass_constants_inc.cc
 
 EXTRA_DIST = rrclass-placeholder.h
 EXTRA_DIST += rrparamregistry-placeholder.cc

+ 92 - 26
src/lib/dns/gen-rdatacode.py.in

@@ -46,9 +46,30 @@ new_rdata_factory_users = [('aaaa', 'in'),
                            ('txt', 'generic')
                           ]
 
-re_typecode = re.compile('([\da-z]+)_(\d+)')
+re_typecode = re.compile('([\da-z\-]+)_(\d+)')
 classcode2txt = {}
 typecode2txt = {}
+# For meta types and types well-known but not implemented.  This is a dict from
+# type code values (as string) to textual mnemonic.
+meta_types = {
+    # Real meta types.  We won't have Rdata implement for them, but we need
+    # RRType constants.
+    '251': 'ixfr', '252': 'axfr', '255': 'any',
+    # Obsolete types.  We probalby won't implement Rdata for them, but it's
+    # better to have RRType constants.
+    '3': 'md', '4': 'mf', '7': 'mb', '8': 'mg', '9': 'mr', '30': 'nxt',
+    '38': 'a6', '254': 'maila',
+    # Types officially assigned but not yet supported in our implementation.
+    '10': 'null', '11': 'wks', '19': 'x25', '21': 'rt', '22': 'nsap',
+    '23': 'nsap-ptr', '24': 'sig', '20': 'isdn', '25': 'key', '26': 'px',
+    '27': 'gpos', '29': 'loc', '36': 'kx', '37': 'cert', '42': 'apl',
+    '45': 'ipseckey', '52': 'tlsa', '55': 'hip', '103': 'unspec',
+    '104': 'nid', '105': 'l32', '106': 'l64', '107': 'lp', '249':  'tkey',
+    '253': 'mailb', '256': 'uri', '257': 'caa'
+    }
+# Classes that don't have any known types.  This is a dict from type code
+# values (as string) to textual mnemonic.
+meta_classes = {'254': 'none'}
 typeandclass = []
 generic_code = 65536            # something larger than any code value
 rdata_declarations = ''
@@ -191,11 +212,11 @@ def import_definitions(classcode2txt, typecode2txt, typeandclass):
                     type_code = m.group(2)
                     if not type_code in typecode2txt:
                         typecode2txt[type_code] = type_txt
-                    if re.search('\cc$', file):
+                    if re.search('\.cc$', file):
                         if rdatadef_mtime < getmtime(file):
                             rdatadef_mtime = getmtime(file)
                         class_definitions += import_classdef(class_txt, file)
-                    elif re.search('\h$', file):
+                    elif re.search('\.h$', file):
                         if rdatahdr_mtime < getmtime(file):
                             rdatahdr_mtime = getmtime(file)
                         rdata_declarations += import_classheader(class_txt,
@@ -261,36 +282,66 @@ class MasterLoaderCallbacks;
 def generate_typeclasscode(fileprefix, basemtime, code2txt, type_or_class):
     placeholder = '@srcdir@/' + fileprefix + '-placeholder.h'
     outputfile = '@builddir@/' + fileprefix + '.h'
+    py_outputfile = '@builddir@/python/' + fileprefix + '_constants_inc.cc'
     upper_key = type_or_class.upper() # TYPE or CLASS
     lower_key = 'rr' + type_or_class.lower() # rrtype or rrclass
     cap_key = type_or_class           # Type or Class
 
-    if not need_generate(outputfile, basemtime) and getmtime(outputfile) > getmtime(placeholder):
+    # We only decide whether to generate files for libdns++ files; Python
+    # files are generated if and only if libdns++ files are generated.
+    # In practice it should be sufficient.
+    if (not need_generate(outputfile, basemtime) and
+        getmtime(outputfile) > getmtime(placeholder)):
         print('skip generating ' + outputfile)
         return
 
-    declarationtxt = ''
-    deftxt = ''
-    for code in code2txt.keys():
-        codetxt = code2txt[code].upper()
-        declarationtxt += ' ' * 4 + 'static const RR' + cap_key + '& ' + codetxt + '();\n'
-        deftxt += '''inline const RR''' + cap_key + '''&
-RR''' + cap_key + '''::''' + codetxt + '''() {
-    static RR''' + cap_key + ''' ''' + lower_key + '''(''' + code + ''');
+    # Create a list of (code, code-text) pairs, where code-text is generally
+    # upper-cased, with applying speicial filters when necessary.
+    def convert(code_txt):
+        # Workaround by heuristics: there's a "NULL" RR type, but it would
+        # cause conflict with the C/C++ macro.  We use Null as a special case.
+        if code_txt == 'null':
+            return 'Null'
+        # Likewise, convert "nsap-ptr" to "NSAP_PTR" as a dash cannot be part
+        # of a C/C++ variable.
+        if code_txt == 'nsap-ptr':
+            return 'NSAP_PTR'
+        return code_txt.upper()
+    codes = [ (code, convert(txt)) for code, txt in code2txt.items() ]
+
+    # Dump source code for libdns++
+    with  open(placeholder, 'r') as header_temp:
+        with open(outputfile, 'w') as header_out:
+            header_out.write(heading_txt)
+            for line in header_temp:
+                header_out.write(line)
+                if re.match('\s+// BEGIN_WELL_KNOWN_' + upper_key +
+                            '_DECLARATIONS$', line):
+                    for code in codes:
+                        header_out.write(' ' * 4 + 'static const RR' +
+                                         cap_key + '& ' + code[1] + '();\n')
+                if re.match('// BEGIN_WELL_KNOWN_' + upper_key +
+                            '_DEFINITIONS$', line):
+                    for code in codes:
+                        header_out.write('''inline const RR''' + cap_key +
+                                         '''&
+RR''' + cap_key + '''::''' + code[1] + '''() {
+    static RR''' + cap_key + ''' ''' + lower_key + '''(''' + code[0] + ''');
     return (''' + lower_key + ''');
 }\n
-'''
-    header_temp = open(placeholder, 'r')
-    header_out = open(outputfile, 'w')
-    header_out.write(heading_txt)
-    for line in header_temp.readlines():
-        header_out.write(line)
-        if re.match('\s+// BEGIN_WELL_KNOWN_' + upper_key + '_DECLARATIONS$', line):
-            header_out.write(declarationtxt)
-        if re.match('// BEGIN_WELL_KNOWN_' + upper_key + '_DEFINITIONS$', line):
-            header_out.write('\n' + deftxt)
-    header_out.close()
-    header_temp.close()
+''')
+
+    # Dump source code snippet for isc.dns Python module
+    with open(py_outputfile, 'w') as py_out:
+        py_out.write("    // auto-generated by ../gen-rdatacode.py."
+                     "  Don't edit this file.\n")
+        py_out.write("\n")
+        for code in codes:
+            py_out.write('''\
+    installClassVariable(''' + lower_key + '''_type, "''' + code[1] + '''",
+                         createRR''' + cap_key + '''Object(RR''' + \
+        cap_key + '''::''' + code[1] + '''()));
+''')
 
 def generate_rrparam(fileprefix, basemtime):
     placeholder = '@srcdir@/' + fileprefix + '-placeholder.cc'
@@ -337,6 +388,16 @@ def generate_rrparam(fileprefix, basemtime):
             typeandclassparams += ', RdataFactoryPtr(new ' + rdf_class + '<'
             typeandclassparams += class_txt + '::' + type_utxt + '>()));\n'
 
+    typeandclassparams += indent + '// Meta and non-implemented RR types\n'
+    for type_code, type_txt in meta_types.items():
+        typeandclassparams += indent + \
+            'addType("' + type_txt.upper() + '", ' + type_code + ');\n'
+
+    typeandclassparams += indent + '// Meta classes\n'
+    for cls_code, cls_txt in meta_classes.items():
+        typeandclassparams += indent + \
+            'addClass("' + cls_txt.upper() + '", ' + cls_code + ');\n'
+
     rrparam_temp = open(placeholder, 'r')
     rrparam_out = open(outputfile, 'w')
     rrparam_out.write(heading_txt)
@@ -353,9 +414,14 @@ if __name__ == "__main__":
         generate_rdatadef('@builddir@/rdataclass.cc', rdatadef_mtime)
         generate_rdatahdr('@builddir@/rdataclass.h', heading_txt,
                           rdata_declarations, rdatahdr_mtime)
-        generate_typeclasscode('rrtype', rdatahdr_mtime, typecode2txt, 'Type')
+
+        # merge auto-generated types/classes with meta maps and generate the
+        # corresponding code.
+        generate_typeclasscode('rrtype', rdatahdr_mtime,
+                               dict(typecode2txt, **meta_types), 'Type')
         generate_typeclasscode('rrclass', classdir_mtime,
-                               classcode2txt, 'Class')
+                               dict(classcode2txt, **meta_classes), 'Class')
+
         generate_rrparam('rrparamregistry', rdatahdr_mtime)
     except:
         sys.stderr.write('Code generation failed due to exception: %s\n' %

+ 0 - 140
src/lib/dns/python/opcode_python.cc

@@ -43,62 +43,12 @@ void Opcode_destroy(s_Opcode* const self);
 PyObject* Opcode_getCode(const s_Opcode* const self);
 PyObject* Opcode_toText(const s_Opcode* const self);
 PyObject* Opcode_str(PyObject* self);
-PyObject* Opcode_QUERY(const s_Opcode* self);
-PyObject* Opcode_IQUERY(const s_Opcode* self);
-PyObject* Opcode_STATUS(const s_Opcode* self);
-PyObject* Opcode_RESERVED3(const s_Opcode* self);
-PyObject* Opcode_NOTIFY(const s_Opcode* self);
-PyObject* Opcode_UPDATE(const s_Opcode* self);
-PyObject* Opcode_RESERVED6(const s_Opcode* self);
-PyObject* Opcode_RESERVED7(const s_Opcode* self);
-PyObject* Opcode_RESERVED8(const s_Opcode* self);
-PyObject* Opcode_RESERVED9(const s_Opcode* self);
-PyObject* Opcode_RESERVED10(const s_Opcode* self);
-PyObject* Opcode_RESERVED11(const s_Opcode* self);
-PyObject* Opcode_RESERVED12(const s_Opcode* self);
-PyObject* Opcode_RESERVED13(const s_Opcode* self);
-PyObject* Opcode_RESERVED14(const s_Opcode* self);
-PyObject* Opcode_RESERVED15(const s_Opcode* self);
-PyObject* Opcode_richcmp(const s_Opcode* const self,
-                         const s_Opcode* const other, int op);
 
 PyMethodDef Opcode_methods[] = {
     { "get_code", reinterpret_cast<PyCFunction>(Opcode_getCode), METH_NOARGS,
       "Returns the code value" },
     { "to_text", reinterpret_cast<PyCFunction>(Opcode_toText), METH_NOARGS,
       "Returns the text representation" },
-    { "QUERY", reinterpret_cast<PyCFunction>(Opcode_QUERY),
-      METH_NOARGS | METH_STATIC, "Creates a QUERY Opcode" },
-    { "IQUERY", reinterpret_cast<PyCFunction>(Opcode_IQUERY),
-      METH_NOARGS | METH_STATIC, "Creates a IQUERY Opcode" },
-    { "STATUS", reinterpret_cast<PyCFunction>(Opcode_STATUS),
-      METH_NOARGS | METH_STATIC, "Creates a STATUS Opcode" },
-    { "RESERVED3", reinterpret_cast<PyCFunction>(Opcode_RESERVED3),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED3 Opcode" },
-    { "NOTIFY", reinterpret_cast<PyCFunction>(Opcode_NOTIFY),
-      METH_NOARGS | METH_STATIC, "Creates a NOTIFY Opcode" },
-    { "UPDATE", reinterpret_cast<PyCFunction>(Opcode_UPDATE),
-      METH_NOARGS | METH_STATIC, "Creates a UPDATE Opcode" },
-    { "RESERVED6", reinterpret_cast<PyCFunction>(Opcode_RESERVED6),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED6 Opcode" },
-    { "RESERVED7", reinterpret_cast<PyCFunction>(Opcode_RESERVED7),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED7 Opcode" },
-    { "RESERVED8", reinterpret_cast<PyCFunction>(Opcode_RESERVED8),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED8 Opcode" },
-    { "RESERVED9", reinterpret_cast<PyCFunction>(Opcode_RESERVED9),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED9 Opcode" },
-    { "RESERVED10", reinterpret_cast<PyCFunction>(Opcode_RESERVED10),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED10 Opcode" },
-    { "RESERVED11", reinterpret_cast<PyCFunction>(Opcode_RESERVED11),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED11 Opcode" },
-    { "RESERVED12", reinterpret_cast<PyCFunction>(Opcode_RESERVED12),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED12 Opcode" },
-    { "RESERVED13", reinterpret_cast<PyCFunction>(Opcode_RESERVED13),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED13 Opcode" },
-    { "RESERVED14", reinterpret_cast<PyCFunction>(Opcode_RESERVED14),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED14 Opcode" },
-    { "RESERVED15", reinterpret_cast<PyCFunction>(Opcode_RESERVED15),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED15 Opcode" },
     { NULL, NULL, 0, NULL }
 };
 
@@ -156,96 +106,6 @@ Opcode_str(PyObject* self) {
 }
 
 PyObject*
-Opcode_createStatic(const Opcode& opcode) {
-    s_Opcode* ret = PyObject_New(s_Opcode, &opcode_type);
-    if (ret != NULL) {
-        ret->cppobj = &opcode;
-        ret->static_code = true;
-    }
-    return (ret);
-}
-
-PyObject*
-Opcode_QUERY(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::QUERY()));
-}
-
-PyObject*
-Opcode_IQUERY(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::IQUERY()));
-}
-
-PyObject*
-Opcode_STATUS(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::STATUS()));
-}
-
-PyObject*
-Opcode_RESERVED3(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED3()));
-}
-
-PyObject*
-Opcode_NOTIFY(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::NOTIFY()));
-}
-
-PyObject*
-Opcode_UPDATE(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::UPDATE()));
-}
-
-PyObject*
-Opcode_RESERVED6(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED6()));
-}
-
-PyObject*
-Opcode_RESERVED7(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED7()));
-}
-
-PyObject*
-Opcode_RESERVED8(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED8()));
-}
-
-PyObject*
-Opcode_RESERVED9(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED9()));
-}
-
-PyObject*
-Opcode_RESERVED10(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED10()));
-}
-
-PyObject*
-Opcode_RESERVED11(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED11()));
-}
-
-PyObject*
-Opcode_RESERVED12(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED12()));
-}
-
-PyObject*
-Opcode_RESERVED13(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED13()));
-}
-
-PyObject*
-Opcode_RESERVED14(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED14()));
-}
-
-PyObject*
-Opcode_RESERVED15(const s_Opcode*) {
-    return (Opcode_createStatic(Opcode::RESERVED15()));
-}
-
-PyObject*
 Opcode_richcmp(const s_Opcode* const self, const s_Opcode* const other,
                const int op)
 {

+ 164 - 66
src/lib/dns/python/pydnspp.cc

@@ -294,38 +294,83 @@ initModulePart_Opcode(PyObject* mod) {
         return (false);
     }
 
-    addClassVariable(opcode_type, "QUERY_CODE",
-                     Py_BuildValue("h", Opcode::QUERY_CODE));
-    addClassVariable(opcode_type, "IQUERY_CODE",
-                     Py_BuildValue("h", Opcode::IQUERY_CODE));
-    addClassVariable(opcode_type, "STATUS_CODE",
-                     Py_BuildValue("h", Opcode::STATUS_CODE));
-    addClassVariable(opcode_type, "RESERVED3_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED3_CODE));
-    addClassVariable(opcode_type, "NOTIFY_CODE",
-                     Py_BuildValue("h", Opcode::NOTIFY_CODE));
-    addClassVariable(opcode_type, "UPDATE_CODE",
-                     Py_BuildValue("h", Opcode::UPDATE_CODE));
-    addClassVariable(opcode_type, "RESERVED6_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED6_CODE));
-    addClassVariable(opcode_type, "RESERVED7_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED7_CODE));
-    addClassVariable(opcode_type, "RESERVED8_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED8_CODE));
-    addClassVariable(opcode_type, "RESERVED9_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED9_CODE));
-    addClassVariable(opcode_type, "RESERVED10_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED10_CODE));
-    addClassVariable(opcode_type, "RESERVED11_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED11_CODE));
-    addClassVariable(opcode_type, "RESERVED12_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED12_CODE));
-    addClassVariable(opcode_type, "RESERVED13_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED13_CODE));
-    addClassVariable(opcode_type, "RESERVED14_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED14_CODE));
-    addClassVariable(opcode_type, "RESERVED15_CODE",
-                     Py_BuildValue("h", Opcode::RESERVED15_CODE));
+    try {
+        installClassVariable(opcode_type, "QUERY_CODE",
+                             Py_BuildValue("h", Opcode::QUERY_CODE));
+        installClassVariable(opcode_type, "IQUERY_CODE",
+                             Py_BuildValue("h", Opcode::IQUERY_CODE));
+        installClassVariable(opcode_type, "STATUS_CODE",
+                             Py_BuildValue("h", Opcode::STATUS_CODE));
+        installClassVariable(opcode_type, "RESERVED3_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED3_CODE));
+        installClassVariable(opcode_type, "NOTIFY_CODE",
+                             Py_BuildValue("h", Opcode::NOTIFY_CODE));
+        installClassVariable(opcode_type, "UPDATE_CODE",
+                             Py_BuildValue("h", Opcode::UPDATE_CODE));
+        installClassVariable(opcode_type, "RESERVED6_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED6_CODE));
+        installClassVariable(opcode_type, "RESERVED7_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED7_CODE));
+        installClassVariable(opcode_type, "RESERVED8_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED8_CODE));
+        installClassVariable(opcode_type, "RESERVED9_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED9_CODE));
+        installClassVariable(opcode_type, "RESERVED10_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED10_CODE));
+        installClassVariable(opcode_type, "RESERVED11_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED11_CODE));
+        installClassVariable(opcode_type, "RESERVED12_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED12_CODE));
+        installClassVariable(opcode_type, "RESERVED13_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED13_CODE));
+        installClassVariable(opcode_type, "RESERVED14_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED14_CODE));
+        installClassVariable(opcode_type, "RESERVED15_CODE",
+                             Py_BuildValue("h", Opcode::RESERVED15_CODE));
+
+        installClassVariable(opcode_type, "QUERY",
+                             createOpcodeObject(Opcode::QUERY()));
+        installClassVariable(opcode_type, "IQUERY",
+                             createOpcodeObject(Opcode::IQUERY()));
+        installClassVariable(opcode_type, "STATUS",
+                             createOpcodeObject(Opcode::STATUS()));
+        installClassVariable(opcode_type, "RESERVED3",
+                             createOpcodeObject(Opcode::RESERVED3()));
+        installClassVariable(opcode_type, "NOTIFY",
+                             createOpcodeObject(Opcode::NOTIFY()));
+        installClassVariable(opcode_type, "UPDATE",
+                             createOpcodeObject(Opcode::UPDATE()));
+        installClassVariable(opcode_type, "RESERVED6",
+                             createOpcodeObject(Opcode::RESERVED6()));
+        installClassVariable(opcode_type, "RESERVED7",
+                             createOpcodeObject(Opcode::RESERVED7()));
+        installClassVariable(opcode_type, "RESERVED8",
+                             createOpcodeObject(Opcode::RESERVED8()));
+        installClassVariable(opcode_type, "RESERVED9",
+                             createOpcodeObject(Opcode::RESERVED9()));
+        installClassVariable(opcode_type, "RESERVED10",
+                             createOpcodeObject(Opcode::RESERVED10()));
+        installClassVariable(opcode_type, "RESERVED11",
+                             createOpcodeObject(Opcode::RESERVED11()));
+        installClassVariable(opcode_type, "RESERVED12",
+                             createOpcodeObject(Opcode::RESERVED12()));
+        installClassVariable(opcode_type, "RESERVED13",
+                             createOpcodeObject(Opcode::RESERVED13()));
+        installClassVariable(opcode_type, "RESERVED14",
+                             createOpcodeObject(Opcode::RESERVED14()));
+        installClassVariable(opcode_type, "RESERVED15",
+                             createOpcodeObject(Opcode::RESERVED15()));
+    } catch (const std::exception& ex) {
+        const std::string ex_what =
+            "Unexpected failure in Opcode initialization: " +
+            std::string(ex.what());
+        PyErr_SetString(po_IscException, ex_what.c_str());
+        return (false);
+    } catch (...) {
+        PyErr_SetString(PyExc_SystemError,
+                        "Unexpected failure in Opcode initialization");
+        return (false);
+    }
 
     return (true);
 }
@@ -341,40 +386,87 @@ initModulePart_Rcode(PyObject* mod) {
         return (false);
     }
 
-    addClassVariable(rcode_type, "NOERROR_CODE",
-                     Py_BuildValue("h", Rcode::NOERROR_CODE));
-    addClassVariable(rcode_type, "FORMERR_CODE",
-                     Py_BuildValue("h", Rcode::FORMERR_CODE));
-    addClassVariable(rcode_type, "SERVFAIL_CODE",
-                     Py_BuildValue("h", Rcode::SERVFAIL_CODE));
-    addClassVariable(rcode_type, "NXDOMAIN_CODE",
-                     Py_BuildValue("h", Rcode::NXDOMAIN_CODE));
-    addClassVariable(rcode_type, "NOTIMP_CODE",
-                     Py_BuildValue("h", Rcode::NOTIMP_CODE));
-    addClassVariable(rcode_type, "REFUSED_CODE",
-                     Py_BuildValue("h", Rcode::REFUSED_CODE));
-    addClassVariable(rcode_type, "YXDOMAIN_CODE",
-                     Py_BuildValue("h", Rcode::YXDOMAIN_CODE));
-    addClassVariable(rcode_type, "YXRRSET_CODE",
-                     Py_BuildValue("h", Rcode::YXRRSET_CODE));
-    addClassVariable(rcode_type, "NXRRSET_CODE",
-                     Py_BuildValue("h", Rcode::NXRRSET_CODE));
-    addClassVariable(rcode_type, "NOTAUTH_CODE",
-                     Py_BuildValue("h", Rcode::NOTAUTH_CODE));
-    addClassVariable(rcode_type, "NOTZONE_CODE",
-                     Py_BuildValue("h", Rcode::NOTZONE_CODE));
-    addClassVariable(rcode_type, "RESERVED11_CODE",
-                     Py_BuildValue("h", Rcode::RESERVED11_CODE));
-    addClassVariable(rcode_type, "RESERVED12_CODE",
-                     Py_BuildValue("h", Rcode::RESERVED12_CODE));
-    addClassVariable(rcode_type, "RESERVED13_CODE",
-                     Py_BuildValue("h", Rcode::RESERVED13_CODE));
-    addClassVariable(rcode_type, "RESERVED14_CODE",
-                     Py_BuildValue("h", Rcode::RESERVED14_CODE));
-    addClassVariable(rcode_type, "RESERVED15_CODE",
-                     Py_BuildValue("h", Rcode::RESERVED15_CODE));
-    addClassVariable(rcode_type, "BADVERS_CODE",
-                     Py_BuildValue("h", Rcode::BADVERS_CODE));
+    try {
+        installClassVariable(rcode_type, "NOERROR_CODE",
+                             Py_BuildValue("h", Rcode::NOERROR_CODE));
+        installClassVariable(rcode_type, "FORMERR_CODE",
+                             Py_BuildValue("h", Rcode::FORMERR_CODE));
+        installClassVariable(rcode_type, "SERVFAIL_CODE",
+                             Py_BuildValue("h", Rcode::SERVFAIL_CODE));
+        installClassVariable(rcode_type, "NXDOMAIN_CODE",
+                             Py_BuildValue("h", Rcode::NXDOMAIN_CODE));
+        installClassVariable(rcode_type, "NOTIMP_CODE",
+                             Py_BuildValue("h", Rcode::NOTIMP_CODE));
+        installClassVariable(rcode_type, "REFUSED_CODE",
+                             Py_BuildValue("h", Rcode::REFUSED_CODE));
+        installClassVariable(rcode_type, "YXDOMAIN_CODE",
+                             Py_BuildValue("h", Rcode::YXDOMAIN_CODE));
+        installClassVariable(rcode_type, "YXRRSET_CODE",
+                             Py_BuildValue("h", Rcode::YXRRSET_CODE));
+        installClassVariable(rcode_type, "NXRRSET_CODE",
+                             Py_BuildValue("h", Rcode::NXRRSET_CODE));
+        installClassVariable(rcode_type, "NOTAUTH_CODE",
+                             Py_BuildValue("h", Rcode::NOTAUTH_CODE));
+        installClassVariable(rcode_type, "NOTZONE_CODE",
+                             Py_BuildValue("h", Rcode::NOTZONE_CODE));
+        installClassVariable(rcode_type, "RESERVED11_CODE",
+                             Py_BuildValue("h", Rcode::RESERVED11_CODE));
+        installClassVariable(rcode_type, "RESERVED12_CODE",
+                             Py_BuildValue("h", Rcode::RESERVED12_CODE));
+        installClassVariable(rcode_type, "RESERVED13_CODE",
+                             Py_BuildValue("h", Rcode::RESERVED13_CODE));
+        installClassVariable(rcode_type, "RESERVED14_CODE",
+                             Py_BuildValue("h", Rcode::RESERVED14_CODE));
+        installClassVariable(rcode_type, "RESERVED15_CODE",
+                             Py_BuildValue("h", Rcode::RESERVED15_CODE));
+        installClassVariable(rcode_type, "BADVERS_CODE",
+                             Py_BuildValue("h", Rcode::BADVERS_CODE));
+
+        installClassVariable(rcode_type, "NOERROR",
+                             createRcodeObject(Rcode::NOERROR()));
+        installClassVariable(rcode_type, "FORMERR",
+                             createRcodeObject(Rcode::FORMERR()));
+        installClassVariable(rcode_type, "SERVFAIL",
+                             createRcodeObject(Rcode::SERVFAIL()));
+        installClassVariable(rcode_type, "NXDOMAIN",
+                             createRcodeObject(Rcode::NXDOMAIN()));
+        installClassVariable(rcode_type, "NOTIMP",
+                             createRcodeObject(Rcode::NOTIMP()));
+        installClassVariable(rcode_type, "REFUSED",
+                             createRcodeObject(Rcode::REFUSED()));
+        installClassVariable(rcode_type, "YXDOMAIN",
+                             createRcodeObject(Rcode::YXDOMAIN()));
+        installClassVariable(rcode_type, "YXRRSET",
+                             createRcodeObject(Rcode::YXRRSET()));
+        installClassVariable(rcode_type, "NXRRSET",
+                             createRcodeObject(Rcode::NXRRSET()));
+        installClassVariable(rcode_type, "NOTAUTH",
+                             createRcodeObject(Rcode::NOTAUTH()));
+        installClassVariable(rcode_type, "NOTZONE",
+                             createRcodeObject(Rcode::NOTZONE()));
+        installClassVariable(rcode_type, "RESERVED11",
+                             createRcodeObject(Rcode::RESERVED11()));
+        installClassVariable(rcode_type, "RESERVED12",
+                             createRcodeObject(Rcode::RESERVED12()));
+        installClassVariable(rcode_type, "RESERVED13",
+                             createRcodeObject(Rcode::RESERVED13()));
+        installClassVariable(rcode_type, "RESERVED14",
+                             createRcodeObject(Rcode::RESERVED14()));
+        installClassVariable(rcode_type, "RESERVED15",
+                             createRcodeObject(Rcode::RESERVED15()));
+        installClassVariable(rcode_type, "BADVERS",
+                             createRcodeObject(Rcode::BADVERS()));
+    } catch (const std::exception& ex) {
+        const std::string ex_what =
+            "Unexpected failure in Rcode initialization: " +
+            std::string(ex.what());
+        PyErr_SetString(po_IscException, ex_what.c_str());
+        return (false);
+    } catch (...) {
+        PyErr_SetString(PyExc_SystemError,
+                        "Unexpected failure in Rcode initialization");
+        return (false);
+    }
 
     return (true);
 }
@@ -432,6 +524,9 @@ initModulePart_RRClass(PyObject* mod) {
                                                   NULL, NULL);
         PyObjectContainer(po_IncompleteRRClass).installToModule(
             mod, "IncompleteRRClass");
+
+        // Incorporate auto-generated RRClass constants
+#include <dns/python/rrclass_constants_inc.cc>
     } catch (const std::exception& ex) {
         const std::string ex_what =
             "Unexpected failure in RRClass initialization: " +
@@ -518,6 +613,9 @@ initModulePart_RRType(PyObject* mod) {
                                                  NULL, NULL);
         PyObjectContainer(po_IncompleteRRType).installToModule(
             mod, "IncompleteRRType");
+
+        // Incorporate auto-generated RRType constants
+#include <dns/python/rrtype_constants_inc.cc>
     } catch (const std::exception& ex) {
         const std::string ex_what =
             "Unexpected failure in RRType initialization: " +

+ 0 - 146
src/lib/dns/python/rcode_python.cc

@@ -55,23 +55,6 @@ PyObject* Rcode_getCode(const s_Rcode* const self);
 PyObject* Rcode_getExtendedCode(const s_Rcode* const self);
 PyObject* Rcode_toText(const s_Rcode* const self);
 PyObject* Rcode_str(PyObject* self);
-PyObject* Rcode_NOERROR(const s_Rcode* self);
-PyObject* Rcode_FORMERR(const s_Rcode* self);
-PyObject* Rcode_SERVFAIL(const s_Rcode* self);
-PyObject* Rcode_NXDOMAIN(const s_Rcode* self);
-PyObject* Rcode_NOTIMP(const s_Rcode* self);
-PyObject* Rcode_REFUSED(const s_Rcode* self);
-PyObject* Rcode_YXDOMAIN(const s_Rcode* self);
-PyObject* Rcode_YXRRSET(const s_Rcode* self);
-PyObject* Rcode_NXRRSET(const s_Rcode* self);
-PyObject* Rcode_NOTAUTH(const s_Rcode* self);
-PyObject* Rcode_NOTZONE(const s_Rcode* self);
-PyObject* Rcode_RESERVED11(const s_Rcode* self);
-PyObject* Rcode_RESERVED12(const s_Rcode* self);
-PyObject* Rcode_RESERVED13(const s_Rcode* self);
-PyObject* Rcode_RESERVED14(const s_Rcode* self);
-PyObject* Rcode_RESERVED15(const s_Rcode* self);
-PyObject* Rcode_BADVERS(const s_Rcode* self);
 PyObject* Rcode_richcmp(const s_Rcode* const self,
                          const s_Rcode* const other, int op);
 
@@ -83,40 +66,6 @@ PyMethodDef Rcode_methods[] = {
       "Returns the upper 8-bit part of the extended code value" },
     { "to_text", reinterpret_cast<PyCFunction>(Rcode_toText), METH_NOARGS,
       "Returns the text representation" },
-    { "NOERROR", reinterpret_cast<PyCFunction>(Rcode_NOERROR),
-      METH_NOARGS | METH_STATIC, "Creates a NOERROR Rcode" },
-    { "FORMERR", reinterpret_cast<PyCFunction>(Rcode_FORMERR),
-      METH_NOARGS | METH_STATIC, "Creates a FORMERR Rcode" },
-    { "SERVFAIL", reinterpret_cast<PyCFunction>(Rcode_SERVFAIL),
-      METH_NOARGS | METH_STATIC, "Creates a SERVFAIL Rcode" },
-    { "NXDOMAIN", reinterpret_cast<PyCFunction>(Rcode_NXDOMAIN),
-      METH_NOARGS | METH_STATIC, "Creates a NXDOMAIN Rcode" },
-    { "NOTIMP", reinterpret_cast<PyCFunction>(Rcode_NOTIMP),
-      METH_NOARGS | METH_STATIC, "Creates a NOTIMP Rcode" },
-    { "REFUSED", reinterpret_cast<PyCFunction>(Rcode_REFUSED),
-      METH_NOARGS | METH_STATIC, "Creates a REFUSED Rcode" },
-    { "YXDOMAIN", reinterpret_cast<PyCFunction>(Rcode_YXDOMAIN),
-      METH_NOARGS | METH_STATIC, "Creates a YXDOMAIN Rcode" },
-    { "YXRRSET", reinterpret_cast<PyCFunction>(Rcode_YXRRSET),
-      METH_NOARGS | METH_STATIC, "Creates a YYRRSET Rcode" },
-    { "NXRRSET", reinterpret_cast<PyCFunction>(Rcode_NXRRSET),
-      METH_NOARGS | METH_STATIC, "Creates a NXRRSET Rcode" },
-    { "NOTAUTH", reinterpret_cast<PyCFunction>(Rcode_NOTAUTH),
-      METH_NOARGS | METH_STATIC, "Creates a NOTAUTH Rcode" },
-    { "NOTZONE", reinterpret_cast<PyCFunction>(Rcode_NOTZONE),
-      METH_NOARGS | METH_STATIC, "Creates a NOTZONE Rcode" },
-    { "RESERVED11", reinterpret_cast<PyCFunction>(Rcode_RESERVED11),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED11 Rcode" },
-    { "RESERVED12", reinterpret_cast<PyCFunction>(Rcode_RESERVED12),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED12 Rcode" },
-    { "RESERVED13", reinterpret_cast<PyCFunction>(Rcode_RESERVED13),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED13 Rcode" },
-    { "RESERVED14", reinterpret_cast<PyCFunction>(Rcode_RESERVED14),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED14 Rcode" },
-    { "RESERVED15", reinterpret_cast<PyCFunction>(Rcode_RESERVED15),
-      METH_NOARGS | METH_STATIC, "Creates a RESERVED15 Rcode" },
-    { "BADVERS", reinterpret_cast<PyCFunction>(Rcode_BADVERS),
-      METH_NOARGS | METH_STATIC, "Creates a BADVERS Rcode" },
     { NULL, NULL, 0, NULL }
 };
 
@@ -193,101 +142,6 @@ Rcode_str(PyObject* self) {
 }
 
 PyObject*
-Rcode_createStatic(const Rcode& rcode) {
-    s_Rcode* ret = PyObject_New(s_Rcode, &rcode_type);
-    if (ret != NULL) {
-        ret->cppobj = &rcode;
-        ret->static_code = true;
-    }
-    return (ret);
-}
-
-PyObject*
-Rcode_NOERROR(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::NOERROR()));
-}
-
-PyObject*
-Rcode_FORMERR(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::FORMERR()));
-}
-
-PyObject*
-Rcode_SERVFAIL(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::SERVFAIL()));
-}
-
-PyObject*
-Rcode_NXDOMAIN(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::NXDOMAIN()));
-}
-
-PyObject*
-Rcode_NOTIMP(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::NOTIMP()));
-}
-
-PyObject*
-Rcode_REFUSED(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::REFUSED()));
-}
-
-PyObject*
-Rcode_YXDOMAIN(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::YXDOMAIN()));
-}
-
-PyObject*
-Rcode_YXRRSET(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::YXRRSET()));
-}
-
-PyObject*
-Rcode_NXRRSET(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::NXRRSET()));
-}
-
-PyObject*
-Rcode_NOTAUTH(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::NOTAUTH()));
-}
-
-PyObject*
-Rcode_NOTZONE(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::NOTZONE()));
-}
-
-PyObject*
-Rcode_RESERVED11(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::RESERVED11()));
-}
-
-PyObject*
-Rcode_RESERVED12(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::RESERVED12()));
-}
-
-PyObject*
-Rcode_RESERVED13(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::RESERVED13()));
-}
-
-PyObject*
-Rcode_RESERVED14(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::RESERVED14()));
-}
-
-PyObject*
-Rcode_RESERVED15(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::RESERVED15()));
-}
-
-PyObject*
-Rcode_BADVERS(const s_Rcode*) {
-    return (Rcode_createStatic(Rcode::BADVERS()));
-}
-
-PyObject*
 Rcode_richcmp(const s_Rcode* const self, const s_Rcode* const other,
               const int op)
 {

+ 0 - 43
src/lib/dns/python/rrclass_python.cc

@@ -54,13 +54,6 @@ PyObject* RRClass_getCode(s_RRClass* self);
 PyObject* RRClass_richcmp(s_RRClass* self, s_RRClass* other, int op);
 Py_hash_t RRClass_hash(PyObject* pyself);
 
-// Static function for direct class creation
-PyObject* RRClass_IN(s_RRClass *self);
-PyObject* RRClass_CH(s_RRClass *self);
-PyObject* RRClass_HS(s_RRClass *self);
-PyObject* RRClass_NONE(s_RRClass *self);
-PyObject* RRClass_ANY(s_RRClass *self);
-
 typedef CPPPyObjectContainer<s_RRClass, RRClass> RRClassContainer;
 
 // This list contains the actual set of functions we have in
@@ -81,11 +74,6 @@ PyMethodDef RRClass_methods[] = {
       "returned" },
     { "get_code", reinterpret_cast<PyCFunction>(RRClass_getCode), METH_NOARGS,
       "Returns the class code as an integer" },
-    { "IN", reinterpret_cast<PyCFunction>(RRClass_IN), METH_NOARGS | METH_STATIC, "Creates an IN RRClass" },
-    { "CH", reinterpret_cast<PyCFunction>(RRClass_CH), METH_NOARGS | METH_STATIC, "Creates a CH RRClass" },
-    { "HS", reinterpret_cast<PyCFunction>(RRClass_HS), METH_NOARGS | METH_STATIC, "Creates an HS RRClass" },
-    { "NONE", reinterpret_cast<PyCFunction>(RRClass_NONE), METH_NOARGS | METH_STATIC, "Creates a NONE RRClass" },
-    { "ANY", reinterpret_cast<PyCFunction>(RRClass_ANY), METH_NOARGS | METH_STATIC, "Creates an ANY RRClass" },
     { NULL, NULL, 0, NULL }
 };
 
@@ -234,37 +222,6 @@ RRClass_richcmp(s_RRClass* self, s_RRClass* other, int op) {
         Py_RETURN_FALSE;
 }
 
-//
-// Common function for RRClass_IN/CH/etc.
-//
-PyObject* RRClass_createStatic(RRClass stc) {
-    s_RRClass* ret = PyObject_New(s_RRClass, &rrclass_type);
-    if (ret != NULL) {
-        ret->cppobj = new RRClass(stc);
-    }
-    return (ret);
-}
-
-PyObject* RRClass_IN(s_RRClass*) {
-    return (RRClass_createStatic(RRClass::IN()));
-}
-
-PyObject* RRClass_CH(s_RRClass*) {
-    return (RRClass_createStatic(RRClass::CH()));
-}
-
-PyObject* RRClass_HS(s_RRClass*) {
-    return (RRClass_createStatic(RRClass::HS()));
-}
-
-PyObject* RRClass_NONE(s_RRClass*) {
-    return (RRClass_createStatic(RRClass::NONE()));
-}
-
-PyObject* RRClass_ANY(s_RRClass*) {
-    return (RRClass_createStatic(RRClass::ANY()));
-}
-
 Py_hash_t
 RRClass_hash(PyObject* pyself) {
     const s_RRClass* const self = static_cast<s_RRClass*>(pyself);

+ 0 - 144
src/lib/dns/python/rrtype_python.cc

@@ -50,25 +50,6 @@ PyObject* RRType_toWire(s_RRType* self, PyObject* args);
 PyObject* RRType_getCode(s_RRType* self);
 PyObject* RRType_richcmp(s_RRType* self, s_RRType* other, int op);
 Py_hash_t RRType_hash(PyObject* pyself);
-PyObject* RRType_NSEC3PARAM(s_RRType *self);
-PyObject* RRType_DNAME(s_RRType *self);
-PyObject* RRType_PTR(s_RRType *self);
-PyObject* RRType_MX(s_RRType *self);
-PyObject* RRType_DNSKEY(s_RRType *self);
-PyObject* RRType_TXT(s_RRType *self);
-PyObject* RRType_RRSIG(s_RRType *self);
-PyObject* RRType_NSEC(s_RRType *self);
-PyObject* RRType_AAAA(s_RRType *self);
-PyObject* RRType_DS(s_RRType *self);
-PyObject* RRType_OPT(s_RRType *self);
-PyObject* RRType_A(s_RRType *self);
-PyObject* RRType_NS(s_RRType *self);
-PyObject* RRType_CNAME(s_RRType *self);
-PyObject* RRType_SOA(s_RRType *self);
-PyObject* RRType_NSEC3(s_RRType *self);
-PyObject* RRType_IXFR(s_RRType *self);
-PyObject* RRType_AXFR(s_RRType *self);
-PyObject* RRType_ANY(s_RRType *self);
 
 typedef CPPPyObjectContainer<s_RRType, RRType> RRTypeContainer;
 
@@ -90,25 +71,6 @@ PyMethodDef RRType_methods[] = {
       "returned" },
     { "get_code", reinterpret_cast<PyCFunction>(RRType_getCode), METH_NOARGS,
       "Returns the type code as an integer" },
-    { "NSEC3PARAM", reinterpret_cast<PyCFunction>(RRType_NSEC3PARAM), METH_NOARGS | METH_STATIC, "Creates an NSEC3PARAM RRType" },
-    { "DNAME", reinterpret_cast<PyCFunction>(RRType_DNAME), METH_NOARGS | METH_STATIC, "Creates a DNAME RRType" },
-    { "PTR", reinterpret_cast<PyCFunction>(RRType_PTR), METH_NOARGS | METH_STATIC, "Creates a PTR RRType" },
-    { "MX", reinterpret_cast<PyCFunction>(RRType_MX), METH_NOARGS | METH_STATIC, "Creates an MX RRType" },
-    { "DNSKEY", reinterpret_cast<PyCFunction>(RRType_DNSKEY), METH_NOARGS | METH_STATIC, "Creates a DNSKEY RRType" },
-    { "TXT", reinterpret_cast<PyCFunction>(RRType_TXT), METH_NOARGS | METH_STATIC, "Creates a TXT RRType" },
-    { "RRSIG", reinterpret_cast<PyCFunction>(RRType_RRSIG), METH_NOARGS | METH_STATIC, "Creates a RRSIG RRType" },
-    { "NSEC", reinterpret_cast<PyCFunction>(RRType_NSEC), METH_NOARGS | METH_STATIC, "Creates a NSEC RRType" },
-    { "AAAA", reinterpret_cast<PyCFunction>(RRType_AAAA), METH_NOARGS | METH_STATIC, "Creates an AAAA RRType" },
-    { "DS", reinterpret_cast<PyCFunction>(RRType_DS), METH_NOARGS | METH_STATIC, "Creates a DS RRType" },
-    { "OPT", reinterpret_cast<PyCFunction>(RRType_OPT), METH_NOARGS | METH_STATIC, "Creates an OPT RRType" },
-    { "A", reinterpret_cast<PyCFunction>(RRType_A), METH_NOARGS | METH_STATIC, "Creates an A RRType" },
-    { "NS", reinterpret_cast<PyCFunction>(RRType_NS), METH_NOARGS | METH_STATIC, "Creates an NS RRType" },
-    { "CNAME", reinterpret_cast<PyCFunction>(RRType_CNAME), METH_NOARGS | METH_STATIC, "Creates a CNAME RRType" },
-    { "SOA", reinterpret_cast<PyCFunction>(RRType_SOA), METH_NOARGS | METH_STATIC, "Creates a SOA RRType" },
-    { "NSEC3", reinterpret_cast<PyCFunction>(RRType_NSEC3), METH_NOARGS | METH_STATIC, "Creates an NSEC3 RRType" },
-    { "IXFR", reinterpret_cast<PyCFunction>(RRType_IXFR), METH_NOARGS | METH_STATIC, "Creates an IXFR RRType" },
-    { "AXFR", reinterpret_cast<PyCFunction>(RRType_AXFR), METH_NOARGS | METH_STATIC, "Creates an AXFR RRType" },
-    { "ANY", reinterpret_cast<PyCFunction>(RRType_ANY), METH_NOARGS | METH_STATIC, "Creates an ANY RRType" },
     { NULL, NULL, 0, NULL }
 };
 
@@ -263,112 +225,6 @@ RRType_richcmp(s_RRType* self, s_RRType* other, int op) {
         Py_RETURN_FALSE;
 }
 
-//
-// Common function for RRType_A/NS/etc.
-//
-PyObject* RRType_createStatic(RRType stc) {
-    s_RRType* ret = PyObject_New(s_RRType, &rrtype_type);
-    if (ret != NULL) {
-        ret->cppobj = new RRType(stc);
-    }
-    return (ret);
-}
-
-PyObject*
-RRType_NSEC3PARAM(s_RRType*) {
-    return (RRType_createStatic(RRType::NSEC3PARAM()));
-}
-
-PyObject*
-RRType_DNAME(s_RRType*) {
-    return (RRType_createStatic(RRType::DNAME()));
-}
-
-PyObject*
-RRType_PTR(s_RRType*) {
-    return (RRType_createStatic(RRType::PTR()));
-}
-
-PyObject*
-RRType_MX(s_RRType*) {
-    return (RRType_createStatic(RRType::MX()));
-}
-
-PyObject*
-RRType_DNSKEY(s_RRType*) {
-    return (RRType_createStatic(RRType::DNSKEY()));
-}
-
-PyObject*
-RRType_TXT(s_RRType*) {
-    return (RRType_createStatic(RRType::TXT()));
-}
-
-PyObject*
-RRType_RRSIG(s_RRType*) {
-    return (RRType_createStatic(RRType::RRSIG()));
-}
-
-PyObject*
-RRType_NSEC(s_RRType*) {
-    return (RRType_createStatic(RRType::NSEC()));
-}
-
-PyObject*
-RRType_AAAA(s_RRType*) {
-    return (RRType_createStatic(RRType::AAAA()));
-}
-
-PyObject*
-RRType_DS(s_RRType*) {
-    return (RRType_createStatic(RRType::DS()));
-}
-
-PyObject*
-RRType_OPT(s_RRType*) {
-    return (RRType_createStatic(RRType::OPT()));
-}
-
-PyObject*
-RRType_A(s_RRType*) {
-    return (RRType_createStatic(RRType::A()));
-}
-
-PyObject*
-RRType_NS(s_RRType*) {
-    return (RRType_createStatic(RRType::NS()));
-}
-
-PyObject*
-RRType_CNAME(s_RRType*) {
-    return (RRType_createStatic(RRType::CNAME()));
-}
-
-PyObject*
-RRType_SOA(s_RRType*) {
-    return (RRType_createStatic(RRType::SOA()));
-}
-
-PyObject*
-RRType_NSEC3(s_RRType*) {
-    return (RRType_createStatic(RRType::NSEC3()));
-}
-
-PyObject*
-RRType_IXFR(s_RRType*) {
-    return (RRType_createStatic(RRType::IXFR()));
-}
-
-PyObject*
-RRType_AXFR(s_RRType*) {
-    return (RRType_createStatic(RRType::AXFR()));
-}
-
-PyObject*
-RRType_ANY(s_RRType*) {
-    return (RRType_createStatic(RRType::ANY()));
-}
-
 Py_hash_t
 RRType_hash(PyObject* pyself) {
     const s_RRType* const self = static_cast<s_RRType*>(pyself);

+ 3 - 3
src/lib/dns/python/tests/edns_python_test.py

@@ -108,8 +108,8 @@ class EDNSTest(unittest.TestCase):
 
     def test_towire_renderer(self):
         renderer = MessageRenderer()
-        extrcode_noerror = Rcode.NOERROR().get_extended_code()
-        extrcode_badvers = Rcode.BADVERS().get_extended_code()
+        extrcode_noerror = Rcode.NOERROR.get_extended_code()
+        extrcode_badvers = Rcode.BADVERS.get_extended_code()
 
         self.assertEqual(1, self.edns_base.to_wire(renderer, extrcode_noerror))
         wiredata = read_wire_data("edns_toWire1.wire")
@@ -148,7 +148,7 @@ class EDNSTest(unittest.TestCase):
         self.assertEqual(0, renderer.get_length())
 
     def test_towire_buffer(self):
-        extrcode_noerror = Rcode.NOERROR().get_extended_code()
+        extrcode_noerror = Rcode.NOERROR.get_extended_code()
 
         obuffer = bytes()
         obuffer = self.edns_base.to_wire(obuffer, extrcode_noerror)

+ 17 - 17
src/lib/dns/python/tests/message_python_test.py

@@ -59,8 +59,8 @@ LONG_TXT4 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef012
 def create_message():
     message_render = Message(Message.RENDER)
     message_render.set_qid(0x1035)
-    message_render.set_opcode(Opcode.QUERY())
-    message_render.set_rcode(Rcode.NOERROR())
+    message_render.set_opcode(Opcode.QUERY)
+    message_render.set_rcode(Rcode.NOERROR)
     message_render.set_header_flag(Message.HEADERFLAG_QR)
     message_render.set_header_flag(Message.HEADERFLAG_RD)
     message_render.set_header_flag(Message.HEADERFLAG_AA)
@@ -161,7 +161,7 @@ class MessageTest(unittest.TestCase):
     def test_set_rcode(self):
         self.assertRaises(TypeError, self.r.set_rcode, "wrong")
 
-        rcode = Rcode.BADVERS()
+        rcode = Rcode.BADVERS
         self.r.set_rcode(rcode)
         self.assertEqual(rcode, self.r.get_rcode())
 
@@ -173,7 +173,7 @@ class MessageTest(unittest.TestCase):
     def test_set_opcode(self):
         self.assertRaises(TypeError, self.r.set_opcode, "wrong")
 
-        opcode = Opcode.IQUERY()
+        opcode = Opcode.IQUERY
         self.r.set_opcode(opcode)
         self.assertEqual(opcode, self.r.get_opcode())
 
@@ -304,8 +304,8 @@ class MessageTest(unittest.TestCase):
         self.assertRaises(TypeError, self.r.clear, 3)
 
     def test_clear_question_section(self):
-        self.r.add_question(Question(Name("www.example.com"), RRClass.IN(),
-                                     RRType.A()))
+        self.r.add_question(Question(Name("www.example.com"), RRClass.IN,
+                                     RRType.A))
         self.assertEqual(1, self.r.get_rr_count(Message.SECTION_QUESTION))
         self.r.clear_section(Message.SECTION_QUESTION)
         self.assertEqual(0, self.r.get_rr_count(Message.SECTION_QUESTION))
@@ -336,19 +336,19 @@ class MessageTest(unittest.TestCase):
                          renderer.get_data())
 
     def test_to_wire_without_opcode(self):
-        self.r.set_rcode(Rcode.NOERROR())
+        self.r.set_rcode(Rcode.NOERROR)
         self.assertRaises(InvalidMessageOperation, self.r.to_wire,
                           MessageRenderer())
 
     def test_to_wire_without_rcode(self):
-        self.r.set_opcode(Opcode.QUERY())
+        self.r.set_opcode(Opcode.QUERY)
         self.assertRaises(InvalidMessageOperation, self.r.to_wire,
                           MessageRenderer())
 
     def __common_tsigmessage_setup(self, flags=[Message.HEADERFLAG_RD],
                                    rrtype=RRType("A"), answer_data=None):
-        self.r.set_opcode(Opcode.QUERY())
-        self.r.set_rcode(Rcode.NOERROR())
+        self.r.set_opcode(Opcode.QUERY)
+        self.r.set_rcode(Rcode.NOERROR)
         for flag in flags:
             self.r.set_header_flag(flag)
         if answer_data is not None:
@@ -407,8 +407,8 @@ class MessageTest(unittest.TestCase):
         self.__common_tsig_checks("message_toWire4.wire")
 
     def test_to_wire_tsig_truncation3(self):
-        self.r.set_opcode(Opcode.QUERY())
-        self.r.set_rcode(Rcode.NOERROR())
+        self.r.set_opcode(Opcode.QUERY)
+        self.r.set_rcode(Rcode.NOERROR)
         for i in range(1, 68):
             self.r.add_question(Question(Name("www.example.com"),
                                          RRClass("IN"), RRType(i)))
@@ -469,11 +469,11 @@ test.example.com. 3600 IN A 192.0.2.2
         self.assertEqual(msg_str, str(message_render))
 
     def test_to_text_without_opcode(self):
-        self.r.set_rcode(Rcode.NOERROR())
+        self.r.set_rcode(Rcode.NOERROR)
         self.assertRaises(InvalidMessageOperation, self.r.to_text)
 
     def test_to_text_without_rcode(self):
-        self.r.set_opcode(Opcode.QUERY())
+        self.r.set_opcode(Opcode.QUERY)
         self.assertRaises(InvalidMessageOperation, self.r.to_text)
 
     def test_from_wire(self):
@@ -488,8 +488,8 @@ test.example.com. 3600 IN A 192.0.2.2
         message_parse = Message(0)
         factoryFromFile(message_parse, "message_fromWire1")
         self.assertEqual(0x1035, message_parse.get_qid())
-        self.assertEqual(Opcode.QUERY(), message_parse.get_opcode())
-        self.assertEqual(Rcode.NOERROR(), message_parse.get_rcode())
+        self.assertEqual(Opcode.QUERY, message_parse.get_opcode())
+        self.assertEqual(Rcode.NOERROR, message_parse.get_rcode())
         self.assertTrue(message_parse.get_header_flag(Message.HEADERFLAG_QR))
         self.assertTrue(message_parse.get_header_flag(Message.HEADERFLAG_RD))
         self.assertTrue(message_parse.get_header_flag(Message.HEADERFLAG_AA))
@@ -568,7 +568,7 @@ test.example.com. 3600 IN A 192.0.2.2
         # Extended Rcode = BADVERS
         message_parse = Message(Message.PARSE)
         factoryFromFile(message_parse, "message_fromWire10.wire")
-        self.assertEqual(Rcode.BADVERS(), message_parse.get_rcode())
+        self.assertEqual(Rcode.BADVERS, message_parse.get_rcode())
 
         # Maximum extended Rcode
         message_parse.clear(Message.PARSE)

+ 4 - 4
src/lib/dns/python/tests/messagerenderer_python_test.py

@@ -31,8 +31,8 @@ class MessageRendererTest(unittest.TestCase):
 
         message = Message(Message.RENDER)
         message.set_qid(123)
-        message.set_opcode(Opcode.QUERY())
-        message.set_rcode(Rcode.NOERROR())
+        message.set_opcode(Opcode.QUERY)
+        message.set_rcode(Rcode.NOERROR)
         message.add_question(Question(name, c, t))
 
         self.message1 = message
@@ -40,8 +40,8 @@ class MessageRendererTest(unittest.TestCase):
         message.set_qid(123)
         message.set_header_flag(Message.HEADERFLAG_AA, True)
         message.set_header_flag(Message.HEADERFLAG_QR, True)
-        message.set_opcode(Opcode.QUERY())
-        message.set_rcode(Rcode.NOERROR())
+        message.set_opcode(Opcode.QUERY)
+        message.set_rcode(Rcode.NOERROR)
         message.add_question(Question(name, c, t))
         rrset = RRset(name, c, t, ttl)
         rrset.add_rdata(Rdata(t, c, "192.0.2.98"))

+ 23 - 23
src/lib/dns/python/tests/nsec3hash_python_test.py

@@ -24,9 +24,9 @@ class NSEC3HashTest(unittest.TestCase):
 
     def setUp(self):
         self.nsec3_common = "2T7B4G4VSA5SMI47K61MV5BV1A22BOJR A RRSIG"
-        self.test_hash = NSEC3Hash(Rdata(RRType.NSEC3PARAM(), RRClass.IN(),
+        self.test_hash = NSEC3Hash(Rdata(RRType.NSEC3PARAM, RRClass.IN,
                                          "1 0 12 aabbccdd"))
-        self.test_hash_nsec3 = NSEC3Hash(Rdata(RRType.NSEC3(), RRClass.IN(),
+        self.test_hash_nsec3 = NSEC3Hash(Rdata(RRType.NSEC3, RRClass.IN,
                                                "1 0 12 aabbccdd " +
                                                self.nsec3_common))
     def test_bad_construct(self):
@@ -37,20 +37,20 @@ class NSEC3HashTest(unittest.TestCase):
         self.assertRaises(TypeError, NSEC3Hash, "1 0 12 aabbccdd")
 
         # additional parameter
-        self.assertRaises(TypeError, NSEC3Hash, Rdata(RRType.NSEC3PARAM(),
-                                                      RRClass.IN(),
+        self.assertRaises(TypeError, NSEC3Hash, Rdata(RRType.NSEC3PARAM,
+                                                      RRClass.IN,
                                                       "1 0 12 aabbccdd"), 1)
 
         # Invaid type of RDATA
-        self.assertRaises(TypeError, NSEC3Hash, Rdata(RRType.A(), RRClass.IN(),
+        self.assertRaises(TypeError, NSEC3Hash, Rdata(RRType.A, RRClass.IN,
                                                       "192.0.2.1"))
 
     def test_unknown_algorithm(self):
         self.assertRaises(UnknownNSEC3HashAlgorithm, NSEC3Hash,
-                          Rdata(RRType.NSEC3PARAM(), RRClass.IN(),
+                          Rdata(RRType.NSEC3PARAM, RRClass.IN,
                                 "2 0 12 aabbccdd"))
         self.assertRaises(UnknownNSEC3HashAlgorithm, NSEC3Hash,
-                          Rdata(RRType.NSEC3(), RRClass.IN(),
+                          Rdata(RRType.NSEC3, RRClass.IN,
                                 "2 0 12 aabbccdd " + self.nsec3_common))
 
     def calculate_check(self, hash):
@@ -71,15 +71,15 @@ class NSEC3HashTest(unittest.TestCase):
 
         # Using unusually large iterations, something larger than the 8-bit
         #range.  (expected hash value generated by BIND 9's dnssec-signzone)
-        self.test_hash = NSEC3Hash(Rdata(RRType.NSEC3PARAM(),
-                                         RRClass.IN(), "1 0 256 AABBCCDD"))
+        self.test_hash = NSEC3Hash(Rdata(RRType.NSEC3PARAM,
+                                         RRClass.IN, "1 0 256 AABBCCDD"))
         self.assertEqual("COG6A52MJ96MNMV3QUCAGGCO0RHCC2Q3",
                          self.test_hash.calculate(Name("example.org")))
 
         # Some boundary cases: 0-iteration and empty salt.  Borrowed from the
         # .com zone data.
-        self.test_hash = NSEC3Hash(Rdata(RRType.NSEC3PARAM(),
-                                         RRClass.IN(),"1 0 0 -"))
+        self.test_hash = NSEC3Hash(Rdata(RRType.NSEC3PARAM,
+                                         RRClass.IN,"1 0 0 -"))
         self.assertEqual("CK0POJMG874LJREF7EFN8430QVIT8BSM",
                          self.test_hash.calculate(Name("com")))
 
@@ -90,39 +90,39 @@ class NSEC3HashTest(unittest.TestCase):
 
     def check_match(self, hash, rrtype, postfix):
         # If all parameters match, it's considered to be matched.
-        self.assertTrue(hash.match(Rdata(rrtype, RRClass.IN(),
+        self.assertTrue(hash.match(Rdata(rrtype, RRClass.IN,
                                          "1 0 12 aabbccdd" + postfix)))
         # Algorithm doesn't match
-        self.assertFalse(hash.match(Rdata(rrtype, RRClass.IN(),
+        self.assertFalse(hash.match(Rdata(rrtype, RRClass.IN,
                                           "2 0 12 aabbccdd" + postfix)))
         # Iterations doesn't match
-        self.assertFalse(hash.match(Rdata(rrtype, RRClass.IN(),
+        self.assertFalse(hash.match(Rdata(rrtype, RRClass.IN,
                                           "1 0 1 aabbccdd" + postfix)))
         # Salt doesn't match
-        self.assertFalse(hash.match(Rdata(rrtype, RRClass.IN(),
+        self.assertFalse(hash.match(Rdata(rrtype, RRClass.IN,
                                           "1 0 12 aabbccde" + postfix)))
         # Salt doesn't match: the other has an empty salt
-        self.assertFalse(hash.match(Rdata(rrtype, RRClass.IN(),
+        self.assertFalse(hash.match(Rdata(rrtype, RRClass.IN,
                                           "1 0 12 -" + postfix)))
         # Flag doesn't matter
-        self.assertTrue(hash.match(Rdata(rrtype, RRClass.IN(),
+        self.assertTrue(hash.match(Rdata(rrtype, RRClass.IN,
                                          "1 1 12 aabbccdd" + postfix)))
 
     def test_match(self):
-        self.check_match(self.test_hash, RRType.NSEC3(),
+        self.check_match(self.test_hash, RRType.NSEC3,
                          " " + self.nsec3_common)
-        self.check_match(self.test_hash_nsec3, RRType.NSEC3(),
+        self.check_match(self.test_hash_nsec3, RRType.NSEC3,
                          " " + self.nsec3_common)
-        self.check_match(self.test_hash, RRType.NSEC3PARAM(), "")
-        self.check_match(self.test_hash_nsec3, RRType.NSEC3PARAM(), "")
+        self.check_match(self.test_hash, RRType.NSEC3PARAM, "")
+        self.check_match(self.test_hash_nsec3, RRType.NSEC3PARAM, "")
 
         # bad parameter checks
         self.assertRaises(TypeError, self.test_hash.match, 1)
         self.assertRaises(TypeError, self.test_hash.match,
-                          Rdata(RRType.NSEC3(), RRClass.IN(),
+                          Rdata(RRType.NSEC3, RRClass.IN,
                                 "1 0 12 aabbccdd " + self.nsec3_common), 1)
         self.assertRaises(TypeError, self.test_hash.match,
-                          Rdata(RRType.A(), RRClass.IN(), "192.0.2.1"))
+                          Rdata(RRType.A, RRClass.IN, "192.0.2.1"))
 
 if __name__ == '__main__':
     unittest.main()

+ 41 - 41
src/lib/dns/python/tests/opcode_python_test.py

@@ -34,53 +34,53 @@ class OpcodeTest(unittest.TestCase):
         self.assertEqual(Opcode.UPDATE_CODE, Opcode(5).get_code())
         self.assertEqual(Opcode.RESERVED15_CODE, Opcode(15).get_code())
 
-        self.assertEqual(Opcode.QUERY_CODE, Opcode.QUERY().get_code())
-        self.assertEqual(Opcode.IQUERY_CODE, Opcode.IQUERY().get_code())
-        self.assertEqual(Opcode.NOTIFY_CODE, Opcode.NOTIFY().get_code())
-        self.assertEqual(Opcode.UPDATE_CODE, Opcode.UPDATE().get_code())
-        self.assertEqual(Opcode.RESERVED15_CODE, Opcode.RESERVED15().get_code())
+        self.assertEqual(Opcode.QUERY_CODE, Opcode.QUERY.get_code())
+        self.assertEqual(Opcode.IQUERY_CODE, Opcode.IQUERY.get_code())
+        self.assertEqual(Opcode.NOTIFY_CODE, Opcode.NOTIFY.get_code())
+        self.assertEqual(Opcode.UPDATE_CODE, Opcode.UPDATE.get_code())
+        self.assertEqual(Opcode.RESERVED15_CODE, Opcode.RESERVED15.get_code())
 
     def test_get_code(self):
-        self.assertEqual(0, Opcode.QUERY().get_code())
-        self.assertEqual(1, Opcode.IQUERY().get_code())
-        self.assertEqual(2, Opcode.STATUS().get_code())
-        self.assertEqual(3, Opcode.RESERVED3().get_code())
-        self.assertEqual(4, Opcode.NOTIFY().get_code())
-        self.assertEqual(5, Opcode.UPDATE().get_code())
-        self.assertEqual(6, Opcode.RESERVED6().get_code())
-        self.assertEqual(7, Opcode.RESERVED7().get_code())
-        self.assertEqual(8, Opcode.RESERVED8().get_code())
-        self.assertEqual(9, Opcode.RESERVED9().get_code())
-        self.assertEqual(10, Opcode.RESERVED10().get_code())
-        self.assertEqual(11, Opcode.RESERVED11().get_code())
-        self.assertEqual(12, Opcode.RESERVED12().get_code())
-        self.assertEqual(13, Opcode.RESERVED13().get_code())
-        self.assertEqual(14, Opcode.RESERVED14().get_code())
-        self.assertEqual(15, Opcode.RESERVED15().get_code())
+        self.assertEqual(0, Opcode.QUERY.get_code())
+        self.assertEqual(1, Opcode.IQUERY.get_code())
+        self.assertEqual(2, Opcode.STATUS.get_code())
+        self.assertEqual(3, Opcode.RESERVED3.get_code())
+        self.assertEqual(4, Opcode.NOTIFY.get_code())
+        self.assertEqual(5, Opcode.UPDATE.get_code())
+        self.assertEqual(6, Opcode.RESERVED6.get_code())
+        self.assertEqual(7, Opcode.RESERVED7.get_code())
+        self.assertEqual(8, Opcode.RESERVED8.get_code())
+        self.assertEqual(9, Opcode.RESERVED9.get_code())
+        self.assertEqual(10, Opcode.RESERVED10.get_code())
+        self.assertEqual(11, Opcode.RESERVED11.get_code())
+        self.assertEqual(12, Opcode.RESERVED12.get_code())
+        self.assertEqual(13, Opcode.RESERVED13.get_code())
+        self.assertEqual(14, Opcode.RESERVED14.get_code())
+        self.assertEqual(15, Opcode.RESERVED15.get_code())
 
     def test_to_text(self):
-        self.assertEqual("QUERY", Opcode.QUERY().to_text())
-        self.assertEqual("QUERY", str(Opcode.QUERY()))
-        self.assertEqual("IQUERY", Opcode.IQUERY().to_text())
-        self.assertEqual("STATUS", Opcode.STATUS().to_text())
-        self.assertEqual("RESERVED3", Opcode.RESERVED3().to_text())
-        self.assertEqual("NOTIFY", Opcode.NOTIFY().to_text())
-        self.assertEqual("UPDATE", Opcode.UPDATE().to_text())
-        self.assertEqual("RESERVED6", Opcode.RESERVED6().to_text())
-        self.assertEqual("RESERVED7", Opcode.RESERVED7().to_text())
-        self.assertEqual("RESERVED8", Opcode.RESERVED8().to_text())
-        self.assertEqual("RESERVED9", Opcode.RESERVED9().to_text())
-        self.assertEqual("RESERVED10", Opcode.RESERVED10().to_text())
-        self.assertEqual("RESERVED11", Opcode.RESERVED11().to_text())
-        self.assertEqual("RESERVED12", Opcode.RESERVED12().to_text())
-        self.assertEqual("RESERVED13", Opcode.RESERVED13().to_text())
-        self.assertEqual("RESERVED14", Opcode.RESERVED14().to_text())
-        self.assertEqual("RESERVED15", Opcode.RESERVED15().to_text())
+        self.assertEqual("QUERY", Opcode.QUERY.to_text())
+        self.assertEqual("QUERY", str(Opcode.QUERY))
+        self.assertEqual("IQUERY", Opcode.IQUERY.to_text())
+        self.assertEqual("STATUS", Opcode.STATUS.to_text())
+        self.assertEqual("RESERVED3", Opcode.RESERVED3.to_text())
+        self.assertEqual("NOTIFY", Opcode.NOTIFY.to_text())
+        self.assertEqual("UPDATE", Opcode.UPDATE.to_text())
+        self.assertEqual("RESERVED6", Opcode.RESERVED6.to_text())
+        self.assertEqual("RESERVED7", Opcode.RESERVED7.to_text())
+        self.assertEqual("RESERVED8", Opcode.RESERVED8.to_text())
+        self.assertEqual("RESERVED9", Opcode.RESERVED9.to_text())
+        self.assertEqual("RESERVED10", Opcode.RESERVED10.to_text())
+        self.assertEqual("RESERVED11", Opcode.RESERVED11.to_text())
+        self.assertEqual("RESERVED12", Opcode.RESERVED12.to_text())
+        self.assertEqual("RESERVED13", Opcode.RESERVED13.to_text())
+        self.assertEqual("RESERVED14", Opcode.RESERVED14.to_text())
+        self.assertEqual("RESERVED15", Opcode.RESERVED15.to_text())
 
     def test_richcmp(self):
-        o1 = Opcode.QUERY()
-        o2 = Opcode.NOTIFY()
-        o3 = Opcode.NOTIFY()
+        o1 = Opcode.QUERY
+        o2 = Opcode.NOTIFY
+        o3 = Opcode.NOTIFY
         self.assertTrue(o2 == o3)
         self.assertFalse(o2 != o3)
         self.assertTrue(o1 != o2)

+ 30 - 30
src/lib/dns/python/tests/rcode_python_test.py

@@ -54,36 +54,36 @@ class RcodeTest(unittest.TestCase):
         self.assertEqual(Rcode.RESERVED15_CODE, Rcode(15).get_code())
         self.assertEqual(Rcode.BADVERS_CODE, Rcode(16).get_code())
 
-        self.assertEqual(Rcode.NOERROR_CODE, Rcode.NOERROR().get_code())
-        self.assertEqual(Rcode.FORMERR_CODE, Rcode.FORMERR().get_code())
-        self.assertEqual(Rcode.NOTIMP_CODE, Rcode.NOTIMP().get_code())
-        self.assertEqual(Rcode.REFUSED_CODE, Rcode.REFUSED().get_code())
-        self.assertEqual(Rcode.RESERVED15_CODE, Rcode.RESERVED15().get_code())
-        self.assertEqual(Rcode.BADVERS_CODE, Rcode.BADVERS().get_code())
+        self.assertEqual(Rcode.NOERROR_CODE, Rcode.NOERROR.get_code())
+        self.assertEqual(Rcode.FORMERR_CODE, Rcode.FORMERR.get_code())
+        self.assertEqual(Rcode.NOTIMP_CODE, Rcode.NOTIMP.get_code())
+        self.assertEqual(Rcode.REFUSED_CODE, Rcode.REFUSED.get_code())
+        self.assertEqual(Rcode.RESERVED15_CODE, Rcode.RESERVED15.get_code())
+        self.assertEqual(Rcode.BADVERS_CODE, Rcode.BADVERS.get_code())
 
     def test_get_code(self):
-        self.assertEqual(0, Rcode.NOERROR().get_code())
-        self.assertEqual(1, Rcode.FORMERR().get_code())
-        self.assertEqual(2, Rcode.SERVFAIL().get_code())
-        self.assertEqual(3, Rcode.NXDOMAIN().get_code())
-        self.assertEqual(4, Rcode.NOTIMP().get_code())
-        self.assertEqual(5, Rcode.REFUSED().get_code())
-        self.assertEqual(6, Rcode.YXDOMAIN().get_code())
-        self.assertEqual(7, Rcode.YXRRSET().get_code())
-        self.assertEqual(8, Rcode.NXRRSET().get_code())
-        self.assertEqual(9, Rcode.NOTAUTH().get_code())
-        self.assertEqual(10, Rcode.NOTZONE().get_code())
-        self.assertEqual(11, Rcode.RESERVED11().get_code())
-        self.assertEqual(12, Rcode.RESERVED12().get_code())
-        self.assertEqual(13, Rcode.RESERVED13().get_code())
-        self.assertEqual(14, Rcode.RESERVED14().get_code())
-        self.assertEqual(15, Rcode.RESERVED15().get_code())
-        self.assertEqual(16, Rcode.BADVERS().get_code())
+        self.assertEqual(0, Rcode.NOERROR.get_code())
+        self.assertEqual(1, Rcode.FORMERR.get_code())
+        self.assertEqual(2, Rcode.SERVFAIL.get_code())
+        self.assertEqual(3, Rcode.NXDOMAIN.get_code())
+        self.assertEqual(4, Rcode.NOTIMP.get_code())
+        self.assertEqual(5, Rcode.REFUSED.get_code())
+        self.assertEqual(6, Rcode.YXDOMAIN.get_code())
+        self.assertEqual(7, Rcode.YXRRSET.get_code())
+        self.assertEqual(8, Rcode.NXRRSET.get_code())
+        self.assertEqual(9, Rcode.NOTAUTH.get_code())
+        self.assertEqual(10, Rcode.NOTZONE.get_code())
+        self.assertEqual(11, Rcode.RESERVED11.get_code())
+        self.assertEqual(12, Rcode.RESERVED12.get_code())
+        self.assertEqual(13, Rcode.RESERVED13.get_code())
+        self.assertEqual(14, Rcode.RESERVED14.get_code())
+        self.assertEqual(15, Rcode.RESERVED15.get_code())
+        self.assertEqual(16, Rcode.BADVERS.get_code())
 
     def test_get_extended_code(self):
-        self.assertEqual(0, Rcode.NOERROR().get_extended_code())
-        self.assertEqual(0, Rcode.YXRRSET().get_extended_code())
-        self.assertEqual(1, Rcode.BADVERS().get_extended_code())
+        self.assertEqual(0, Rcode.NOERROR.get_extended_code())
+        self.assertEqual(0, Rcode.YXRRSET.get_extended_code())
+        self.assertEqual(1, Rcode.BADVERS.get_extended_code())
         self.assertEqual(0xab, Rcode(0xabf).get_extended_code())
         self.assertEqual(0xff, Rcode(0xfff).get_extended_code())
 
@@ -107,13 +107,13 @@ class RcodeTest(unittest.TestCase):
         self.assertEqual("RESERVED15", Rcode(15).to_text())
         self.assertEqual("BADVERS", Rcode(16).to_text())
         
-        self.assertEqual("17", Rcode(Rcode.BADVERS().get_code() + 1).to_text())
+        self.assertEqual("17", Rcode(Rcode.BADVERS.get_code() + 1).to_text())
         self.assertEqual("4095", Rcode(0xfff).to_text())
 
     def test_richcmp(self):
-        r1 = Rcode.NOERROR()
-        r2 = Rcode.FORMERR()
-        r3 = Rcode.FORMERR()
+        r1 = Rcode.NOERROR
+        r2 = Rcode.FORMERR
+        r3 = Rcode.FORMERR
         self.assertTrue(r2 == r3)
         self.assertTrue(r1 != r2)
         self.assertFalse(r1 == r2)

+ 10 - 10
src/lib/dns/python/tests/rrclass_python_test.py

@@ -23,8 +23,8 @@ from pydnspp import *
 
 class RRClassTest(unittest.TestCase):
     def setUp(self):
-        self.c1 = RRClass.IN()
-        self.c2 = RRClass.CH()
+        self.c1 = RRClass.IN
+        self.c2 = RRClass.CH
 
     def test_init(self):
         self.assertRaises(InvalidRRClass, RRClass, "wrong")
@@ -81,17 +81,17 @@ class RRClassTest(unittest.TestCase):
     def test_hash(self):
         # Exploiting the knowledge that the hash value is the numeric class
         # value, we can predict the comparison result.
-        self.assertEqual(hash(RRClass.IN()), hash(RRClass("IN")))
+        self.assertEqual(hash(RRClass.IN), hash(RRClass("IN")))
         self.assertEqual(hash(RRClass("in")), hash(RRClass("IN")))
-        self.assertNotEqual(hash(RRClass.IN()), hash(RRClass.CH()))
-        self.assertNotEqual(hash(RRClass.IN()), hash(RRClass("CLASS65535")))
+        self.assertNotEqual(hash(RRClass.IN), hash(RRClass.CH))
+        self.assertNotEqual(hash(RRClass.IN), hash(RRClass("CLASS65535")))
 
     def test_statics(self):
-        self.assertEqual(RRClass.IN(), RRClass("IN"))
-        self.assertEqual(RRClass.CH(), RRClass("CH"))
-        self.assertEqual(RRClass.HS(), RRClass("HS"))
-        self.assertEqual(254, RRClass.NONE().get_code())
-        self.assertEqual(255, RRClass.ANY().get_code())
+        self.assertEqual(RRClass.IN, RRClass("IN"))
+        self.assertEqual(RRClass.CH, RRClass("CH"))
+        self.assertEqual(RRClass.HS, RRClass("HS"))
+        self.assertEqual(254, RRClass.NONE.get_code())
+        self.assertEqual(255, RRClass.ANY.get_code())
 
 if __name__ == '__main__':
     unittest.main()

+ 23 - 23
src/lib/dns/python/tests/rrset_collection_python_test.py

@@ -34,64 +34,64 @@ class RRsetCollectionTest(unittest.TestCase):
         self.assertRaises(TypeError, RRsetCollection, 1)
         self.assertRaises(TypeError, RRsetCollection, # extra arg
                           b'example. 0 A 192.0.2.1',
-                          Name('example'), RRClass.IN(), 1)
+                          Name('example'), RRClass.IN, 1)
         self.assertRaises(TypeError, RRsetCollection, # incorrect order
-                          b'example. 0 A 192.0.2.1', RRClass.IN(),
+                          b'example. 0 A 192.0.2.1', RRClass.IN,
                           Name('example'))
 
         # constructor will result in C++ exception.
         self.assertRaises(IscException, RRsetCollection,
                           TESTDATA_DIR + '/no_such_file', Name('example.org'),
-                          RRClass.IN())
+                          RRClass.IN)
 
     def check_find_result(self, rrsets):
         # Commonly used check pattern
-        found = rrsets.find(Name('www.example.org'), RRClass.IN(), RRType.A())
+        found = rrsets.find(Name('www.example.org'), RRClass.IN, RRType.A)
         self.assertNotEqual(None, found)
         self.assertEqual(Name('www.example.org'), found.get_name())
-        self.assertEqual(RRClass.IN(), found.get_class())
-        self.assertEqual(RRType.A(), found.get_type())
+        self.assertEqual(RRClass.IN, found.get_class())
+        self.assertEqual(RRType.A, found.get_type())
         self.assertEqual('192.0.2.1', found.get_rdata()[0].to_text())
 
     def test_find(self):
         # Checking the underlying find() is called as intended, both for
         # success and failure cases, and with two different constructors.
         rrsets = RRsetCollection(TESTDATA_DIR + '/example.org',
-                                 Name('example.org'), RRClass.IN())
+                                 Name('example.org'), RRClass.IN)
         self.check_find_result(rrsets)
-        self.assertEqual(None, rrsets.find(Name('example.org'), RRClass.IN(),
-                                           RRType.A()))
+        self.assertEqual(None, rrsets.find(Name('example.org'), RRClass.IN,
+                                           RRType.A))
 
         rrsets = RRsetCollection(b'www.example.org. 3600 IN A 192.0.2.1',
-                                 Name('example.org'), RRClass.IN())
+                                 Name('example.org'), RRClass.IN)
         self.check_find_result(rrsets)
-        self.assertEqual(None, rrsets.find(Name('example.org'), RRClass.IN(),
-                                           RRType.A()))
+        self.assertEqual(None, rrsets.find(Name('example.org'), RRClass.IN,
+                                           RRType.A))
 
     def test_find_badargs(self):
         rrsets = RRsetCollection()
 
         # Check bad arguments: bad types
-        self.assertRaises(TypeError, rrsets.find, 1, RRClass.IN(), RRType.A())
+        self.assertRaises(TypeError, rrsets.find, 1, RRClass.IN, RRType.A)
         self.assertRaises(TypeError, rrsets.find, Name('example'), 1,
-                          RRType.A())
+                          RRType.A)
         self.assertRaises(TypeError, rrsets.find, Name('example'), 1,
-                          RRType.A())
+                          RRType.A)
         self.assertRaises(TypeError, rrsets.find, Name('example'),
-                          RRClass.IN(), 1)
-        self.assertRaises(TypeError, rrsets.find, Name('example'), RRType.A(),
-                          RRClass.IN())
+                          RRClass.IN, 1)
+        self.assertRaises(TypeError, rrsets.find, Name('example'), RRType.A,
+                          RRClass.IN)
 
         # Check bad arguments: too many/few arguments
         self.assertRaises(TypeError, rrsets.find, Name('example'),
-                          RRClass.IN(), RRType.A(), 0)
+                          RRClass.IN, RRType.A, 0)
         self.assertRaises(TypeError, rrsets.find, Name('example'),
-                          RRClass.IN())
+                          RRClass.IN)
 
     def test_add_remove_rrset(self):
         name = Name('www.example.org')
-        rrclass = RRClass.IN()
-        rrtype = RRType.A()
+        rrclass = RRClass.IN
+        rrtype = RRType.A
 
         # Create a collection with no RRsets
         rrsets = RRsetCollection()
@@ -134,7 +134,7 @@ class RRsetCollectionTest(unittest.TestCase):
                 pass
         rrsets = EmptyRRsetCollection()
         self.assertRaises(TypeError, rrsets.find, Name('www.example.org'),
-                          RRClass.IN(), RRType.A())
+                          RRClass.IN, RRType.A)
 
 if __name__ == '__main__':
     unittest.main()

+ 22 - 22
src/lib/dns/python/tests/rrtype_python_test.py

@@ -119,35 +119,35 @@ class TestModuleSpec(unittest.TestCase):
     def test_hash(self):
         # Exploiting the knowledge that the hash value is the numeric class
         # value, we can predict the comparison result.
-        self.assertEqual(hash(RRType.AAAA()), hash(RRType("AAAA")))
+        self.assertEqual(hash(RRType.AAAA), hash(RRType("AAAA")))
         self.assertEqual(hash(RRType("aaaa")), hash(RRType("AAAA")))
         self.assertEqual(hash(RRType(28)), hash(RRType("AAAA")))
-        self.assertNotEqual(hash(RRType.A()), hash(RRType.NS()))
-        self.assertNotEqual(hash(RRType.AAAA()), hash(RRType("Type65535")))
+        self.assertNotEqual(hash(RRType.A), hash(RRType.NS))
+        self.assertNotEqual(hash(RRType.AAAA), hash(RRType("Type65535")))
 
     def test_statics(self):
-        self.assertEqual(RRType("NSEC3PARAM"), RRType.NSEC3PARAM())
-        self.assertEqual(RRType("DNAME"), RRType.DNAME())
-        self.assertEqual(RRType("PTR"), RRType.PTR())
-        self.assertEqual(RRType("MX"), RRType.MX())
-        self.assertEqual(RRType("DNSKEY"), RRType.DNSKEY())
-        self.assertEqual(RRType("TXT"), RRType.TXT())
-        self.assertEqual(RRType("RRSIG"), RRType.RRSIG())
-        self.assertEqual(RRType("NSEC"), RRType.NSEC())
-        self.assertEqual(RRType("AAAA"), RRType.AAAA())
-        self.assertEqual(RRType("DS"), RRType.DS())
-        self.assertEqual(RRType("OPT"), RRType.OPT())
-        self.assertEqual(RRType("A"), RRType.A())
-        self.assertEqual(RRType("NS"), RRType.NS())
-        self.assertEqual(RRType("CNAME"), RRType.CNAME())
-        self.assertEqual(RRType("SOA"), RRType.SOA())
-        self.assertEqual(RRType("NSEC3"), RRType.NSEC3())
+        self.assertEqual(RRType("NSEC3PARAM"), RRType.NSEC3PARAM)
+        self.assertEqual(RRType("DNAME"), RRType.DNAME)
+        self.assertEqual(RRType("PTR"), RRType.PTR)
+        self.assertEqual(RRType("MX"), RRType.MX)
+        self.assertEqual(RRType("DNSKEY"), RRType.DNSKEY)
+        self.assertEqual(RRType("TXT"), RRType.TXT)
+        self.assertEqual(RRType("RRSIG"), RRType.RRSIG)
+        self.assertEqual(RRType("NSEC"), RRType.NSEC)
+        self.assertEqual(RRType("AAAA"), RRType.AAAA)
+        self.assertEqual(RRType("DS"), RRType.DS)
+        self.assertEqual(RRType("OPT"), RRType.OPT)
+        self.assertEqual(RRType("A"), RRType.A)
+        self.assertEqual(RRType("NS"), RRType.NS)
+        self.assertEqual(RRType("CNAME"), RRType.CNAME)
+        self.assertEqual(RRType("SOA"), RRType.SOA)
+        self.assertEqual(RRType("NSEC3"), RRType.NSEC3)
 
         # these can't be built with string input
         # (see the original cpp TODO)
-        self.assertEqual(251, RRType.IXFR().get_code())
-        self.assertEqual(252, RRType.AXFR().get_code())
-        self.assertEqual(255, RRType.ANY().get_code())
+        self.assertEqual(251, RRType.IXFR.get_code())
+        self.assertEqual(252, RRType.AXFR.get_code())
+        self.assertEqual(255, RRType.ANY.get_code())
         
 if __name__ == '__main__':
     unittest.main()

+ 18 - 18
src/lib/dns/python/tests/tsig_python_test.py

@@ -40,7 +40,7 @@ class TSIGContextTest(unittest.TestCase):
         self.keyring = TSIGKeyRing()
         self.message = Message(Message.RENDER)
         self.renderer = MessageRenderer()
-        self.test_class = RRClass.IN()
+        self.test_class = RRClass.IN
         self.test_ttl = RRTTL(86400)
         self.secret = base64.b64decode(b"SFuWd/q99SzF8Yzd1QbB9g==")
         self.tsig_ctx = TSIGContext(TSIGKey(self.test_name,
@@ -59,12 +59,12 @@ class TSIGContextTest(unittest.TestCase):
     # Note: intentionally use camelCase so that we can easily copy-paste
     # corresponding C++ tests.
     def createMessageAndSign(self, id, qname, ctx, message_flags=RD_FLAG,
-                             qtype=RRType.A(), answer_data=None,
+                             qtype=RRType.A, answer_data=None,
                              answer_type=None, add_question=True,
-                             rcode=Rcode.NOERROR()):
+                             rcode=Rcode.NOERROR):
         self.message.clear(Message.RENDER)
         self.message.set_qid(id)
-        self.message.set_opcode(Opcode.QUERY())
+        self.message.set_opcode(Opcode.QUERY)
         self.message.set_rcode(rcode)
         if (message_flags & QR_FLAG) != 0:
             self.message.set_header_flag(Message.HEADERFLAG_QR)
@@ -120,7 +120,7 @@ class TSIGContextTest(unittest.TestCase):
         self.assertEqual(TSIGContext.STATE_INIT, self.tsig_ctx.get_state())
 
         # And there should be no error code.
-        self.assertEqual(TSIGError(Rcode.NOERROR()), self.tsig_ctx.get_error())
+        self.assertEqual(TSIGError(Rcode.NOERROR), self.tsig_ctx.get_error())
 
         # No message signed yet
         self.assertRaises(TSIGContextError, self.tsig_ctx.last_had_signature)
@@ -249,7 +249,7 @@ class TSIGContextTest(unittest.TestCase):
         tsig = self.createMessageAndSign(self.qid, self.test_name,
                                          self.tsig_verify_ctx,
                                          QR_FLAG|AA_FLAG|RD_FLAG,
-                                         RRType.A(), "192.0.2.1")
+                                         RRType.A, "192.0.2.1")
 
         expected_mac = b"\x8f\xcd\xa6\x6a\x7c\xd1\xa3\xb9\x94\x8e\xb1\x86" + \
             b"\x9d\x38\x4a\x9f"
@@ -280,7 +280,7 @@ class TSIGContextTest(unittest.TestCase):
         zone_name = Name("example.com")
 
         tsig = self.createMessageAndSign(axfr_qid, zone_name, self.tsig_ctx,
-                                         0, RRType.AXFR())
+                                         0, RRType.AXFR)
 
         received_data = read_wire_data("tsig_verify1.wire")
         self.commonVerifyChecks(self.tsig_verify_ctx, tsig, received_data,
@@ -289,10 +289,10 @@ class TSIGContextTest(unittest.TestCase):
 
         tsig = self.createMessageAndSign(axfr_qid, zone_name,
                                          self.tsig_verify_ctx,
-                                         AA_FLAG|QR_FLAG, RRType.AXFR(),
+                                         AA_FLAG|QR_FLAG, RRType.AXFR,
                                          "ns.example.com. root.example.com." +\
                                          " 2011041503 7200 3600 2592000 1200",
-                                         RRType.SOA())
+                                         RRType.SOA)
 
         received_data = read_wire_data("tsig_verify2.wire")
         self.commonVerifyChecks(self.tsig_ctx, tsig, received_data,
@@ -302,8 +302,8 @@ class TSIGContextTest(unittest.TestCase):
             b"\x60\x34\x13\x09\x68"
         tsig = self.createMessageAndSign(axfr_qid, zone_name,
                                          self.tsig_verify_ctx,
-                                         AA_FLAG|QR_FLAG, RRType.AXFR(),
-                                         "ns.example.com.", RRType.NS(),
+                                         AA_FLAG|QR_FLAG, RRType.AXFR,
+                                         "ns.example.com.", RRType.NS,
                                          False)
         self.commonSignChecks(tsig, axfr_qid, 0x4da8e951, expected_mac)
 
@@ -316,7 +316,7 @@ class TSIGContextTest(unittest.TestCase):
 
         test_qid = 0x7fc4
         tsig = self.createMessageAndSign(test_qid, self.test_name,
-                                         self.tsig_ctx, 0, RRType.SOA())
+                                         self.tsig_ctx, 0, RRType.SOA)
 
         # "advance the clock" and try validating, which should fail due to
         # BADTIME
@@ -328,8 +328,8 @@ class TSIGContextTest(unittest.TestCase):
         # make and sign a response in the context of TSIG error.
         tsig = self.createMessageAndSign(test_qid, self.test_name,
                                          self.tsig_verify_ctx,
-                                         QR_FLAG, RRType.SOA(), None, None,
-                                         True, Rcode.NOTAUTH())
+                                         QR_FLAG, RRType.SOA, None, None,
+                                         True, Rcode.NOTAUTH)
 
         expected_otherdata = b"\x00\x00\x4d\xa8\xbe\x86"
         expected_mac = b"\xd4\xb0\x43\xf6\xf4\x44\x95\xec\x8a\x01\x26" +\
@@ -344,7 +344,7 @@ class TSIGContextTest(unittest.TestCase):
         fix_current_time(0x4da8b9d6)
 
         tsig = self.createMessageAndSign(self.qid, self.test_name,
-                                         self.tsig_ctx, 0, RRType.SOA())
+                                         self.tsig_ctx, 0, RRType.SOA)
 
         # "rewind the clock" and try validating, which should fail due to
         # BADTIME
@@ -361,7 +361,7 @@ class TSIGContextTest(unittest.TestCase):
         fix_current_time(0x4da8b9d6)
 
         tsig = self.createMessageAndSign(self.qid, self.test_name,
-                                         self.tsig_ctx, 0, RRType.SOA())
+                                         self.tsig_ctx, 0, RRType.SOA)
 
         fix_current_time(0x4da8b9d6 + 301)
         self.assertEqual(TSIGError.BAD_TIME,
@@ -382,7 +382,7 @@ class TSIGContextTest(unittest.TestCase):
     def test_badtime_overflow(self):
         fix_current_time(200)
         tsig = self.createMessageAndSign(self.qid, self.test_name,
-                                         self.tsig_ctx, 0, RRType.SOA())
+                                         self.tsig_ctx, 0, RRType.SOA)
 
         # This should be in the okay range, but since "200 - fudge" overflows
         # and we compare them as 64-bit unsigned integers, it results in a
@@ -522,7 +522,7 @@ class TSIGContextTest(unittest.TestCase):
                          self.tsig_verify_ctx.get_state())
         self.createMessageAndSign(self.qid, self.test_name,
                                   self.tsig_verify_ctx,
-                                  QR_FLAG|AA_FLAG|RD_FLAG, RRType.A(),
+                                  QR_FLAG|AA_FLAG|RD_FLAG, RRType.A,
                                   "192.0.2.1")
         self.assertEqual(TSIGContext.STATE_SENT_RESPONSE,
                          self.tsig_verify_ctx.get_state())

+ 13 - 13
src/lib/dns/python/tests/tsigerror_python_test.py

@@ -28,7 +28,7 @@ class TSIGErrorTest(unittest.TestCase):
 
     def test_from_rcode(self):
         # We use RCODE for code values from 0-15.
-        self.assertEqual(0, TSIGError(Rcode.NOERROR()).get_code())
+        self.assertEqual(0, TSIGError(Rcode.NOERROR).get_code())
         self.assertEqual(15, TSIGError(Rcode(15)).get_code())
 
         # From error code 16 TSIG errors define a separate space, so passing
@@ -50,19 +50,19 @@ class TSIGErrorTest(unittest.TestCase):
         self.assertEqual(TSIGError.BAD_TIME_CODE, TSIGError.BAD_TIME.get_code())
 
     def test_equal(self):
-        self.assertTrue(TSIGError.NOERROR == TSIGError(Rcode.NOERROR()))
-        self.assertTrue(TSIGError(Rcode.NOERROR()) == TSIGError.NOERROR)
+        self.assertTrue(TSIGError.NOERROR == TSIGError(Rcode.NOERROR))
+        self.assertTrue(TSIGError(Rcode.NOERROR) == TSIGError.NOERROR)
 
         self.assertTrue(TSIGError.BAD_SIG == TSIGError(16))
         self.assertTrue(TSIGError(16) == TSIGError.BAD_SIG)
 
     def test_nequal(self):
-        self.assertTrue(TSIGError.BAD_KEY != TSIGError(Rcode.NOERROR()))
-        self.assertTrue(TSIGError(Rcode.NOERROR()) != TSIGError.BAD_KEY)
+        self.assertTrue(TSIGError.BAD_KEY != TSIGError(Rcode.NOERROR))
+        self.assertTrue(TSIGError(Rcode.NOERROR) != TSIGError.BAD_KEY)
 
     def test_to_text(self):
         # TSIGError derived from the standard Rcode
-        self.assertEqual("NOERROR", TSIGError(Rcode.NOERROR()).to_text())
+        self.assertEqual("NOERROR", TSIGError(Rcode.NOERROR).to_text())
 
         # Well known TSIG errors
         self.assertEqual("BADSIG", TSIGError.BAD_SIG.to_text())
@@ -74,21 +74,21 @@ class TSIGErrorTest(unittest.TestCase):
         self.assertEqual("65535", TSIGError(65535).to_text());
 
         # also check str() works same way
-        self.assertEqual("NOERROR", str(TSIGError(Rcode.NOERROR())))
+        self.assertEqual("NOERROR", str(TSIGError(Rcode.NOERROR)))
         self.assertEqual("BADSIG", str(TSIGError.BAD_SIG))
 
     def test_to_rcode(self):
         # TSIGError derived from the standard Rcode
-        self.assertEqual(Rcode.NOERROR(), TSIGError(Rcode.NOERROR()).to_rcode())
+        self.assertEqual(Rcode.NOERROR, TSIGError(Rcode.NOERROR).to_rcode())
 
         # Well known TSIG errors
-        self.assertEqual(Rcode.NOTAUTH(), TSIGError.BAD_SIG.to_rcode())
-        self.assertEqual(Rcode.NOTAUTH(), TSIGError.BAD_KEY.to_rcode())
-        self.assertEqual(Rcode.NOTAUTH(), TSIGError.BAD_TIME.to_rcode())
+        self.assertEqual(Rcode.NOTAUTH, TSIGError.BAD_SIG.to_rcode())
+        self.assertEqual(Rcode.NOTAUTH, TSIGError.BAD_KEY.to_rcode())
+        self.assertEqual(Rcode.NOTAUTH, TSIGError.BAD_TIME.to_rcode())
 
         # Unknown (or not yet supported) codes are treated as SERVFAIL.
-        self.assertEqual(Rcode.SERVFAIL(), TSIGError(19).to_rcode())
-        self.assertEqual(Rcode.SERVFAIL(), TSIGError(65535).to_rcode())
+        self.assertEqual(Rcode.SERVFAIL, TSIGError(19).to_rcode())
+        self.assertEqual(Rcode.SERVFAIL, TSIGError(65535).to_rcode())
 
         # Check there's no redundant refcount (which would cause leak)
         self.assertEqual(1, sys.getrefcount(TSIGError.BAD_SIG.to_rcode()))

+ 29 - 32
src/lib/dns/python/tests/zone_checker_python_test.py

@@ -35,8 +35,8 @@ class ZoneCheckerTest(unittest.TestCase):
         rrsets = RRsetCollection(b'example.org. 0 SOA . . 0 0 0 0 0\n' +
                                  b'example.org. 0 NS ns.example.org.\n' +
                                  b'ns.example.org. 0 A 192.0.2.1\n',
-                                 Name('example.org'), RRClass.IN())
-        self.assertTrue(check_zone(Name('example.org'), RRClass.IN(),
+                                 Name('example.org'), RRClass.IN)
+        self.assertTrue(check_zone(Name('example.org'), RRClass.IN,
                                    rrsets,
                                    (lambda r: self.__callback(r, errors),
                                     lambda r: self.__callback(r, warns))))
@@ -45,8 +45,8 @@ class ZoneCheckerTest(unittest.TestCase):
 
         # Check fails and one additional warning.
         rrsets = RRsetCollection(b'example.org. 0 NS ns.example.org.',
-                                 Name('example.org'), RRClass.IN())
-        self.assertFalse(check_zone(Name('example.org'), RRClass.IN(), rrsets,
+                                 Name('example.org'), RRClass.IN)
+        self.assertFalse(check_zone(Name('example.org'), RRClass.IN, rrsets,
                                     (lambda r: self.__callback(r, errors),
                                      lambda r: self.__callback(r, warns))))
         self.assertEqual(['zone example.org/IN: has 0 SOA records'], errors)
@@ -56,7 +56,7 @@ class ZoneCheckerTest(unittest.TestCase):
         # Same RRset collection, suppressing callbacks
         errors = []
         warns = []
-        self.assertFalse(check_zone(Name('example.org'), RRClass.IN(), rrsets,
+        self.assertFalse(check_zone(Name('example.org'), RRClass.IN, rrsets,
                                     (None, None)))
         self.assertEqual([], errors)
         self.assertEqual([], warns)
@@ -64,29 +64,29 @@ class ZoneCheckerTest(unittest.TestCase):
     def test_check_badarg(self):
         rrsets = RRsetCollection()
         # Bad types
-        self.assertRaises(TypeError, check_zone, 1, RRClass.IN(), rrsets,
+        self.assertRaises(TypeError, check_zone, 1, RRClass.IN, rrsets,
                           (None, None))
         self.assertRaises(TypeError, check_zone, Name('example'), 1, rrsets,
                           (None, None))
-        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN(),
+        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN,
                           1, (None, None))
-        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN(),
+        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN,
                           rrsets, 1)
 
         # Bad callbacks
-        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN(),
+        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN,
                           rrsets, (None, None, None))
-        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN(),
+        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN,
                           rrsets, (1, None))
-        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN(),
+        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN,
                           rrsets, (None, 1))
 
         # Extra/missing args
-        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN(),
+        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN,
                           rrsets, (None, None), 1)
-        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN(),
+        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN,
                           rrsets)
-        check_zone(Name('example'), RRClass.IN(), rrsets, (None, None))
+        check_zone(Name('example'), RRClass.IN, rrsets, (None, None))
 
     def test_check_callback_fail(self):
         # Let the call raise a Python exception.  It should be propagated to
@@ -96,7 +96,7 @@ class ZoneCheckerTest(unittest.TestCase):
 
         # Using an empty collection, triggering an error callback.
         self.assertRaises(FakeException, check_zone, Name('example.org'),
-                          RRClass.IN(), RRsetCollection(),
+                          RRClass.IN, RRsetCollection(),
                           (__bad_callback, None))
 
         # An unusual case: the callback is expected to return None, but if it
@@ -108,7 +108,7 @@ class ZoneCheckerTest(unittest.TestCase):
 
         ref_checker = RefChecker()
         orig_refcnt = sys.getrefcount(ref_checker)
-        check_zone(Name('example.org'), RRClass.IN(), RRsetCollection(),
+        check_zone(Name('example.org'), RRClass.IN, RRsetCollection(),
                    (lambda r: __callback(r, ref_checker), None))
         self.assertEqual(orig_refcnt, sys.getrefcount(ref_checker))
 
@@ -132,48 +132,45 @@ class ZoneCheckerTest(unittest.TestCase):
                     raise FakeException('find error')
                 if self.__find_result is not 'use_default':
                     return self.__find_result
-                if rrtype == RRType.SOA():
-                    soa = RRset(Name('example'), RRClass.IN(), rrtype,
-                                RRTTL(0))
-                    soa.add_rdata(Rdata(RRType.SOA(), RRClass.IN(),
+                if rrtype == RRType.SOA:
+                    soa = RRset(Name('example'), RRClass.IN, rrtype, RRTTL(0))
+                    soa.add_rdata(Rdata(RRType.SOA, RRClass.IN,
                                         '. . 0 0 0 0 0'))
                     return soa
-                if rrtype == RRType.NS():
-                    ns = RRset(Name('example'), RRClass.IN(), rrtype,
-                               RRTTL(0))
-                    ns.add_rdata(Rdata(RRType.NS(), RRClass.IN(),
-                                       'example.org.'))
+                if rrtype == RRType.NS:
+                    ns = RRset(Name('example'), RRClass.IN, rrtype, RRTTL(0))
+                    ns.add_rdata(Rdata(RRType.NS, RRClass.IN, 'example.org.'))
                     return ns
                 return None
 
         # A successful case.  Just checking it works in that case.
         rrsets = FakeRRsetCollection()
-        self.assertTrue(check_zone(Name('example'), RRClass.IN(), rrsets,
+        self.assertTrue(check_zone(Name('example'), RRClass.IN, rrsets,
                                    (None, None)))
 
         # Likewise, normal case but zone check fails.
         rrsets = FakeRRsetCollection(False, None)
-        self.assertFalse(check_zone(Name('example'), RRClass.IN(), rrsets,
+        self.assertFalse(check_zone(Name('example'), RRClass.IN, rrsets,
                                     (None, None)))
 
         # Our find() returns a bad type of result.
         rrsets = FakeRRsetCollection(False, 1)
-        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN(),
+        self.assertRaises(TypeError, check_zone, Name('example'), RRClass.IN,
                           rrsets, (None, None))
 
         # Our find() returns an empty SOA RRset.  C++ zone checker code
         # throws, which results in IscException.
         rrsets = FakeRRsetCollection(False, RRset(Name('example'),
-                                                  RRClass.IN(),
-                                                  RRType.SOA(), RRTTL(0)))
+                                                  RRClass.IN,
+                                                  RRType.SOA, RRTTL(0)))
         self.assertRaises(IscException, check_zone, Name('example'),
-                          RRClass.IN(), rrsets, (None, None))
+                          RRClass.IN, rrsets, (None, None))
 
         # Our find() raises an exception.  That exception is propagated to
         # the top level.
         rrsets = FakeRRsetCollection(True)
         self.assertRaises(FakeException, check_zone, Name('example'),
-                          RRClass.IN(), rrsets, (None, None))
+                          RRClass.IN, rrsets, (None, None))
 
 if __name__ == '__main__':
     unittest.main()

+ 4 - 0
src/lib/dns/rdata/template.h

@@ -39,6 +39,10 @@
 // Note: do not remove the comment lines beginning with "BEGIN_" and "END_".
 // These are markers used by a script for auto-generating build-able source
 // files.
+//
+// On completion of implementing a new type of Rdata, remove the corresponding
+// entry from the meta_types dictionary of gen-rdatacode.py.in.  Otherwise
+// it will cause build failure.
 
 class MyType : public Rdata {
 public:

+ 0 - 14
src/lib/dns/rrclass-placeholder.h

@@ -294,28 +294,14 @@ public:
 
     // BEGIN_WELL_KNOWN_CLASS_DECLARATIONS
     // END_WELL_KNOWN_CLASS_DECLARATIONS
-    
-    static const RRClass& NONE();
 
 private:
-    // \brief Meta-classes
-    enum {
-        RRCLASS_RESERVED0 = 0,
-        RRCLASS_NONE = 254
-    };
     uint16_t classcode_;
 };
 
 // BEGIN_WELL_KNOWN_CLASS_DEFINITIONS
 // END_WELL_KNOWN_CLASS_DEFINITIONS
 
-inline const RRClass&
-RRClass::NONE() {
-    static RRClass rrclass(RRCLASS_NONE);
-
-    return (rrclass);
-}
-
 ///
 /// \brief Insert the \c RRClass as a string into stream.
 ///

+ 0 - 30
src/lib/dns/rrtype-placeholder.h

@@ -262,43 +262,13 @@ public:
     // BEGIN_WELL_KNOWN_TYPE_DECLARATIONS
     // END_WELL_KNOWN_TYPE_DECLARATIONS
 
-    static const RRType& IXFR();
-    static const RRType& AXFR();
-    static const RRType& ANY();
-
 private:
-    // \brief Meta-classes
-    // XXX: these should be implemented using rrparamregistry
-    enum {
-        RRTYPE_IXFR = 251,
-        RRTYPE_AXFR = 252,
-        RRTYPE_ANY = 255
-    };
-
     uint16_t typecode_;
 };
 
 // BEGIN_WELL_KNOWN_TYPE_DEFINITIONS
 // END_WELL_KNOWN_TYPE_DEFINITIONS
 
-inline const RRType&
-RRType::IXFR() {
-    static RRType rrtype(RRTYPE_IXFR);
-    return (rrtype);
-}
-
-inline const RRType&
-RRType::AXFR() {
-    static RRType rrtype(RRTYPE_AXFR);
-    return (rrtype);
-}
-
-inline const RRType&
-RRType::ANY() {
-    static RRType rrtype(RRTYPE_ANY);
-    return (rrtype);
-}
-
 ///
 /// \brief Insert the \c RRType as a string into stream.
 ///

+ 25 - 0
src/lib/dns/tests/rrclass_unittest.cc

@@ -148,4 +148,29 @@ TEST_F(RRClassTest, LeftShiftOperator) {
     oss << RRClass::IN();
     EXPECT_EQ(RRClass::IN().toText(), oss.str());
 }
+
+// Below, we'll check definitions for all well-known RR classes; whether they
+// are defined and have the correct parameter values.  Test data are generated
+// from the list available at:
+// http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
+struct ClassParam {
+    const char* const txt;      // "IN", "CH", etc
+    const uint16_t code;        // 1, 3,
+    const RRClass& (*obj)();     // RRClass::IN(), etc
+} known_classes[] = {
+    {"IN", 1, RRClass::IN}, {"CH", 3, RRClass::CH}, {"HS", 4, RRClass::HS},
+    {"NONE", 254, RRClass::NONE}, {"ANY", 255, RRClass::ANY},
+    {NULL, 0, NULL}
+};
+
+TEST(RRClassConstTest, wellKnowns) {
+    for (int i = 0; known_classes[i].txt; ++i) {
+        SCOPED_TRACE("Checking well known RRClass: " +
+                     string(known_classes[i].txt));
+        EXPECT_EQ(known_classes[i].code,
+                  RRClass(known_classes[i].txt).getCode());
+        EXPECT_EQ(known_classes[i].code,
+                  (*known_classes[i].obj)().getCode());
+    }
+}
 }

+ 1 - 1
src/lib/dns/tests/rrset_unittest.cc

@@ -205,7 +205,7 @@ TEST_F(RRsetTest, toText) {
     // Unless it is type ANY or NONE
     EXPECT_EQ("test.example.com. 3600 ANY A\n",
               rrset_any_a_empty.toText());
-    EXPECT_EQ("test.example.com. 3600 CLASS254 A\n",
+    EXPECT_EQ("test.example.com. 3600 NONE A\n",
               rrset_none_a_empty.toText());
 }
 

+ 53 - 0
src/lib/dns/tests/rrtype_unittest.cc

@@ -145,4 +145,57 @@ TEST_F(RRTypeTest, LeftShiftOperator) {
     oss << RRType::A();
     EXPECT_EQ(RRType::A().toText(), oss.str());
 }
+
+// Below, we'll check definitions for all well-known RR types; whether they
+// are defined and have the correct parameter values.  Test data are generated
+// from the list available at:
+// http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
+struct TypeParam {
+    const char* const txt;      // "A", "AAAA", "NS", etc
+    const uint16_t code;        // 1, 28, 2, etc
+    const RRType& (*obj)();     // RRType::A(), etc
+} known_types[] = {
+    {"A", 1, RRType::A}, {"NS", 2, RRType::NS}, {"MD", 3, RRType::MD},
+    {"MF", 4, RRType::MF}, {"CNAME", 5, RRType::CNAME},
+    {"SOA", 6, RRType::SOA}, {"MB", 7, RRType::MB}, {"MG", 8, RRType::MG},
+    {"MR", 9, RRType::MR}, {"NULL", 10, RRType::Null},
+    {"WKS", 11, RRType::WKS}, {"PTR", 12, RRType::PTR},
+    {"HINFO", 13, RRType::HINFO}, {"MINFO", 14, RRType::MINFO},
+    {"MX", 15, RRType::MX}, {"TXT", 16, RRType::TXT}, {"RP", 17, RRType::RP},
+    {"AFSDB", 18, RRType::AFSDB}, {"X25", 19, RRType::X25},
+    {"ISDN", 20, RRType::ISDN}, {"RT", 21, RRType::RT},
+    {"NSAP", 22, RRType::NSAP}, {"NSAP-PTR", 23, RRType::NSAP_PTR},
+    {"SIG", 24, RRType::SIG}, {"KEY", 25, RRType::KEY},
+    {"PX", 26, RRType::PX}, {"GPOS", 27, RRType::GPOS},
+    {"AAAA", 28, RRType::AAAA}, {"LOC", 29, RRType::LOC},
+    {"NXT", 30, RRType::NXT}, {"SRV", 33, RRType::SRV},
+    {"NAPTR", 35, RRType::NAPTR}, {"KX", 36, RRType::KX},
+    {"CERT", 37, RRType::CERT}, {"A6", 38, RRType::A6},
+    {"DNAME", 39, RRType::DNAME}, {"OPT", 41, RRType::OPT},
+    {"APL", 42, RRType::APL}, {"DS", 43, RRType::DS},
+    {"SSHFP", 44, RRType::SSHFP}, {"IPSECKEY", 45, RRType::IPSECKEY},
+    {"RRSIG", 46, RRType::RRSIG}, {"NSEC", 47, RRType::NSEC},
+    {"DNSKEY", 48, RRType::DNSKEY}, {"DHCID", 49, RRType::DHCID},
+    {"NSEC3", 50, RRType::NSEC3}, {"NSEC3PARAM", 51, RRType::NSEC3PARAM},
+    {"TLSA", 52, RRType::TLSA}, {"HIP", 55, RRType::HIP},
+    {"SPF", 99, RRType::SPF}, {"UNSPEC", 103, RRType::UNSPEC},
+    {"NID", 104, RRType::NID}, {"L32", 105, RRType::L32},
+    {"L64", 106, RRType::L64}, {"LP", 107, RRType::LP},
+    {"TKEY", 249, RRType::TKEY}, {"TSIG", 250, RRType::TSIG},
+    {"IXFR", 251, RRType::IXFR}, {"AXFR", 252, RRType::AXFR},
+    {"MAILB", 253, RRType::MAILB}, {"MAILA", 254, RRType::MAILA},
+    {"ANY", 255, RRType::ANY}, {"URI", 256, RRType::URI},
+    {"CAA", 257, RRType::CAA}, {"DLV", 32769, RRType::DLV},
+    {NULL, 0, NULL}
+};
+
+TEST(RRTypeConstTest, wellKnowns) {
+    for (int i = 0; known_types[i].txt; ++i) {
+        SCOPED_TRACE("Checking well known RRType: " +
+                     string(known_types[i].txt));
+        EXPECT_EQ(known_types[i].code, RRType(known_types[i].txt).getCode());
+        EXPECT_EQ(known_types[i].code,
+                  (*known_types[i].obj)().getCode());
+    }
+}
 }

+ 3 - 7
src/lib/python/isc/__init__.py

@@ -1,7 +1,3 @@
-# On some systems, it appears the dynamic linker gets
-# confused if the order is not right here
-# There is probably a solution for this, but for now:
-# order is important here!
-import isc.cc
-import isc.config
-import isc.datasrc
+"""
+This is the top directory for common BIND 10 Python modules and packages.
+"""

+ 5 - 5
src/lib/python/isc/datasrc/tests/clientlist_test.py

@@ -43,8 +43,8 @@ class ClientListTest(unittest.TestCase):
         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())
+        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
@@ -52,7 +52,7 @@ class ClientListTest(unittest.TestCase):
         self.assertRaises(TypeError, isc.datasrc.ConfigurableClientList, "IN")
         # Too many arguments
         self.assertRaises(TypeError, isc.datasrc.ConfigurableClientList,
-                         isc.dns.RRClass.IN(), isc.dns.RRClass.IN())
+                         isc.dns.RRClass.IN, isc.dns.RRClass.IN)
 
     def test_configure(self):
         """
@@ -60,7 +60,7 @@ class ClientListTest(unittest.TestCase):
         ones are acceptend and invalid rejected. We check the changes
         have effect.
         """
-        self.clist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.IN())
+        self.clist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.IN)
         # This should be NOP now
         self.clist.configure("[]", True)
         # Check the zone is not there yet
@@ -102,7 +102,7 @@ class ClientListTest(unittest.TestCase):
         Test the find accepts the right arguments, some of them can be omitted,
         etc.
         """
-        self.clist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.IN())
+        self.clist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.IN)
         self.clist.configure('''[{
             "type": "MasterFiles",
             "params": {

+ 70 - 70
src/lib/python/isc/datasrc/tests/datasrc_test.py

@@ -51,8 +51,8 @@ def check_for_rrset(expected_rrsets, rrset):
     return False
 
 def create_soa(serial):
-    soa = RRset(Name('example.org'), RRClass.IN(), RRType.SOA(), RRTTL(3600))
-    soa.add_rdata(Rdata(RRType.SOA(), RRClass.IN(),
+    soa = RRset(Name('example.org'), RRClass.IN, RRType.SOA, RRTTL(3600))
+    soa.add_rdata(Rdata(RRType.SOA, RRClass.IN,
                         'ns1.example.org. admin.example.org. ' +
                         str(serial) + ' 3600 1800 2419200 7200'))
     return soa
@@ -66,13 +66,13 @@ def test_findall_common(self, tested):
     result, rrset, _ = tested.find_all(isc.dns.Name("www.sql1.example.com"),
                                        ZoneFinder.FIND_DEFAULT)
     self.assertEqual(ZoneFinder.DELEGATION, result)
-    expected = RRset(Name('sql1.example.com.'), RRClass.IN(), RRType.NS(),
+    expected = RRset(Name('sql1.example.com.'), RRClass.IN, RRType.NS,
                      RRTTL(3600))
-    expected.add_rdata(Rdata(RRType.NS(), RRClass.IN(),
+    expected.add_rdata(Rdata(RRType.NS, RRClass.IN,
                              'dns01.example.com.'))
-    expected.add_rdata(Rdata(RRType.NS(), RRClass.IN(),
+    expected.add_rdata(Rdata(RRType.NS, RRClass.IN,
                              'dns02.example.com.'))
-    expected.add_rdata(Rdata(RRType.NS(), RRClass.IN(),
+    expected.add_rdata(Rdata(RRType.NS, RRClass.IN,
                              'dns03.example.com.'))
     self.assertTrue(rrsets_equal(expected, rrset))
 
@@ -88,16 +88,16 @@ def test_findall_common(self, tested):
     self.assertEqual(2, len(rrsets))
     rrsets.sort(key=lambda rrset: rrset.get_type().to_text())
     expected = [
-        RRset(Name('mix.example.com.'), RRClass.IN(), RRType.A(),
+        RRset(Name('mix.example.com.'), RRClass.IN, RRType.A,
               RRTTL(3600)),
-        RRset(Name('mix.example.com.'), RRClass.IN(), RRType.AAAA(),
+        RRset(Name('mix.example.com.'), RRClass.IN, RRType.AAAA,
               RRTTL(3600))
     ]
-    expected[0].add_rdata(Rdata(RRType.A(), RRClass.IN(), "192.0.2.1"))
-    expected[0].add_rdata(Rdata(RRType.A(), RRClass.IN(), "192.0.2.2"))
-    expected[1].add_rdata(Rdata(RRType.AAAA(), RRClass.IN(),
+    expected[0].add_rdata(Rdata(RRType.A, RRClass.IN, "192.0.2.1"))
+    expected[0].add_rdata(Rdata(RRType.A, RRClass.IN, "192.0.2.2"))
+    expected[1].add_rdata(Rdata(RRType.AAAA, RRClass.IN,
                                 "2001:db8::1"))
-    expected[1].add_rdata(Rdata(RRType.AAAA(), RRClass.IN(),
+    expected[1].add_rdata(Rdata(RRType.AAAA, RRClass.IN,
                                 "2001:db8::2"))
     for (rrset, exp) in zip(rrsets, expected):
         self.assertTrue(rrsets_equal(exp, rrset))
@@ -158,9 +158,9 @@ class DataSrcClient(unittest.TestCase):
         expected_rrset_list = []
 
         name = isc.dns.Name("sql1.example.com")
-        rrclass = isc.dns.RRClass.IN()
+        rrclass = isc.dns.RRClass.IN
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.DNSKEY(), isc.dns.RRTTL(3600),
+                  isc.dns.RRType.DNSKEY, isc.dns.RRTTL(3600),
                   [
                      "256 3 5 AwEAAdYdRhBAEY67R/8G1N5AjGF6asIiNh/pNGeQ8xDQP13J"+
                      "N2lo+sNqWcmpYNhuVqRbLB+mamsU1XcCICSBvAlSmfz/ZUdafX23knAr"+
@@ -168,7 +168,7 @@ class DataSrcClient(unittest.TestCase):
                      "5fs0dE/xLztL/CzZ"
                   ])
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.DNSKEY(), isc.dns.RRTTL(3600),
+                  isc.dns.RRType.DNSKEY, isc.dns.RRTTL(3600),
                   [
                      "257 3 5 AwEAAbaKDSa9XEFTsjSYpUTHRotTS9Tz3krfDucugW5UokGQ"+
                      "KC26QlyHXlPTZkC+aRFUs/dicJX2kopndLcnlNAPWiKnKtrsFSCnIJDB"+
@@ -179,22 +179,22 @@ class DataSrcClient(unittest.TestCase):
                      "jRWAzGsxJiJyjd6w2k0="
                   ])
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.NS(), isc.dns.RRTTL(3600),
+                  isc.dns.RRType.NS, isc.dns.RRTTL(3600),
                   [
                     "dns01.example.com."
                   ])
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.NS(), isc.dns.RRTTL(3600),
+                  isc.dns.RRType.NS, isc.dns.RRTTL(3600),
                   [
                     "dns02.example.com."
                   ])
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.NS(), isc.dns.RRTTL(3600),
+                  isc.dns.RRType.NS, isc.dns.RRTTL(3600),
                   [
                     "dns03.example.com."
                   ])
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.NSEC(), isc.dns.RRTTL(7200),
+                  isc.dns.RRType.NSEC, isc.dns.RRTTL(7200),
                   [
                      "www.sql1.example.com. NS SOA RRSIG NSEC DNSKEY"
                   ])
@@ -204,36 +204,36 @@ class DataSrcClient(unittest.TestCase):
         # Since we passed separate_rrs = True to get_iterator, we get several
         # sets of RRSIGs, one for each TTL
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+                  isc.dns.RRType.RRSIG, isc.dns.RRTTL(3600), None)
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+                  isc.dns.RRType.RRSIG, isc.dns.RRTTL(3600), None)
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+                  isc.dns.RRType.RRSIG, isc.dns.RRTTL(3600), None)
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+                  isc.dns.RRType.RRSIG, isc.dns.RRTTL(3600), None)
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(7200), None)
+                  isc.dns.RRType.RRSIG, isc.dns.RRTTL(7200), None)
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.SOA(), isc.dns.RRTTL(3600),
+                  isc.dns.RRType.SOA, isc.dns.RRTTL(3600),
                   [
                      "master.example.com. admin.example.com. 678 3600 1800 2419200 7200"
                   ])
         name = isc.dns.Name("www.sql1.example.com.")
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.A(), isc.dns.RRTTL(3600),
+                  isc.dns.RRType.A, isc.dns.RRTTL(3600),
                   [
                      "192.0.2.100"
                   ])
         name = isc.dns.Name("www.sql1.example.com.")
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.NSEC(), isc.dns.RRTTL(7200),
+                  isc.dns.RRType.NSEC, isc.dns.RRTTL(7200),
                   [
                      "sql1.example.com. A RRSIG NSEC"
                   ])
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(3600), None)
+                  isc.dns.RRType.RRSIG, isc.dns.RRTTL(3600), None)
         add_rrset(expected_rrset_list, name, rrclass,
-                  isc.dns.RRType.RRSIG(), isc.dns.RRTTL(7200), None)
+                  isc.dns.RRType.RRSIG, isc.dns.RRTTL(7200), None)
 
         # rrs is an iterator, but also has direct get_next_rrset(), use
         # the latter one here
@@ -287,11 +287,11 @@ class DataSrcClient(unittest.TestCase):
         dsc = isc.datasrc.DataSourceClient("sqlite3", READ_ZONE_DB_CONFIG)
         iterator = dsc.get_iterator(isc.dns.Name("sql1.example.com."))
         expected_soa = isc.dns.RRset(isc.dns.Name("sql1.example.com."),
-                                     isc.dns.RRClass.IN(),
-                                     isc.dns.RRType.SOA(),
+                                     isc.dns.RRClass.IN,
+                                     isc.dns.RRType.SOA,
                                      isc.dns.RRTTL(3600))
-        expected_soa.add_rdata(isc.dns.Rdata(isc.dns.RRType.SOA(),
-                                             isc.dns.RRClass.IN(),
+        expected_soa.add_rdata(isc.dns.Rdata(isc.dns.RRType.SOA,
+                                             isc.dns.RRClass.IN,
                                              "master.example.com. " +
                                              "admin.example.com. 678 " +
                                              "3600 1800 2419200 7200"))
@@ -337,7 +337,7 @@ class DataSrcClient(unittest.TestCase):
         result, finder = dsc.find_zone(isc.dns.Name("example.com"))
 
         self.assertEqual(finder.SUCCESS, result)
-        self.assertEqual(isc.dns.RRClass.IN(), finder.get_class())
+        self.assertEqual(isc.dns.RRClass.IN, finder.get_class())
         self.assertEqual("example.com.", finder.get_origin().to_text())
 
         test_findall_common(self, finder)
@@ -347,11 +347,11 @@ class DataSrcClient(unittest.TestCase):
 
         result, finder = dsc.find_zone(isc.dns.Name("example.com"))
         self.assertEqual(finder.SUCCESS, result)
-        self.assertEqual(isc.dns.RRClass.IN(), finder.get_class())
+        self.assertEqual(isc.dns.RRClass.IN, finder.get_class())
         self.assertEqual("example.com.", finder.get_origin().to_text())
 
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
@@ -359,13 +359,13 @@ class DataSrcClient(unittest.TestCase):
 
         # Check the optional parameters are optional
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A())
+                                       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.sql1.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.DELEGATION, result)
         self.assertEqual("sql1.example.com. 3600 IN NS dns01.example.com.\n" +
@@ -374,7 +374,7 @@ class DataSrcClient(unittest.TestCase):
                          rrset.to_text())
 
         result, rrset, _ = finder.find(isc.dns.Name("doesnotexist.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.NXDOMAIN, result)
         self.assertEqual(None, rrset)
@@ -382,16 +382,16 @@ class DataSrcClient(unittest.TestCase):
 
         self.assertRaises(isc.datasrc.OutOfZone, finder.find,
                           isc.dns.Name("www.some.other.domain"),
-                          isc.dns.RRType.A())
+                          isc.dns.RRType.A)
 
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.TXT(),
+                                       isc.dns.RRType.TXT,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.NXRRSET, result)
         self.assertEqual(None, rrset)
 
         result, rrset, _ = finder.find(isc.dns.Name("cname-ext.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.CNAME, result)
         self.assertEqual(
@@ -400,14 +400,14 @@ class DataSrcClient(unittest.TestCase):
 
         result, rrset, flags = \
             finder.find(isc.dns.Name("foo.wild.example.com"),
-                        isc.dns.RRType.A(), finder.FIND_DEFAULT)
+                        isc.dns.RRType.A, finder.FIND_DEFAULT)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual(finder.RESULT_WILDCARD, flags)
         self.assertEqual("foo.wild.example.com. 3600 IN A 192.0.2.255\n",
                          rrset.to_text())
 
         result, rrset, _ = finder.find(isc.dns.Name("foo.wild.example.com"),
-                                       isc.dns.RRType.TXT(),
+                                       isc.dns.RRType.TXT,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.NXRRSET, result)
         self.assertTrue(finder.RESULT_WILDCARD, flags)
@@ -415,7 +415,7 @@ class DataSrcClient(unittest.TestCase):
 
         self.assertRaises(TypeError, finder.find,
                           "foo",
-                          isc.dns.RRType.A(),
+                          isc.dns.RRType.A,
                           finder.FIND_DEFAULT)
         self.assertRaises(TypeError, finder.find,
                           isc.dns.Name("cname-ext.example.com"),
@@ -423,7 +423,7 @@ class DataSrcClient(unittest.TestCase):
                           finder.FIND_DEFAULT)
         self.assertRaises(TypeError, finder.find,
                           isc.dns.Name("cname-ext.example.com"),
-                          isc.dns.RRType.A(),
+                          isc.dns.RRType.A,
                           "foo")
 
 class DataSrcUpdater(unittest.TestCase):
@@ -451,7 +451,7 @@ class DataSrcUpdater(unittest.TestCase):
         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(),
+                                        isc.dns.RRType.A,
                                         ZoneFinder.FIND_DEFAULT)
         self.assertEqual(ZoneFinder.SUCCESS, result)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
@@ -459,7 +459,7 @@ class DataSrcUpdater(unittest.TestCase):
 
         # Omit optional parameters
         result, rrset, _ = updater.find(isc.dns.Name("www.example.com"),
-                                        isc.dns.RRType.A())
+                                        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())
@@ -471,11 +471,11 @@ class DataSrcUpdater(unittest.TestCase):
         # first make sure, through a separate finder, that some record exists
         result, finder = dsc.find_zone(isc.dns.Name("example.com"))
         self.assertEqual(finder.SUCCESS, result)
-        self.assertEqual(isc.dns.RRClass.IN(), finder.get_class())
+        self.assertEqual(isc.dns.RRClass.IN, finder.get_class())
         self.assertEqual("example.com.", finder.get_origin().to_text())
 
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
@@ -490,13 +490,13 @@ class DataSrcUpdater(unittest.TestCase):
         # The record should be gone in the updater, but not in the original
         # finder (since we have not committed)
         result, rrset, _ = updater.find(isc.dns.Name("www.example.com"),
-                                        isc.dns.RRType.A(),
+                                        isc.dns.RRType.A,
                                         finder.FIND_DEFAULT)
         self.assertEqual(finder.NXDOMAIN, result)
         self.assertEqual(None, rrset)
 
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
@@ -508,7 +508,7 @@ class DataSrcUpdater(unittest.TestCase):
 
         # the record should be gone now in the 'real' finder as well
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.NXDOMAIN, result)
         self.assertEqual(None, rrset)
@@ -522,7 +522,7 @@ class DataSrcUpdater(unittest.TestCase):
         self.assertRaises(isc.datasrc.Error, updater.commit)
 
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
@@ -537,26 +537,26 @@ class DataSrcUpdater(unittest.TestCase):
         rrsets = updater.get_rrset_collection()
 
         # From this point we cannot make further updates
-        rrset = RRset(isc.dns.Name('www.example.com'), isc.dns.RRClass.IN(),
-                      isc.dns.RRType.AAAA(), isc.dns.RRTTL(10))
-        rrset.add_rdata(isc.dns.Rdata(isc.dns.RRType.AAAA(),
-                                      isc.dns.RRClass.IN(), '2001:db8::1'))
+        rrset = RRset(isc.dns.Name('www.example.com'), isc.dns.RRClass.IN,
+                      isc.dns.RRType.AAAA, isc.dns.RRTTL(10))
+        rrset.add_rdata(isc.dns.Rdata(isc.dns.RRType.AAAA,
+                                      isc.dns.RRClass.IN, '2001:db8::1'))
         self.assertRaises(isc.datasrc.Error, updater.add_rrset, rrset)
 
         # Checks basic API
         found = rrsets.find(isc.dns.Name("www.example.com"),
-                            isc.dns.RRClass.IN(), isc.dns.RRType.A())
+                            isc.dns.RRClass.IN, isc.dns.RRType.A)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
                          found.to_text())
         self.assertEqual(None, rrsets.find(isc.dns.Name("www.example.com"),
-                                           isc.dns.RRClass.IN(),
-                                           isc.dns.RRType.AAAA()))
+                                           isc.dns.RRClass.IN,
+                                           isc.dns.RRType.AAAA))
 
         # Once committed collection cannot be used any more.
         updater.commit()
         self.assertRaises(isc.dns.RRsetCollectionError,
                           rrsets.find, isc.dns.Name("www.example.com"),
-                          isc.dns.RRClass.IN(), isc.dns.RRType.A())
+                          isc.dns.RRClass.IN, isc.dns.RRType.A)
 
         # When we destroy the RRsetCollection it should release the refcount
         # to the updater.
@@ -578,10 +578,10 @@ class DataSrcUpdater(unittest.TestCase):
         # see if a lookup succeeds in sqlite3 ds
         result, finder = dsc_sql.find_zone(isc.dns.Name("example.com"))
         self.assertEqual(finder.SUCCESS, result)
-        self.assertEqual(isc.dns.RRClass.IN(), finder.get_class())
+        self.assertEqual(isc.dns.RRClass.IN, finder.get_class())
         self.assertEqual("example.com.", finder.get_origin().to_text())
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
@@ -600,11 +600,11 @@ class DataSrcUpdater(unittest.TestCase):
         # first make sure, through a separate finder, that some record exists
         result, finder = dsc.find_zone(isc.dns.Name("example.com"))
         self.assertEqual(finder.SUCCESS, result)
-        self.assertEqual(isc.dns.RRClass.IN(), finder.get_class())
+        self.assertEqual(isc.dns.RRClass.IN, finder.get_class())
         self.assertEqual("example.com.", finder.get_origin().to_text())
 
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
@@ -619,7 +619,7 @@ class DataSrcUpdater(unittest.TestCase):
         # The record should be gone in the updater, but not in the original
         # finder (since we have not committed)
         result, rrset, _ = updater.find(isc.dns.Name("www.example.com"),
-                                        isc.dns.RRType.A(),
+                                        isc.dns.RRType.A,
                                         finder.FIND_DEFAULT)
         self.assertEqual(finder.NXDOMAIN, result)
         self.assertEqual(None, rrset)
@@ -629,7 +629,7 @@ class DataSrcUpdater(unittest.TestCase):
 
         # the record should still be available in the 'real' finder as well
         result, rrset, _ = finder.find(isc.dns.Name("www.example.com"),
-                                       isc.dns.RRType.A(),
+                                       isc.dns.RRType.A,
                                        finder.FIND_DEFAULT)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual("www.example.com. 3600 IN A 192.0.2.1\n",
@@ -755,9 +755,9 @@ class JournalWrite(unittest.TestCase):
         conn.close()
 
     def create_a(self, address):
-        a_rr = RRset(Name('www.example.org'), RRClass.IN(), RRType.A(),
+        a_rr = RRset(Name('www.example.org'), RRClass.IN, RRType.A,
                      RRTTL(3600))
-        a_rr.add_rdata(Rdata(RRType.A(), RRClass.IN(), address))
+        a_rr.add_rdata(Rdata(RRType.A, RRClass.IN, address))
         return (a_rr)
 
     def test_journal_write(self):

+ 3 - 2
src/lib/python/isc/datasrc/tests/zone_loader_test.py

@@ -13,6 +13,7 @@
 # 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
 
@@ -96,7 +97,7 @@ class ZoneLoaderTests(unittest.TestCase):
         """
         result, finder = self.client.find_zone(self.test_name)
         self.assertEqual(self.client.SUCCESS, result)
-        result, rrset, _ = finder.find(self.test_name, isc.dns.RRType.SOA())
+        result, rrset, _ = finder.find(self.test_name, isc.dns.RRType.SOA)
         self.assertEqual(finder.SUCCESS, result)
         self.assertEqual(soa_txt, rrset.to_text())
 
@@ -231,7 +232,7 @@ class ZoneLoaderTests(unittest.TestCase):
     def test_wrong_class_from_client(self):
         # For ds->ds loading, wrong class is detected upon construction
         # Need a bit of the extended setup for CH source client
-        clientlist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.CH())
+        clientlist = isc.datasrc.ConfigurableClientList(isc.dns.RRClass.CH)
         clientlist.configure('[ { "type": "static", "params": "' +
                              STATIC_ZONE_FILE +'" } ]', False)
         self.source_client, _, _ = clientlist.find(isc.dns.Name("bind."),

+ 57 - 57
src/lib/python/isc/ddns/session.py

@@ -135,7 +135,7 @@ class DDNS_SOA:
     def __write_soa_internal(self, origin_soa, soa_num):
         '''Write back serial number to soa'''
         new_soa = RRset(origin_soa.get_name(), origin_soa.get_class(),
-                        RRType.SOA(), origin_soa.get_ttl())
+                        RRType.SOA, origin_soa.get_ttl())
         soa_rdata_parts = origin_soa.get_rdata()[0].to_text().split()
         soa_rdata_parts[2] = str(soa_num.get_value())
         new_soa.add_rdata(Rdata(origin_soa.get_type(), origin_soa.get_class(),
@@ -248,14 +248,14 @@ class UpdateSession:
             self.__check_update_acl(self.__zname, self.__zclass)
             self._create_diff()
             prereq_result = self.__check_prerequisites()
-            if prereq_result != Rcode.NOERROR():
+            if prereq_result != Rcode.NOERROR:
                 self.__make_response(prereq_result)
                 return UPDATE_ERROR, self.__zname, self.__zclass
             update_result = self.__do_update()
-            if update_result != Rcode.NOERROR():
+            if update_result != Rcode.NOERROR:
                 self.__make_response(update_result)
                 return UPDATE_ERROR, self.__zname, self.__zclass
-            self.__make_response(Rcode.NOERROR())
+            self.__make_response(Rcode.NOERROR)
             return UPDATE_SUCCESS, self.__zname, self.__zclass
         except UpdateError as e:
             if not e.nolog:
@@ -272,7 +272,7 @@ class UpdateSession:
         except isc.datasrc.Error as e:
             logger.error(LIBDDNS_DATASRC_ERROR,
                          ClientFormatter(self.__client_addr, self.__tsig), e)
-            self.__make_response(Rcode.SERVFAIL())
+            self.__make_response(Rcode.SERVFAIL)
             return UPDATE_ERROR, None, None
 
     def _get_update_zone(self):
@@ -295,11 +295,11 @@ class UpdateSession:
         n_zones = self.__message.get_rr_count(SECTION_ZONE)
         if n_zones != 1:
             raise UpdateError('Invalid number of records in zone section: ' +
-                              str(n_zones), None, None, Rcode.FORMERR())
+                              str(n_zones), None, None, Rcode.FORMERR)
         zrecord = self.__message.get_question()[0]
-        if zrecord.get_type() != RRType.SOA():
+        if zrecord.get_type() != RRType.SOA:
             raise UpdateError('update zone section contains non-SOA',
-                              None, None, Rcode.FORMERR())
+                              None, None, Rcode.FORMERR)
 
         # See if we're serving a primary zone specified in the zone section.
         zname = zrecord.get_name()
@@ -316,12 +316,12 @@ class UpdateSession:
             logger.debug(DBGLVL_TRACE_BASIC, LIBDDNS_UPDATE_FORWARD_FAIL,
                          ClientFormatter(self.__client_addr, self.__tsig),
                          ZoneFormatter(zname, zclass))
-            raise UpdateError('forward', zname, zclass, Rcode.NOTIMP(), True)
+            raise UpdateError('forward', zname, zclass, Rcode.NOTIMP, True)
         # zone wasn't found
         logger.debug(DBGLVL_TRACE_BASIC, LIBDDNS_UPDATE_NOTAUTH,
                      ClientFormatter(self.__client_addr, self.__tsig),
                      ZoneFormatter(zname, zclass))
-        raise UpdateError('notauth', zname, zclass, Rcode.NOTAUTH(), True)
+        raise UpdateError('notauth', zname, zclass, Rcode.NOTAUTH, True)
 
     def _create_diff(self):
         '''
@@ -352,7 +352,7 @@ class UpdateSession:
             logger.info(LIBDDNS_UPDATE_DENIED,
                         ClientFormatter(self.__client_addr, self.__tsig),
                         ZoneFormatter(zname, zclass))
-            raise UpdateError('rejected', zname, zclass, Rcode.REFUSED(), True)
+            raise UpdateError('rejected', zname, zclass, Rcode.REFUSED, True)
         if action == DROP:
             logger.info(LIBDDNS_UPDATE_DROPPED,
                         ClientFormatter(self.__client_addr, self.__tsig),
@@ -459,7 +459,7 @@ class UpdateSession:
     def __check_prerequisites(self):
         '''Check the prerequisites section of the UPDATE Message.
            RFC2136 Section 2.4.
-           Returns a dns Rcode signaling either no error (Rcode.NOERROR())
+           Returns a dns Rcode signaling either no error (Rcode.NOERROR)
            or that one of the prerequisites failed (any other Rcode).
         '''
 
@@ -473,20 +473,20 @@ class UpdateSession:
                             ClientFormatter(self.__client_addr),
                             ZoneFormatter(self.__zname, self.__zclass),
                             RRsetFormatter(rrset))
-                return Rcode.NOTZONE()
+                return Rcode.NOTZONE
 
             # Algorithm taken from RFC2136 Section 3.2
-            if rrset.get_class() == RRClass.ANY():
+            if rrset.get_class() == RRClass.ANY:
                 if rrset.get_ttl().get_value() != 0 or\
                    rrset.get_rdata_count() != 0:
                     logger.info(LIBDDNS_PREREQ_FORMERR_ANY,
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
-                elif rrset.get_type() == RRType.ANY():
+                    return Rcode.FORMERR
+                elif rrset.get_type() == RRType.ANY:
                     if not self.__prereq_name_in_use(rrset):
-                        rcode = Rcode.NXDOMAIN()
+                        rcode = Rcode.NXDOMAIN
                         logger.info(LIBDDNS_PREREQ_NAME_IN_USE_FAILED,
                                     ClientFormatter(self.__client_addr),
                                     ZoneFormatter(self.__zname, self.__zclass),
@@ -494,23 +494,23 @@ class UpdateSession:
                         return rcode
                 else:
                     if not self.__prereq_rrset_exists(rrset):
-                        rcode = Rcode.NXRRSET()
+                        rcode = Rcode.NXRRSET
                         logger.info(LIBDDNS_PREREQ_RRSET_EXISTS_FAILED,
                                     ClientFormatter(self.__client_addr),
                                     ZoneFormatter(self.__zname, self.__zclass),
                                     RRsetFormatter(rrset), rcode)
                         return rcode
-            elif rrset.get_class() == RRClass.NONE():
+            elif rrset.get_class() == RRClass.NONE:
                 if rrset.get_ttl().get_value() != 0 or\
                    rrset.get_rdata_count() != 0:
                     logger.info(LIBDDNS_PREREQ_FORMERR_NONE,
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
-                elif rrset.get_type() == RRType.ANY():
+                    return Rcode.FORMERR
+                elif rrset.get_type() == RRType.ANY:
                     if not self.__prereq_name_not_in_use(rrset):
-                        rcode = Rcode.YXDOMAIN()
+                        rcode = Rcode.YXDOMAIN
                         logger.info(LIBDDNS_PREREQ_NAME_NOT_IN_USE_FAILED,
                                     ClientFormatter(self.__client_addr),
                                     ZoneFormatter(self.__zname, self.__zclass),
@@ -518,7 +518,7 @@ class UpdateSession:
                         return rcode
                 else:
                     if not self.__prereq_rrset_does_not_exist(rrset):
-                        rcode = Rcode.YXRRSET()
+                        rcode = Rcode.YXRRSET
                         logger.info(LIBDDNS_PREREQ_RRSET_DOES_NOT_EXIST_FAILED,
                                     ClientFormatter(self.__client_addr),
                                     ZoneFormatter(self.__zname, self.__zclass),
@@ -530,7 +530,7 @@ class UpdateSession:
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
+                    return Rcode.FORMERR
                 else:
                     collect_rrsets(exact_match_rrsets, rrset)
             else:
@@ -538,11 +538,11 @@ class UpdateSession:
                             ClientFormatter(self.__client_addr),
                             ZoneFormatter(self.__zname, self.__zclass),
                             RRsetFormatter(rrset))
-                return Rcode.FORMERR()
+                return Rcode.FORMERR
 
         for collected_rrset in exact_match_rrsets:
             if not self.__prereq_rrset_exists_value(collected_rrset):
-                rcode = Rcode.NXRRSET()
+                rcode = Rcode.NXRRSET
                 logger.info(LIBDDNS_PREREQ_RRSET_EXISTS_VAL_FAILED,
                             ClientFormatter(self.__client_addr),
                             ZoneFormatter(self.__zname, self.__zclass),
@@ -550,7 +550,7 @@ class UpdateSession:
                 return rcode
 
         # All prerequisites are satisfied
-        return Rcode.NOERROR()
+        return Rcode.NOERROR
 
     def __set_soa_rrset(self, rrset):
         '''Sets the given rrset to the member __added_soa (which
@@ -570,7 +570,7 @@ class UpdateSession:
                             ClientFormatter(self.__client_addr),
                             ZoneFormatter(self.__zname, self.__zclass),
                             RRsetFormatter(rrset))
-                return Rcode.NOTZONE()
+                return Rcode.NOTZONE
             if rrset.get_class() == self.__zclass:
                 # In fact, all metatypes are in a specific range,
                 # so one check can test TKEY to ANY
@@ -581,52 +581,52 @@ class UpdateSession:
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
-                if rrset.get_type() == RRType.SOA():
+                    return Rcode.FORMERR
+                if rrset.get_type() == RRType.SOA:
                     # In case there's multiple soa records in the update
                     # somehow, just take the last
                     for rr in foreach_rr(rrset):
                         self.__set_soa_rrset(rr)
-            elif rrset.get_class() == RRClass.ANY():
+            elif rrset.get_class() == RRClass.ANY:
                 if rrset.get_ttl().get_value() != 0:
                     logger.info(LIBDDNS_UPDATE_DELETE_NONZERO_TTL,
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
+                    return Rcode.FORMERR
                 if rrset.get_rdata_count() > 0:
                     logger.info(LIBDDNS_UPDATE_DELETE_RRSET_NOT_EMPTY,
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
+                    return Rcode.FORMERR
                 if rrset.get_type().get_code() >= 249 and\
                    rrset.get_type().get_code() <= 254:
                     logger.info(LIBDDNS_UPDATE_DELETE_BAD_TYPE,
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
-            elif rrset.get_class() == RRClass.NONE():
+                    return Rcode.FORMERR
+            elif rrset.get_class() == RRClass.NONE:
                 if rrset.get_ttl().get_value() != 0:
                     logger.info(LIBDDNS_UPDATE_DELETE_RR_NONZERO_TTL,
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
+                    return Rcode.FORMERR
                 if rrset.get_type().get_code() >= 249:
                     logger.info(LIBDDNS_UPDATE_DELETE_RR_BAD_TYPE,
                                 ClientFormatter(self.__client_addr),
                                 ZoneFormatter(self.__zname, self.__zclass),
                                 RRsetFormatter(rrset))
-                    return Rcode.FORMERR()
+                    return Rcode.FORMERR
             else:
                 logger.info(LIBDDNS_UPDATE_BAD_CLASS,
                             ClientFormatter(self.__client_addr),
                             ZoneFormatter(self.__zname, self.__zclass),
                             RRsetFormatter(rrset))
-                return Rcode.FORMERR()
-        return Rcode.NOERROR()
+                return Rcode.FORMERR
+        return Rcode.NOERROR
 
     def __do_update_add_single_rr(self, rr, existing_rrset):
         '''Helper for __do_update_add_rrs_to_rrset: only add the
@@ -657,7 +657,7 @@ class UpdateSession:
         # For a number of cases, we may need to remove data in the zone
         # (note; SOA is handled separately by __do_update, so that one
         # is explicitely ignored here)
-        if rrset.get_type() == RRType.SOA():
+        if rrset.get_type() == RRType.SOA:
             return
         result, orig_rrset, _ = self.__diff.find(rrset.get_name(),
                                                  rrset.get_type())
@@ -668,7 +668,7 @@ class UpdateSession:
             return
         elif result == ZoneFinder.SUCCESS:
             # if update is cname, and zone rr is not, ignore
-            if rrset.get_type() == RRType.CNAME():
+            if rrset.get_type() == RRType.CNAME:
                 # Remove original CNAME record (the new one
                 # is added below)
                 self.__diff.delete_data(orig_rrset)
@@ -679,7 +679,7 @@ class UpdateSession:
         elif result == ZoneFinder.NXRRSET:
             # There is data present, but not for this type.
             # If this type is CNAME, ignore the update
-            if rrset.get_type() == RRType.CNAME():
+            if rrset.get_type() == RRType.CNAME:
                 return
         for rr in foreach_rr(rrset):
             self.__do_update_add_single_rr(rr, orig_rrset)
@@ -696,8 +696,8 @@ class UpdateSession:
                                                         rrset.get_type())
         if result == ZoneFinder.SUCCESS:
             if to_delete.get_name() == self.__zname and\
-               (to_delete.get_type() == RRType.SOA() or\
-                to_delete.get_type() == RRType.NS()):
+               (to_delete.get_type() == RRType.SOA or\
+                to_delete.get_type() == RRType.NS):
                 # ignore
                 return
             for rr in foreach_rr(to_delete):
@@ -749,8 +749,8 @@ class UpdateSession:
             for to_delete in rrsets:
                 # if name == self.__zname and type is soa or ns, don't delete!
                 if to_delete.get_name() == self.__zname and\
-                   (to_delete.get_type() == RRType.SOA() or
-                    to_delete.get_type() == RRType.NS()):
+                   (to_delete.get_type() == RRType.SOA or
+                    to_delete.get_type() == RRType.NS):
                     continue
                 else:
                     for rr in foreach_rr(to_delete):
@@ -771,10 +771,10 @@ class UpdateSession:
         to_delete = convert_rrset_class(rrset, self.__zclass)
 
         if rrset.get_name() == self.__zname:
-            if rrset.get_type() == RRType.SOA():
+            if rrset.get_type() == RRType.SOA:
                 # ignore
                 return
-            elif rrset.get_type() == RRType.NS():
+            elif rrset.get_type() == RRType.NS:
                 # hmm. okay. annoying. There must be at least one left,
                 # delegate to helper method
                 self.__ns_deleter_helper(to_delete)
@@ -793,14 +793,14 @@ class UpdateSession:
         # serial magic and add the newly created one
 
         # get it from DS and to increment and stuff
-        result, old_soa, _ = self.__diff.find(self.__zname, RRType.SOA(),
+        result, old_soa, _ = self.__diff.find(self.__zname, RRType.SOA,
                                               ZoneFinder.NO_WILDCARD |
                                               ZoneFinder.FIND_GLUE_OK)
         # We may implement recovering from missing SOA data at some point, but
         # for now servfail on such a broken state
         if result != ZoneFinder.SUCCESS:
             raise UpdateError("Error finding SOA record in datasource.",
-                    self.__zname, self.__zclass, Rcode.SERVFAIL())
+                    self.__zname, self.__zclass, Rcode.SERVFAIL)
         serial_operation = DDNS_SOA()
         if self.__added_soa is not None and\
         serial_operation.soa_update_check(old_soa, self.__added_soa):
@@ -820,7 +820,7 @@ class UpdateSession:
         '''
         # prescan
         prescan_result = self.__do_prescan()
-        if prescan_result != Rcode.NOERROR():
+        if prescan_result != Rcode.NOERROR:
             return prescan_result
 
         # update
@@ -841,22 +841,22 @@ class UpdateSession:
             for rrset in self.__message.get_section(SECTION_UPDATE):
                 if rrset.get_class() == self.__zclass:
                     self.__do_update_add_rrs_to_rrset(rrset)
-                elif rrset.get_class() == RRClass.ANY():
-                    if rrset.get_type() == RRType.ANY():
+                elif rrset.get_class() == RRClass.ANY:
+                    if rrset.get_type() == RRType.ANY:
                         self.__do_update_delete_name(rrset)
                     else:
                         self.__do_update_delete_rrset(rrset)
-                elif rrset.get_class() == RRClass.NONE():
+                elif rrset.get_class() == RRClass.NONE:
                     self.__do_update_delete_rrs_from_rrset(rrset)
 
             self.__diff.commit()
-            return Rcode.NOERROR()
+            return Rcode.NOERROR
         except isc.datasrc.Error as dse:
             logger.info(LIBDDNS_UPDATE_DATASRC_COMMIT_FAILED, dse)
-            return Rcode.SERVFAIL()
+            return Rcode.SERVFAIL
         except Exception as uce:
             logger.error(LIBDDNS_UPDATE_UNCAUGHT_EXCEPTION,
                          ClientFormatter(self.__client_addr),
                          ZoneFormatter(self.__zname, self.__zclass),
                          uce)
-            return Rcode.SERVFAIL()
+            return Rcode.SERVFAIL

File diff suppressed because it is too large
+ 306 - 309
src/lib/python/isc/ddns/tests/session_tests.py


+ 7 - 7
src/lib/python/isc/ddns/tests/zone_config_tests.py

@@ -26,7 +26,7 @@ import socket
 # Some common test parameters
 TEST_ZONE_NAME = Name('example.org')
 TEST_SECONDARY_ZONE_NAME = Name('example.com')
-TEST_RRCLASS = RRClass.IN()
+TEST_RRCLASS = RRClass.IN
 TEST_TSIG_KEY = TSIGKey("example.com:SFuWd/q99SzF8Yzd1QbB9g==")
 TEST_ACL_CONTEXT = isc.acl.dns.RequestContext(
     socket.getaddrinfo("192.0.2.1", 1234, 0, socket.SOCK_DGRAM,
@@ -88,12 +88,12 @@ class ZoneConfigTest(unittest.TestCase):
         # zone class doesn't match (but zone name matches)
         self.__datasrc_client.set_find_result(DataSourceClient.SUCCESS)
         zconfig = ZoneConfig({(TEST_SECONDARY_ZONE_NAME, TEST_RRCLASS)},
-                             RRClass.CH(), self.__datasrc_client)
+                             RRClass.CH, self.__datasrc_client)
         self.assertEqual((ZONE_NOTFOUND, None),
                          (zconfig.find_zone(TEST_ZONE_NAME, TEST_RRCLASS)))
         # similar to the previous case, but also in the secondary list
         zconfig = ZoneConfig({(TEST_ZONE_NAME, TEST_RRCLASS)},
-                             RRClass.CH(), self.__datasrc_client)
+                             RRClass.CH, self.__datasrc_client)
         self.assertEqual((ZONE_NOTFOUND, None),
                          (zconfig.find_zone(TEST_ZONE_NAME, TEST_RRCLASS)))
 
@@ -107,7 +107,7 @@ class ZoneConfigTest(unittest.TestCase):
         zconfig = ZoneConfig({(TEST_SECONDARY_ZONE_NAME, TEST_RRCLASS),
                               (Name('example'), TEST_RRCLASS),
                               (Name('sub.example.org'), TEST_RRCLASS),
-                              (TEST_ZONE_NAME, RRClass.CH())},
+                              (TEST_ZONE_NAME, RRClass.CH)},
                              TEST_RRCLASS, self.__datasrc_client)
         self.assertEqual((ZONE_PRIMARY, self.__datasrc_client),
                          self.zconfig.find_zone(TEST_ZONE_NAME, TEST_RRCLASS))
@@ -134,7 +134,7 @@ class ACLConfigTest(unittest.TestCase):
         # 'All reject' ACL will still apply for any other zones
         acl = self.__zconfig.get_update_acl(Name('example.com'), TEST_RRCLASS)
         self.assertEqual(REJECT, acl.execute(TEST_ACL_CONTEXT))
-        acl = self.__zconfig.get_update_acl(TEST_ZONE_NAME, RRClass.CH())
+        acl = self.__zconfig.get_update_acl(TEST_ZONE_NAME, RRClass.CH)
         self.assertEqual(REJECT, acl.execute(TEST_ACL_CONTEXT))
 
         # Test with a map with a few more ACL entries.  Should be nothing
@@ -143,14 +143,14 @@ class ACLConfigTest(unittest.TestCase):
                        REQUEST_LOADER.load([{"action": "REJECT"}]),
                    (TEST_ZONE_NAME, TEST_RRCLASS):
                        REQUEST_LOADER.load([{"action": "ACCEPT"}]),
-                   (TEST_ZONE_NAME, RRClass.CH()):
+                   (TEST_ZONE_NAME, RRClass.CH):
                        REQUEST_LOADER.load([{"action": "DROP"}])}
         self.__zconfig.set_update_acl_map(acl_map)
         acl = self.__zconfig.get_update_acl(TEST_ZONE_NAME, TEST_RRCLASS)
         self.assertEqual(ACCEPT, acl.execute(TEST_ACL_CONTEXT))
         acl = self.__zconfig.get_update_acl(Name('example.com'), TEST_RRCLASS)
         self.assertEqual(REJECT, acl.execute(TEST_ACL_CONTEXT))
-        acl = self.__zconfig.get_update_acl(TEST_ZONE_NAME, RRClass.CH())
+        acl = self.__zconfig.get_update_acl(TEST_ZONE_NAME, RRClass.CH)
         self.assertEqual(DROP, acl.execute(TEST_ACL_CONTEXT))
 
 if __name__ == "__main__":

+ 9 - 9
src/lib/python/isc/notify/notify_out.py

@@ -302,12 +302,12 @@ class NotifyOut:
                          format_zone_str(zone_name, zone_class))
             return []
 
-        result, ns_rrset, _ = finder.find(zone_name, RRType.NS())
+        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())
+        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,
@@ -323,11 +323,11 @@ class NotifyOut:
             ns_result, ns_finder = ds_client.find_zone(ns_name)
             if ns_result is DataSourceClient.SUCCESS or \
                ns_result is DataSourceClient.PARTIALMATCH:
-                result, rrset, _ = ns_finder.find(ns_name, RRType.A())
+                result, rrset, _ = ns_finder.find(ns_name, RRType.A)
                 if result is ns_finder.SUCCESS and rrset is not None:
                     addrs.extend([a.to_text() for a in rrset.get_rdata()])
 
-                result, rrset, _ = ns_finder.find(ns_name, RRType.AAAA())
+                result, rrset, _ = ns_finder.find(ns_name, RRType.AAAA)
                 if result is ns_finder.SUCCESS and rrset is not None:
                     addrs.extend([aaaa.to_text()
                                     for aaaa in rrset.get_rdata()])
@@ -509,10 +509,10 @@ class NotifyOut:
         msg = Message(Message.RENDER)
         qid = random.randint(0, 0xFFFF)
         msg.set_qid(qid)
-        msg.set_opcode(Opcode.NOTIFY())
-        msg.set_rcode(Rcode.NOERROR())
+        msg.set_opcode(Opcode.NOTIFY)
+        msg.set_rcode(Rcode.NOERROR)
         msg.set_header_flag(Message.HEADERFLAG_AA)
-        msg.add_question(Question(zone_name, zone_class, RRType.SOA()))
+        msg.add_question(Question(zone_name, zone_class, RRType.SOA))
         msg.add_rrset(Message.SECTION_ANSWER, self._get_zone_soa(zone_name,
                                                                  zone_class))
         return msg, qid
@@ -531,7 +531,7 @@ class NotifyOut:
                                            zone_name.to_text() + '/' +
                                            zone_class.to_text() + ' not found')
 
-        result, soa_rrset, _ = finder.find(zone_name, RRType.SOA())
+        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 ' +
@@ -566,7 +566,7 @@ class NotifyOut:
                             Name(zone_notify_info.zone_name).to_text())
                 return _BAD_QUERY_NAME
 
-            if msg.get_opcode() != Opcode.NOTIFY():
+            if msg.get_opcode() != Opcode.NOTIFY:
                 logger.warn(NOTIFY_OUT_REPLY_BAD_OPCODE, from_addr[0],
                             from_addr[1], msg.get_opcode().to_text())
                 return _BAD_OPCODE

+ 7 - 7
src/lib/python/isc/notify/tests/notify_out_test.py

@@ -377,7 +377,7 @@ class TestNotifyOut(unittest.TestCase):
 
     def test_get_notify_slaves_from_ns(self):
         records = self._notify._get_notify_slaves_from_ns(Name('example.net.'),
-                                                          RRClass.IN())
+                                                          RRClass.IN)
         self.assertEqual(6, len(records))
         self.assertEqual('8:8::8:8', records[5])
         self.assertEqual('7.7.7.7', records[4])
@@ -387,7 +387,7 @@ class TestNotifyOut(unittest.TestCase):
         self.assertEqual('3.3.3.3', records[0])
 
         records = self._notify._get_notify_slaves_from_ns(Name('example.com.'),
-                                                          RRClass.IN())
+                                                          RRClass.IN)
         self.assertEqual(3, len(records))
         self.assertEqual('5:5::5:5', records[2])
         self.assertEqual('4:4::4:4', records[1])
@@ -396,19 +396,19 @@ class TestNotifyOut(unittest.TestCase):
     def test_get_notify_slaves_from_ns_unusual(self):
         self._notify._db_file = TESTDATA_SRCDIR + '/brokentest.sqlite3'
         self.assertEqual([], self._notify._get_notify_slaves_from_ns(
-                Name('nons.example'), RRClass.IN()))
+                Name('nons.example'), RRClass.IN))
         self.assertEqual([], self._notify._get_notify_slaves_from_ns(
-                Name('nosoa.example'), RRClass.IN()))
+                Name('nosoa.example'), RRClass.IN))
         self.assertEqual([], self._notify._get_notify_slaves_from_ns(
-                Name('multisoa.example'), RRClass.IN()))
+                Name('multisoa.example'), RRClass.IN))
 
         self.assertEqual([], self._notify._get_notify_slaves_from_ns(
-                Name('nosuchzone.example'), RRClass.IN()))
+                Name('nosuchzone.example'), RRClass.IN))
 
         # This will cause failure in getting access to the data source.
         self._notify._db_file = TESTDATA_SRCDIR + '/nodir/error.sqlite3'
         self.assertEqual([], self._notify._get_notify_slaves_from_ns(
-                Name('example.com'), RRClass.IN()))
+                Name('example.com'), RRClass.IN))
 
     def test_init_notify_out(self):
         self._notify._init_notify_out(self._db_file)

+ 3 - 3
src/lib/python/isc/statistics/tests/counters_test.py

@@ -139,9 +139,9 @@ class TestBasicMethods(unittest.TestCase):
             counters._get_counter(self.counters._statistics._data,
                                  counter_name),
             concurrency * number)
-        self.assertGreater(
+        self.assertGreaterEqual(
             counters._get_counter(self.counters._statistics._data,
-                                 timer_name), 0)
+                                 timer_name), 0.0)
 
     def test_concat(self):
         # only strings
@@ -200,7 +200,7 @@ class BaseTestCounters():
             if name.find('time_to_') == 0:
                 self.counters.start_timer(*args)
                 self.counters.stop_timer(*args)
-                self.assertGreater(self.counters.get(*args), 0)
+                self.assertGreaterEqual(self.counters.get(*args), 0.0)
                 sec = self.counters.get(*args)
                 for zone_str in (self._entire_server, TEST_ZONE_NAME_STR):
                     isc.cc.data.set(self._statistics_data,

+ 9 - 6
src/lib/python/isc/sysinfo/sysinfo.py

@@ -44,7 +44,7 @@ class SysInfo:
         self._net_stats = 'Unknown\n'
         self._net_connections = 'Unknown\n'
 
-        # The following are Linux speicific, and should eventually be removed
+        # The following are Linux specific, and should eventually be removed
         # from this level; for now we simply default to None (so they won't
         # be printed)
         self._platform_distro = None
@@ -162,9 +162,12 @@ class SysInfoPOSIX(SysInfo):
 
         u = os.uname()
         self._platform_name = u[0]
+        self._hostname = u[1]
         self._platform_version = u[2]
         self._platform_machine = u[4]
 
+        self._loadavg = os.getloadavg()
+
 class SysInfoLinux(SysInfoPOSIX):
     """Linux implementation of the SysInfo class.
     See the SysInfo class documentation for more information.
@@ -322,8 +325,8 @@ class SysInfoBSD(SysInfoPOSIX):
         except (subprocess.CalledProcessError, OSError):
             self._net_connections = 'Warning: "netstat -nr" command failed.\n'
 
-class SysInfoOpenBSD(SysInfoBSD):
-    """OpenBSD implementation of the SysInfo class.
+class SysInfoNetBSD(SysInfoBSD):
+    """NetBSD and OpenBSD implementation of the SysInfo class.
     See the SysInfo class documentation for more information.
     """
     def __init__(self):
@@ -499,8 +502,8 @@ def SysInfoFromFactory():
     osname = platform.system()
     if osname == 'Linux':
         return SysInfoLinux()
-    elif osname == 'OpenBSD':
-        return SysInfoOpenBSD()
+    elif (osname == 'NetBSD') or (osname == 'OpenBSD'):
+        return SysInfoNetBSD()
     elif osname == 'FreeBSD':
         return SysInfoFreeBSD()
     elif osname == 'Darwin':
@@ -508,4 +511,4 @@ def SysInfoFromFactory():
     elif osname == 'BIND10Testcase':
         return SysInfoTestcase()
     else:
-        return SysInfo()
+        return SysInfoPOSIX()

+ 13 - 13
src/lib/python/isc/testutils/rrset_utils.py

@@ -30,7 +30,7 @@ def rrsets_equal(a, b):
            a.get_class() == b.get_class() and \
            a.get_type() == b.get_type() and \
            a.get_ttl() == b.get_ttl() and \
-           (a.get_type() == RRType.RRSIG() or
+           (a.get_type() == RRType.RRSIG or
             sorted(a.get_rdata()) == sorted(b.get_rdata()))
 
 # The following are short cut utilities to create an RRset of a specific
@@ -38,25 +38,25 @@ def rrsets_equal(a, b):
 # tests, so we define default values for them for convenience.
 
 def create_a(name, address, ttl=3600):
-    rrset = RRset(name, RRClass.IN(), RRType.A(), RRTTL(ttl))
-    rrset.add_rdata(Rdata(RRType.A(), RRClass.IN(), address))
+    rrset = RRset(name, RRClass.IN, RRType.A, RRTTL(ttl))
+    rrset.add_rdata(Rdata(RRType.A, RRClass.IN, address))
     return rrset
 
 def create_aaaa(name, address, ttl=3600):
-    rrset = RRset(name, RRClass.IN(), RRType.AAAA(), RRTTL(ttl))
-    rrset.add_rdata(Rdata(RRType.AAAA(), RRClass.IN(), address))
+    rrset = RRset(name, RRClass.IN, RRType.AAAA, RRTTL(ttl))
+    rrset.add_rdata(Rdata(RRType.AAAA, RRClass.IN, address))
     return rrset
 
 def create_ns(nsname, name=Name('example.com'), ttl=3600):
     '''For convenience we use a default name often used as a zone name'''
-    rrset = RRset(name, RRClass.IN(), RRType.NS(), RRTTL(ttl))
-    rrset.add_rdata(Rdata(RRType.NS(), RRClass.IN(), nsname))
+    rrset = RRset(name, RRClass.IN, RRType.NS, RRTTL(ttl))
+    rrset.add_rdata(Rdata(RRType.NS, RRClass.IN, nsname))
     return rrset
 
 def create_cname(target='target.example.com.', name=Name('example.com'),
                  ttl=3600):
-    rrset = RRset(name, RRClass.IN(), RRType.CNAME(), RRTTL(ttl))
-    rrset.add_rdata(Rdata(RRType.CNAME(), RRClass.IN(), target))
+    rrset = RRset(name, RRClass.IN, RRType.CNAME, RRTTL(ttl))
+    rrset.add_rdata(Rdata(RRType.CNAME, RRClass.IN, target))
     return rrset
 
 def create_generic(name, rdlen, type=RRType('TYPE65300'), ttl=3600):
@@ -67,16 +67,16 @@ def create_generic(name, rdlen, type=RRType('TYPE65300'), ttl=3600):
     The RDATA will be filled with specified length of all-0 data.
 
     '''
-    rrset = RRset(name, RRClass.IN(), type, RRTTL(ttl))
-    rrset.add_rdata(Rdata(type, RRClass.IN(), '\\# ' +
+    rrset = RRset(name, RRClass.IN, type, RRTTL(ttl))
+    rrset.add_rdata(Rdata(type, RRClass.IN, '\\# ' +
                           str(rdlen) + ' ' + '00' * rdlen))
     return rrset
 
 def create_soa(serial, name=Name('example.com'), ttl=3600):
     '''For convenience we use a default name often used as a zone name'''
 
-    rrset = RRset(name, RRClass.IN(), RRType.SOA(), RRTTL(ttl))
+    rrset = RRset(name, RRClass.IN, RRType.SOA, RRTTL(ttl))
     rdata_str = 'master.example.com. admin.example.com. ' + \
         str(serial) + ' 3600 1800 2419200 7200'
-    rrset.add_rdata(Rdata(RRType.SOA(), RRClass.IN(), rdata_str))
+    rrset.add_rdata(Rdata(RRType.SOA, RRClass.IN, rdata_str))
     return rrset

+ 5 - 5
src/lib/python/isc/xfrin/diff.py

@@ -146,12 +146,12 @@ class Diff:
         """
         # first add or delete must be of type SOA
         if len(buf) == 0 and\
-           rr.get_type() != isc.dns.RRType.SOA():
+           rr.get_type() != isc.dns.RRType.SOA:
             raise ValueError("First " + operation +
                              " in single update mode must be of type SOA")
         # And later adds or deletes may not
         elif len(buf) != 0 and\
-           rr.get_type() == isc.dns.RRType.SOA():
+           rr.get_type() == isc.dns.RRType.SOA:
             raise ValueError("Multiple SOA records in single " +
                              "update mode " + operation)
         buf.append((operation, rr))
@@ -238,8 +238,8 @@ class Diff:
             '''A helper routine to identify whether two RRsets are of the
             same 'type'.  For RRSIGs we should consider type covered, too.
             '''
-            if rrset1.get_type() != isc.dns.RRType.RRSIG() or \
-                    rrset2.get_type != isc.dns.RRType.RRSIG():
+            if rrset1.get_type() != isc.dns.RRType.RRSIG or \
+                    rrset2.get_type != isc.dns.RRType.RRSIG:
                 return rrset1.get_type() == rrset2.get_type()
             # RR type of the both RRsets is RRSIG.  Compare type covered.
             # We know they have exactly one RDATA.
@@ -425,7 +425,7 @@ class Diff:
             return a.get_name() == b.get_name() and\
                    a.get_type() == b.get_type() and\
                    a.get_rdata()[0] == b.get_rdata()[0]
-        if rr.get_type() == isc.dns.RRType.SOA():
+        if rr.get_type() == isc.dns.RRType.SOA:
             return buf
         else:
             return [ op for op in buf if not same_rr(op[1], rr)]

+ 30 - 30
src/lib/python/isc/xfrin/tests/diff_tests.py

@@ -57,8 +57,8 @@ class DiffTest(unittest.TestCase):
         self.__find_all_name = None
         self.__find_all_options = None
         # Some common values
-        self.__rrclass = RRClass.IN()
-        self.__type = RRType.A()
+        self.__rrclass = RRClass.IN
+        self.__type = RRType.A
         self.__ttl = RRTTL(3600)
         # And RRsets
         # Create two valid rrsets
@@ -81,27 +81,27 @@ class DiffTest(unittest.TestCase):
         # Also create a few other (valid) rrsets
         # A SOA record
         self.__rrset_soa = RRset(Name('example.org.'), self.__rrclass,
-                                 RRType.SOA(), RRTTL(3600))
-        self.__rrset_soa.add_rdata(Rdata(RRType.SOA(), self.__rrclass,
+                                 RRType.SOA, RRTTL(3600))
+        self.__rrset_soa.add_rdata(Rdata(RRType.SOA, self.__rrclass,
                                          "ns1.example.org. " +
                                          "admin.example.org. " +
                                          "1233 3600 1800 2419200 7200"))
         # A few single-rr rrsets that together would for a multi-rr rrset
         self.__rrset3 = RRset(Name('c.example.org.'), self.__rrclass,
-                              RRType.TXT(), self.__ttl)
-        self.__rrset3.add_rdata(Rdata(RRType.TXT(), self.__rrclass, "one"))
+                              RRType.TXT, self.__ttl)
+        self.__rrset3.add_rdata(Rdata(RRType.TXT, self.__rrclass, "one"))
         self.__rrset4 = RRset(Name('c.example.org.'), self.__rrclass,
-                              RRType.TXT(), self.__ttl)
-        self.__rrset4.add_rdata(Rdata(RRType.TXT(), self.__rrclass, "two"))
+                              RRType.TXT, self.__ttl)
+        self.__rrset4.add_rdata(Rdata(RRType.TXT, self.__rrclass, "two"))
         self.__rrset5 = RRset(Name('c.example.org.'), self.__rrclass,
-                              RRType.TXT(), self.__ttl)
-        self.__rrset5.add_rdata(Rdata(RRType.TXT(), self.__rrclass, "three"))
+                              RRType.TXT, self.__ttl)
+        self.__rrset5.add_rdata(Rdata(RRType.TXT, self.__rrclass, "three"))
         self.__rrset6 = RRset(Name('d.example.org.'), self.__rrclass,
-                              RRType.A(), self.__ttl)
-        self.__rrset6.add_rdata(Rdata(RRType.A(), self.__rrclass, "192.0.2.1"))
+                              RRType.A, self.__ttl)
+        self.__rrset6.add_rdata(Rdata(RRType.A, self.__rrclass, "192.0.2.1"))
         self.__rrset7 = RRset(Name('d.example.org.'), self.__rrclass,
-                              RRType.A(), self.__ttl)
-        self.__rrset7.add_rdata(Rdata(RRType.A(), self.__rrclass, "192.0.2.2"))
+                              RRType.A, self.__ttl)
+        self.__rrset7.add_rdata(Rdata(RRType.A, self.__rrclass, "192.0.2.2"))
 
     def __mock_compact(self):
         """
@@ -316,7 +316,7 @@ class DiffTest(unittest.TestCase):
         self.assertRaises(ValueError, diff.add_data, self.__rrset2)
         self.assertRaises(ValueError, diff.delete_data, self.__rrset1)
         self.assertRaises(ValueError, diff.find, Name('foo.example.org.'),
-                          RRType.A())
+                          RRType.A)
         self.assertRaises(ValueError, diff.find_all, Name('foo.example.org.'))
         diff.apply = orig_apply
         self.assertRaises(ValueError, diff.apply)
@@ -435,9 +435,9 @@ class DiffTest(unittest.TestCase):
         Test a wrong class of rrset is rejected.
         """
         diff = Diff(self, Name('example.org.'))
-        rrset = RRset(Name('a.example.org.'), RRClass.CH(), RRType.NS(),
+        rrset = RRset(Name('a.example.org.'), RRClass.CH, RRType.NS,
                       self.__ttl)
-        rrset.add_rdata(Rdata(RRType.NS(), RRClass.CH(), 'ns.example.org.'))
+        rrset.add_rdata(Rdata(RRType.NS, RRClass.CH, 'ns.example.org.'))
         self.assertRaises(ValueError, diff.add_data, rrset)
         self.assertRaises(ValueError, diff.delete_data, rrset)
 
@@ -517,14 +517,14 @@ class DiffTest(unittest.TestCase):
         '''
         diff = Diff(self, Name('example.org.'))
         rrsig1 = RRset(Name('example.org'), self.__rrclass,
-                       RRType.RRSIG(), RRTTL(3600))
-        rrsig1.add_rdata(Rdata(RRType.RRSIG(), self.__rrclass,
+                       RRType.RRSIG, RRTTL(3600))
+        rrsig1.add_rdata(Rdata(RRType.RRSIG, self.__rrclass,
                                'A 5 3 3600 20000101000000 20000201000000 ' +
                                '0 example.org. FAKEFAKEFAKE'))
         diff.add_data(rrsig1)
         rrsig2 = RRset(Name('example.org'), self.__rrclass,
-                       RRType.RRSIG(), RRTTL(1800))
-        rrsig2.add_rdata(Rdata(RRType.RRSIG(), self.__rrclass,
+                       RRType.RRSIG, RRTTL(1800))
+        rrsig2.add_rdata(Rdata(RRType.RRSIG, self.__rrclass,
                                'AAAA 5 3 3600 20000101000000 20000201000000 ' +
                                '1 example.org. FAKEFAKEFAKE'))
         diff.add_data(rrsig2)
@@ -558,7 +558,7 @@ class DiffTest(unittest.TestCase):
         '''
         diff_multi = Diff(self, Name('example.org.'), single_update_mode=False)
         self.assertRaises(ValueError, diff_multi.find_updated,
-                          Name('example.org.'), RRType.A())
+                          Name('example.org.'), RRType.A)
         self.assertRaises(ValueError, diff_multi.find_all_updated,
                           Name('example.org.'))
 
@@ -571,12 +571,12 @@ class DiffTest(unittest.TestCase):
         '''
 
         # full rrset for A (to check compact())
-        txt = RRset(Name('c.example.org.'), self.__rrclass, RRType.TXT(),
+        txt = RRset(Name('c.example.org.'), self.__rrclass, RRType.TXT,
                     RRTTL(3600))
         txt.add_rdata(Rdata(txt.get_type(), txt.get_class(), "one"))
         txt.add_rdata(Rdata(txt.get_type(), txt.get_class(), "two"))
         txt.add_rdata(Rdata(txt.get_type(), txt.get_class(), "three"))
-        a = RRset(Name('d.example.org.'), self.__rrclass, RRType.A(),
+        a = RRset(Name('d.example.org.'), self.__rrclass, RRType.A,
                   RRTTL(3600))
         a.add_rdata(Rdata(a.get_type(), a.get_class(), "192.0.2.1"))
         a.add_rdata(Rdata(a.get_type(), a.get_class(), "192.0.2.2"))
@@ -680,7 +680,7 @@ class DiffTest(unittest.TestCase):
     def test_find(self):
         diff = Diff(self, Name('example.org.'))
         name = Name('www.example.org.')
-        rrtype = RRType.A()
+        rrtype = RRType.A
 
         self.assertFalse(self.__find_called)
         self.assertEqual(None, self.__find_name)
@@ -698,7 +698,7 @@ class DiffTest(unittest.TestCase):
     def test_find_options(self):
         diff = Diff(self, Name('example.org.'))
         name = Name('foo.example.org.')
-        rrtype = RRType.TXT()
+        rrtype = RRType.TXT
         options = ZoneFinder.NO_WILDCARD
 
         self.assertEqual("find_return", diff.find(name, rrtype, options))
@@ -998,8 +998,8 @@ class DiffTest(unittest.TestCase):
 
         # Add a second rr with different type at same name
         add_rrset = RRset(self.__rrset3.get_name(), self.__rrclass,
-                          RRType.A(), self.__ttl)
-        add_rrset.add_rdata(Rdata(RRType.A(), self.__rrclass, "192.0.2.2"))
+                          RRType.A, self.__ttl)
+        add_rrset.add_rdata(Rdata(RRType.A, self.__rrclass, "192.0.2.2"))
         diff.add_data(add_rrset)
 
         self.__check_find_all_call(diff.find_all_updated, self.__rrset3,
@@ -1131,8 +1131,8 @@ class DiffTest(unittest.TestCase):
         self.assertTrue(isinstance(collection, self.Collection))
         # The collection is just the mock from above, so this doesn't do much
         # testing, but we check that the mock got through and didn't get hurt.
-        self.assertIsNone(collection.find(Name('example.org'), RRClass.IN(),
-                                          RRType.SOA()))
+        self.assertIsNone(collection.find(Name('example.org'), RRClass.IN,
+                                          RRType.SOA))
 
 if __name__ == "__main__":
     isc.log.init("bind10")

+ 5 - 5
src/lib/util/unittests/fork.cc

@@ -93,10 +93,10 @@ provide_input(int *read_pipe, const void *input, const size_t length)
 
 /*
  * This creates a pipe, forks and reads the pipe and compares it
- * with given data. Used to check output of run in asynchronous way.
+ * with given data. Used to check output of run in an asynchronous way.
  */
 pid_t
-check_output(int *write_pipe, const void *output, const size_t length)
+check_output(int *write_pipe, const void* const output, const size_t length)
 {
     int pipes[2];
     if (pipe(pipes)) {
@@ -109,9 +109,7 @@ check_output(int *write_pipe, const void *output, const size_t length)
         return pid;
     } else {
         close(pipes[1]);
-        // We don't return the memory, but we're in tests and end this process
-        // right away.
-        unsigned char *buffer = new unsigned char[length + 1];
+        unsigned char* buffer = new unsigned char[length + 1];
         // Try to read one byte more to see if the output ends here
         size_t got_length(read_data(pipes[0], buffer, length + 1));
         bool ok(true);
@@ -133,8 +131,10 @@ check_output(int *write_pipe, const void *output, const size_t length)
                 fprintf(stderr, "%02hhx", output_c[i]);
             }
             fprintf(stderr, "\n");
+            delete [] buffer;
             exit(1);
         } else {
+            delete [] buffer;
             exit(0);
         }
     }

+ 2 - 2
src/lib/util/unittests/fork.h

@@ -40,10 +40,10 @@ bool
 process_ok(pid_t process);
 
 pid_t
-provide_input(int *read_pipe, const void *input, const size_t length);
+provide_input(int* read_pipe, const void* input, const size_t length);
 
 pid_t
-check_output(int *write_pipe, const void *output, const size_t length);
+check_output(int* write_pipe, const void* const output, const size_t length);
 
 } // End of the namespace
 }

+ 1 - 1
tools/query_cmp/src/lib/handledns.py

@@ -187,7 +187,7 @@ def send_req(query, server, port=53, timeout=5):
 
 	msg = Message(Message.RENDER)
 	msg.set_qid(int(qheader['id']))
-	msg.set_opcode(Opcode.QUERY())
+	msg.set_opcode(Opcode.QUERY)
 	msg.set_rcode(Rcode(int(qheader['rcode'])))
 
 	if qheader['qr'] == 1: