Merge lp:~rvb/maas/write_dns_config-command into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 1303
Proposed branch: lp:~rvb/maas/write_dns_config-command
Merge into: lp:~maas-committers/maas/trunk
Prerequisite: lp:~rvb/maas/bug-1067977-dns-conf
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:~rvb/maas/write_dns_config-command
Reviewer Review Type Date Requested Status
Jeroen T. Vermeulen (community) Approve
Review via email: mp+131030@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.

Description of the change

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

maas-dns will call:
- Call the command 'set_up_dns' (set up all the RNDC config)
- restart bind (at this stage MAAS still cannot restart bind itself as the rndc key is still not loaded)
- Call the command 'write_dns_config'

The main goal of this fix is to cover for the following workflow:
1. the user configures an interface to manage DNS
2. looking at the logs, he suddenly realizes that he forgot to install the maas-dns package
3. the users installs maas-dns
At this stage, it is important that maas-dns calls the command write_dns_config so that the confi done in 1. is applied to the DNS config.

To post a comment you must log in.
Revision history for this message
Jeroen T. Vermeulen (jtv) wrote :

One small thing: in write_dns_config.py your help string uses the term “MAAS server.” I guess that should be “region controller” now. Or even just “region.”

Jeroen

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> One small thing: in write_dns_config.py your help string uses the term “MAAS
> server.” I guess that should be “region controller” now. Or even just
> “region.”

Good point, done.

bzr grep "MAAS server" tells me we need to make that change in a few other places as well ;)

Revision history for this message
MAAS Lander (maas-lander) wrote :

No proposals found for merge of lp:~rvb/maas/bug-1067977-dns-conf into lp:maas.

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-10-25 10:49: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-10-25 10:49: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-10-25 10:49: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())