← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/bind-dev-service into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/bind-dev-service into lp:maas with lp:~rvb/maas/dns-fixture as a prerequisite.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/bind-dev-service/+merge/113933

This branch adds a bind dev service.

The service dynamically creates the required configuration (in etc/named) using the fixture's methods.

= Notes =

You'll see that the config gets rewritten (in services/dns/set_up_named.py) every single time the service is started.  I considered writing these files only once but generating the config files (and the copying the executable) is quick [<1s on my machine] and this will avoid weird caching issue.
-- 
https://code.launchpad.net/~rvb/maas/bind-dev-service/+merge/113933
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/bind-dev-service into lp:maas.
=== modified file '.bzrignore'
--- .bzrignore	2012-06-24 13:31:20 +0000
+++ .bzrignore	2012-07-09 10:18:20 +0000
@@ -14,6 +14,7 @@
 ./docs/_build
 ./docs/api.rst
 ./eggs
+./etc/named
 ./include
 ./lib
 ./local

=== modified file 'Makefile'
--- Makefile	2012-07-05 20:19:59 +0000
+++ Makefile	2012-07-09 10:18:20 +0000
@@ -139,6 +139,7 @@
 	$(RM) -r docs/_build
 	$(RM) -r run/* services/*/supervise
 	$(RM) twisted/plugins/dropin.cache
+	$(RM) etc/named
 
 harness: bin/maas bin/database
 	$(dbrun) bin/maas shell --settings=maas.demo
@@ -173,7 +174,7 @@
 # Development services.
 #
 
-service_names := celeryd database pserv reloader txlongpoll web webapp
+service_names := celeryd database dns pserv reloader txlongpoll web webapp
 services := $(patsubst %,services/%/,$(service_names))
 
 run:
@@ -246,6 +247,8 @@
 
 # Dependencies for individual services.
 
+services/dns/@deps: bin/maas
+
 services/celeryd/@deps:
 
 services/database/@deps: bin/database

=== added directory 'services/dns'
=== added file 'services/dns/run'
--- services/dns/run	1970-01-01 00:00:00 +0000
+++ services/dns/run	2012-07-09 10:18:20 +0000
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+# Exit immediately if a command exits with a non-zero status.
+set -o errexit
+
+# Move to the project root.
+cd "$(dirname "$0")/../.."
+
+# Start logging, if requested. Not using multilog here right now
+# because there are race issues when restarting.
+[ -z "${logdir:-}" ] || exec &>> "${logdir}/current"
+
+# Set up named.
+./bin/py services/dns/set_up_named.py
+# Run named.
+exec ./etc/named/named -g -c ./etc/named/named.conf

=== added file 'services/dns/set_up_named.py'
--- services/dns/set_up_named.py	1970-01-01 00:00:00 +0000
+++ services/dns/set_up_named.py	2012-07-09 10:18:20 +0000
@@ -0,0 +1,44 @@
+# Copyright 2012 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Setup configuration files required to run `named` in etc/named.
+"""
+
+from __future__ import (
+    absolute_import,
+    print_function,
+    unicode_literals,
+    )
+
+__metaclass__ = type
+__all__ = []
+
+import os
+import shutil
+
+from maastesting.bindfixture import set_up_named
+
+
+PROJECT_DIR = os.path.join(
+    os.path.dirname(os.path.abspath(__file__)), os.pardir, os.pardir)
+
+
+NAMED_HOMEDIR = os.path.join(
+    PROJECT_DIR, 'etc', 'named')
+
+
+if __name__ == "__main__":
+    # Cleanup the old configuration.
+    shutil.rmtree(NAMED_HOMEDIR)
+    # Create the directory.
+    os.makedirs(NAMED_HOMEDIR)
+    # Write the config.
+    set_up_named(
+        homedir=NAMED_HOMEDIR,
+        port=5244,
+        rndc_port=5245,
+        log_file=os.path.join(PROJECT_DIR, 'logs', 'dns', 'current'),
+        named_file=os.path.join(NAMED_HOMEDIR, 'named'),
+        conf_file=os.path.join(NAMED_HOMEDIR, 'named.conf'),
+        rndcconf_file=os.path.join(NAMED_HOMEDIR, 'rndc.conf')
+        )