summaryrefslogtreecommitdiff
path: root/nova/virt/netutils.py
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2014-05-27 16:09:40 -0500
committerRick Harris <rconradharris@gmail.com>2014-07-11 10:00:09 -0500
commit383d0c945e4874d7e66ad8ed03fe6556ac7c03d8 (patch)
tree169aca65e98dfef388f15535ba84729e941e3959 /nova/virt/netutils.py
parent031add7a82fb088ae9a4586189cc5f89c1a303b6 (diff)
downloadnova-383d0c945e4874d7e66ad8ed03fe6556ac7c03d8.tar.gz
Fix interfaces template for two interfaces and IPv6
If you have more than one interface and IPv6 enabled, then the interfaces file emitted would have the incorrect syntax: the `auto eth1` line would be appended to the end of the `gateway` line of the previous stanza. This was a result of improper whitespace control in the Jinja template which this patch fixes. In order to prevent regressions, this patch swaps out the existing tests with corresponding tests that are whitespace sensitive. This is important because it's difficult to tweak Jinja templates in a way that fixes the whitespace for one scenario while not breaking another. Closes-Bug: 1339888 Change-Id: Id5566ea2f93ee1a6b8bc42e83bc64a1c6a09e680
Diffstat (limited to 'nova/virt/netutils.py')
-rw-r--r--nova/virt/netutils.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/nova/virt/netutils.py b/nova/virt/netutils.py
index a4bc773ac7..225607cf34 100644
--- a/nova/virt/netutils.py
+++ b/nova/virt/netutils.py
@@ -140,12 +140,9 @@ def get_injected_network_template(network_info, use_ipv6=CONF.use_ipv6,
if not nets:
return
- return build_template(template, nets, ipv6_is_available)
-
-
-def build_template(template, nets, ipv6_is_available):
tmpl_path, tmpl_file = os.path.split(CONF.injected_network_template)
- env = jinja2.Environment(loader=jinja2.FileSystemLoader(tmpl_path))
+ env = jinja2.Environment(loader=jinja2.FileSystemLoader(tmpl_path),
+ trim_blocks=True)
template = env.get_template(tmpl_file)
return template.render({'interfaces': nets,
'use_ipv6': ipv6_is_available})