summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordanP <jordan.pittier@cloudwatt.com>2014-09-16 09:44:35 +0000
committerJordanP <jordan.pittier@cloudwatt.com>2014-09-16 12:40:55 +0000
commit0468eca1ab356170975de521bbcf93c445a4e0cd (patch)
tree978771c5de80c32afd80846570f3e72df4a984b6
parenta31e41ecaca791286ab7b93b0035b6b1dd89a5e8 (diff)
downloaddesignate-0468eca1ab356170975de521bbcf93c445a4e0cd.tar.gz
Bind9 zone file should end with a new line
This patchs add a new empty line at the end of the zone template. Otherwise Bind9 complains with "named[21602]: $PATH/example.net._$ID.zone:18: file does not end with newline" Change-Id: Ib73ac32e8e793aa79114879ae0017dbfb725f813
-rw-r--r--designate/resources/templates/bind9-zone.jinja21
-rw-r--r--designate/tests/test_resources/test_templates/__init__.py0
-rw-r--r--designate/tests/test_resources/test_templates/test_bind9.py28
-rw-r--r--designate/tests/test_utils.py5
-rw-r--r--designate/utils.py2
5 files changed, 35 insertions, 1 deletions
diff --git a/designate/resources/templates/bind9-zone.jinja2 b/designate/resources/templates/bind9-zone.jinja2
index 25966509..af148501 100644
--- a/designate/resources/templates/bind9-zone.jinja2
+++ b/designate/resources/templates/bind9-zone.jinja2
@@ -16,3 +16,4 @@ $TTL {{ domain.ttl }}
{% for record in records %}
{{record.name}} {{record.ttl or ''}} IN {{record.type}} {{record.priority or ''}} {{record.data}}
{%- endfor %}
+
diff --git a/designate/tests/test_resources/test_templates/__init__.py b/designate/tests/test_resources/test_templates/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/designate/tests/test_resources/test_templates/__init__.py
diff --git a/designate/tests/test_resources/test_templates/test_bind9.py b/designate/tests/test_resources/test_templates/test_bind9.py
new file mode 100644
index 00000000..2b35ee02
--- /dev/null
+++ b/designate/tests/test_resources/test_templates/test_bind9.py
@@ -0,0 +1,28 @@
+# Copyright 2014 Cloudwatt
+#
+# Author: Jordan Pittier <jordan.pittier@cloudwatt.com>
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+from designate.openstack.common import log as logging
+from designate.tests import TestCase
+from designate import utils
+
+
+LOG = logging.getLogger(__name__)
+
+
+class Bind9Test(TestCase):
+ def test_bind9_zone_ends_with_empty_line(self):
+ name = ['templates', 'bind9-zone.jinja2']
+ resource_string = utils.resource_string(*name)
+ self.assertEqual('\n\n', resource_string[-2:])
diff --git a/designate/tests/test_utils.py b/designate/tests/test_utils.py
index 949bff58..82634ee1 100644
--- a/designate/tests/test_utils.py
+++ b/designate/tests/test_utils.py
@@ -54,6 +54,11 @@ class TestUtils(TestCase):
self.assertIsInstance(template, Template)
+ def test_load_template_keep_trailing_newline(self):
+ name = 'bind9-config.jinja2'
+ template = utils.load_template(name)
+ self.assertTrue(template.environment.keep_trailing_newline)
+
def test_load_template_missing(self):
name = 'invalid.jinja2'
diff --git a/designate/utils.py b/designate/utils.py
index 8d60a770..6deb7a8c 100644
--- a/designate/utils.py
+++ b/designate/utils.py
@@ -114,7 +114,7 @@ def load_schema(version, name):
def load_template(template_name):
template_string = resource_string('templates', template_name)
- return Template(template_string)
+ return Template(template_string, keep_trailing_newline=True)
def render_template(template, **template_context):