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
=== modified file 'src/maasserver/management/commands/set_up_dns.py'
--- src/maasserver/management/commands/set_up_dns.py 2012-08-13 11:04:44 +0000
+++ src/maasserver/management/commands/set_up_dns.py 2012-12-03 07:43:19 +0000
@@ -6,7 +6,7 @@
6This creates a basic, blank DNS configuration which will allow MAAS to6This creates a basic, blank DNS configuration which will allow MAAS to
7reload its configuration once zone files will be written.7reload its configuration once zone files will be written.
88
9The main purpose of this command is for it to be run when MAAS is9The main purpose of this command is for it to be run when 'maas-dns' is
10installed.10installed.
11"""11"""
1212
1313
=== added file 'src/maasserver/management/commands/write_dns_config.py'
--- src/maasserver/management/commands/write_dns_config.py 1970-01-01 00:00:00 +0000
+++ src/maasserver/management/commands/write_dns_config.py 2012-12-03 07:43:19 +0000
@@ -0,0 +1,34 @@
1# Copyright 2012 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Django command: write the MAAS named zone files.
5
6If any of the cluster controllers connected to this MAAS region controller
7is configured to manage DNS, write the DNS configuration.
8
9The main purpose of this command is for it to be run when 'maas-dns' is
10installed.
11"""
12
13from __future__ import (
14 absolute_import,
15 print_function,
16 unicode_literals,
17 )
18
19__metaclass__ = type
20__all__ = [
21 'Command',
22 ]
23
24from django.core.management.base import BaseCommand
25from maasserver.dns import write_full_dns_config
26
27
28class Command(BaseCommand):
29 help = (
30 "Write the DNS configuration files and reload the DNS server if "
31 "this region has cluster controllers configured to manage DNS.")
32
33 def handle(self, *args, **options):
34 write_full_dns_config()
035
=== added file 'src/maasserver/tests/test_commands_write_dns_config.py'
--- src/maasserver/tests/test_commands_write_dns_config.py 1970-01-01 00:00:00 +0000
+++ src/maasserver/tests/test_commands_write_dns_config.py 2012-12-03 07:43:19 +0000
@@ -0,0 +1,52 @@
1# Copyright 2012 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Tests for the write_dns_config command."""
5
6from __future__ import (
7 absolute_import,
8 print_function,
9 unicode_literals,
10 )
11
12__metaclass__ = type
13__all__ = []
14
15
16import os
17
18from celery.conf import conf
19from django.core.management import call_command
20from maasserver.testing.testcase import TestCase
21from maasserver.testing.factory import factory
22from django.conf import settings
23from netaddr import (
24 IPNetwork,
25 )
26from maasserver.enum import (
27 NODEGROUP_STATUS,
28 NODEGROUPINTERFACE_MANAGEMENT,
29 )
30from provisioningserver import tasks
31from testtools.matchers import (
32 FileExists,
33 )
34
35
36class TestWriteDNSConfigCommand(TestCase):
37
38 def test_write_dns_config_writes_zone_file(self):
39 dns_conf_dir = self.make_dir()
40 self.patch(conf, 'DNS_CONFIG_DIR', dns_conf_dir)
41 self.patch(settings, 'DNS_CONNECT', True)
42 # Prevent rndc task dispatch.
43 self.patch(tasks, "rndc_command")
44 domain = factory.getRandomString()
45 factory.make_node_group(
46 name=domain,
47 network=IPNetwork('192.168.0.1/24'),
48 status=NODEGROUP_STATUS.ACCEPTED,
49 management=NODEGROUPINTERFACE_MANAGEMENT.DHCP_AND_DNS)
50 call_command('write_dns_config')
51 zone_file = os.path.join(dns_conf_dir, 'zone.%s' % domain)
52 self.assertThat(zone_file, FileExists())

Subscribers

People subscribed via source and target branches

to status/vote changes: