Merge lp:~julian-edwards/maas/backport-r1303 into lp:maas/1.2

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 1325
Proposed branch: lp:~julian-edwards/maas/backport-r1303
Merge into: lp:maas/1.2
Diff against target: 108 lines (+87/-1)
3 files modified
src/maasserver/management/commands/set_up_dns.py (+1/-1)
src/maasserver/management/commands/write_dns_config.py (+34/-0)
src/maasserver/tests/test_commands_write_dns_config.py (+52/-0)
To merge this branch: bzr merge lp:~julian-edwards/maas/backport-r1303
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+137496@code.launchpad.net

Commit message

Add a command to write the full DNS config.  This will be called by the postinst script of maas-dns. (backport r1303)

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/management/commands/set_up_dns.py'
2--- src/maasserver/management/commands/set_up_dns.py 2012-08-13 11:04:44 +0000
3+++ src/maasserver/management/commands/set_up_dns.py 2012-12-03 07:43:19 +0000
4@@ -6,7 +6,7 @@
5 This creates a basic, blank DNS configuration which will allow MAAS to
6 reload its configuration once zone files will be written.
7
8-The main purpose of this command is for it to be run when MAAS is
9+The main purpose of this command is for it to be run when 'maas-dns' is
10 installed.
11 """
12
13
14=== added file 'src/maasserver/management/commands/write_dns_config.py'
15--- src/maasserver/management/commands/write_dns_config.py 1970-01-01 00:00:00 +0000
16+++ src/maasserver/management/commands/write_dns_config.py 2012-12-03 07:43:19 +0000
17@@ -0,0 +1,34 @@
18+# Copyright 2012 Canonical Ltd. This software is licensed under the
19+# GNU Affero General Public License version 3 (see the file LICENSE).
20+
21+"""Django command: write the MAAS named zone files.
22+
23+If any of the cluster controllers connected to this MAAS region controller
24+is configured to manage DNS, write the DNS configuration.
25+
26+The main purpose of this command is for it to be run when 'maas-dns' is
27+installed.
28+"""
29+
30+from __future__ import (
31+ absolute_import,
32+ print_function,
33+ unicode_literals,
34+ )
35+
36+__metaclass__ = type
37+__all__ = [
38+ 'Command',
39+ ]
40+
41+from django.core.management.base import BaseCommand
42+from maasserver.dns import write_full_dns_config
43+
44+
45+class Command(BaseCommand):
46+ help = (
47+ "Write the DNS configuration files and reload the DNS server if "
48+ "this region has cluster controllers configured to manage DNS.")
49+
50+ def handle(self, *args, **options):
51+ write_full_dns_config()
52
53=== added file 'src/maasserver/tests/test_commands_write_dns_config.py'
54--- src/maasserver/tests/test_commands_write_dns_config.py 1970-01-01 00:00:00 +0000
55+++ src/maasserver/tests/test_commands_write_dns_config.py 2012-12-03 07:43:19 +0000
56@@ -0,0 +1,52 @@
57+# Copyright 2012 Canonical Ltd. This software is licensed under the
58+# GNU Affero General Public License version 3 (see the file LICENSE).
59+
60+"""Tests for the write_dns_config command."""
61+
62+from __future__ import (
63+ absolute_import,
64+ print_function,
65+ unicode_literals,
66+ )
67+
68+__metaclass__ = type
69+__all__ = []
70+
71+
72+import os
73+
74+from celery.conf import conf
75+from django.core.management import call_command
76+from maasserver.testing.testcase import TestCase
77+from maasserver.testing.factory import factory
78+from django.conf import settings
79+from netaddr import (
80+ IPNetwork,
81+ )
82+from maasserver.enum import (
83+ NODEGROUP_STATUS,
84+ NODEGROUPINTERFACE_MANAGEMENT,
85+ )
86+from provisioningserver import tasks
87+from testtools.matchers import (
88+ FileExists,
89+ )
90+
91+
92+class TestWriteDNSConfigCommand(TestCase):
93+
94+ def test_write_dns_config_writes_zone_file(self):
95+ dns_conf_dir = self.make_dir()
96+ self.patch(conf, 'DNS_CONFIG_DIR', dns_conf_dir)
97+ self.patch(settings, 'DNS_CONNECT', True)
98+ # Prevent rndc task dispatch.
99+ self.patch(tasks, "rndc_command")
100+ domain = factory.getRandomString()
101+ factory.make_node_group(
102+ name=domain,
103+ network=IPNetwork('192.168.0.1/24'),
104+ status=NODEGROUP_STATUS.ACCEPTED,
105+ management=NODEGROUPINTERFACE_MANAGEMENT.DHCP_AND_DNS)
106+ call_command('write_dns_config')
107+ zone_file = os.path.join(dns_conf_dir, 'zone.%s' % domain)
108+ self.assertThat(zone_file, FileExists())

Subscribers

People subscribed via source and target branches

to status/vote changes: