summaryrefslogtreecommitdiff
path: root/cloudinit/templater.py
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-08 17:59:31 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-08 17:59:31 -0700
commit1a415b187119fbdc4e08112a6afb23f1caf2b9ad (patch)
treeb7b767ede2d63f89019d53103451e429c16dc205 /cloudinit/templater.py
parent675341b3b1431eda2513d87d741c5b72d74e4405 (diff)
downloadvyos-cloud-init-1a415b187119fbdc4e08112a6afb23f1caf2b9ad.tar.gz
vyos-cloud-init-1a415b187119fbdc4e08112a6afb23f1caf2b9ad.zip
Ensure files end with ".tmpl" if they don't initially.
Diffstat (limited to 'cloudinit/templater.py')
-rw-r--r--cloudinit/templater.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/cloudinit/templater.py b/cloudinit/templater.py
index b6b320ab..5a3563a2 100644
--- a/cloudinit/templater.py
+++ b/cloudinit/templater.py
@@ -2,14 +2,17 @@ import os
from Cheetah.Template import Template
+from cloudinit import settings
from cloudinit import util
-TEMPLATE_DIR = '/etc/cloud/templates/'
-
def render_to_file(template, outfile, searchList):
- contents = Template(file=os.path.join(TEMPLATE_DIR, template),
- searchList=[searchList]).respond()
+ fn = template
+ (base, ext) = os.path.splitext(fn)
+ if ext != ".tmpl":
+ fn = "%s.tmpl" % (fn)
+ fn = os.path.join(settings.TEMPLATE_DIR, fn)
+ contents = Template(file=fn, searchList=[searchList]).respond()
util.write_file(outfile, contents)