Browse Source

[2380] introduced some initial framework for new loadzone

JINMEI Tatuya 12 years ago
parent
commit
e7f01efd35

+ 2 - 0
configure.ac

@@ -1176,6 +1176,7 @@ AC_CONFIG_FILES([Makefile
                  src/bin/dbutil/tests/Makefile
                  src/bin/dbutil/tests/testdata/Makefile
                  src/bin/loadzone/Makefile
+                 src/bin/loadzone/tests/Makefile
                  src/bin/loadzone/tests/correct/Makefile
                  src/bin/loadzone/tests/error/Makefile
                  src/bin/msgq/Makefile
@@ -1352,6 +1353,7 @@ AC_OUTPUT([doc/version.ent
            src/bin/loadzone/tests/correct/correct_test.sh
            src/bin/loadzone/tests/error/error_test.sh
            src/bin/loadzone/b10-loadzone.py
+           src/bin/loadzone/loadzone.py
            src/bin/usermgr/run_b10-cmdctl-usermgr.sh
            src/bin/usermgr/b10-cmdctl-usermgr.py
            src/bin/msgq/msgq.py

+ 11 - 1
src/bin/loadzone/Makefile.am

@@ -1,8 +1,13 @@
-SUBDIRS = . tests/correct tests/error
+#SUBDIRS = . tests/correct tests/error  <= TBD: clean this up later
+SUBDIRS = . tests
 bin_SCRIPTS = b10-loadzone
+# tentative setup: clean this up:
+bin_SCRIPTS += b10-loadzone-ng
 noinst_SCRIPTS = run_loadzone.sh
 
 CLEANFILES = b10-loadzone
+# tentative setup: clean this up:
+CLEANFILES += b10-loadzone-ng
 
 man_MANS = b10-loadzone.8
 DISTCLEANFILES = $(man_MANS)
@@ -27,6 +32,11 @@ b10-loadzone: b10-loadzone.py
 	       -e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" b10-loadzone.py >$@
 	chmod a+x $@
 
+# tentatively named "-ng".
+b10-loadzone-ng: loadzone.py
+	$(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" loadzone.py >$@
+	chmod a+x $@
+
 EXTRA_DIST += tests/normal/README
 EXTRA_DIST += tests/normal/dsset-subzone.example.com
 EXTRA_DIST += tests/normal/example.com

+ 52 - 0
src/bin/loadzone/loadzone.py.in

@@ -0,0 +1,52 @@
+#!@PYTHON@
+
+# Copyright (C) 2012  Internet Systems Consortium.
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+import sys
+sys.path.append('@@PYTHONPATH@@')
+from optparse import OptionParser
+import isc.log
+
+isc.log.init("b10-loadzone", buffer=True)
+logger = isc.log.Logger("loadzone")
+
+def set_cmd_options(parser):
+    '''Helper function to set command-line options.
+
+    '''
+    parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
+            help="display more about what is going on")
+
+class LoadZoneRunner:
+    '''TBD
+
+    '''
+    def __init__(self, command_args):
+        usage_txt = 'usage: %prog [options] zonename zonefile'
+        parser = OptionParser(usage=usage_txt)
+        set_cmd_options(parser)
+        (options, args) = parser.parse_args(args=command_args)
+
+    def run(self):
+        pass
+
+if '__main__' == __name__:
+    runner = LoadZoneRunner(sys.argv[1:])
+    runner.run()
+
+## Local Variables:
+## mode: python
+## End:

File diff suppressed because it is too large
+ 25 - 0
src/bin/loadzone/tests/Makefile.am


+ 38 - 0
src/bin/loadzone/tests/loadzone_test.py

@@ -0,0 +1,38 @@
+# Copyright (C) 2012  Internet Systems Consortium.
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
+# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
+# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+'''Tests for the loadzone module'''
+
+import unittest
+from loadzone import *
+import isc.log
+
+class TestLoadZoneRunner(unittest.TestCase):
+    def setUp(self):
+        pass
+
+    def tearDown(self):
+        pass
+
+    def test_dummy(self):
+        '''
+        Test the old socket file is removed (if any) and a new socket
+        is created when the ddns server is created.
+        '''
+        runner = LoadZoneRunner(['-h', 'example.org', 'example.zone'])
+
+if __name__== "__main__":
+    isc.log.resetUnitTestRootLogger()
+    unittest.main()