summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-07-09 16:41:45 -0400
committerScott Moser <smoser@ubuntu.com>2012-07-09 16:41:45 -0400
commit75af023c864d1b6c4e48788b1b4cf7aad5eb2204 (patch)
tree2f79d479ee27ecb26faa94b91ea47e10b63c6612 /cloudinit
parent50b9e8b7be096e331eb070c5c48d833b1756463c (diff)
downloadvyos-cloud-init-75af023c864d1b6c4e48788b1b4cf7aad5eb2204.tar.gz
vyos-cloud-init-75af023c864d1b6c4e48788b1b4cf7aad5eb2204.zip
Revert back to using cheetah + adjust resultant code + templates
At this point there is a mixture of "double hash" cheetah comments and '#*' cheetah comments.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_final_message.py17
-rw-r--r--cloudinit/config/cc_update_etc_hosts.py6
-rw-r--r--cloudinit/templater.py11
3 files changed, 15 insertions, 19 deletions
diff --git a/cloudinit/config/cc_final_message.py b/cloudinit/config/cc_final_message.py
index b1caca47..3865332f 100644
--- a/cloudinit/config/cc_final_message.py
+++ b/cloudinit/config/cc_final_message.py
@@ -26,23 +26,20 @@ from cloudinit.settings import PER_ALWAYS
frequency = PER_ALWAYS
-FINAL_MESSAGE_DEF = ("Cloud-init v. {{version}} finished at {{timestamp}}."
- " Up {{uptime}} seconds.")
+# Cheetah formated default message
+FINAL_MESSAGE_DEF = ("Cloud-init v. ${version} finished at ${timestamp}."
+ " Up ${uptime} seconds.")
def handle(_name, cfg, cloud, log, args):
- msg_in = None
+ msg_in = ''
if len(args) != 0:
- msg_in = args[0]
+ msg_in = str(args[0])
else:
- msg_in = util.get_cfg_option_str(cfg, "final_message")
-
- if not msg_in:
- template_fn = cloud.get_template_filename('final_message')
- if template_fn:
- msg_in = util.load_file(template_fn)
+ msg_in = util.get_cfg_option_str(cfg, "final_message". msg_in)
+ msg_in = msg_in.strip()
if not msg_in:
msg_in = FINAL_MESSAGE_DEF
diff --git a/cloudinit/config/cc_update_etc_hosts.py b/cloudinit/config/cc_update_etc_hosts.py
index c148b12e..38108da7 100644
--- a/cloudinit/config/cc_update_etc_hosts.py
+++ b/cloudinit/config/cc_update_etc_hosts.py
@@ -36,11 +36,11 @@ def handle(name, cfg, cloud, log, _args):
return
# Render from a template file
- distro_n = cloud.distro.name
- tpl_fn_name = cloud.get_template_filename("hosts.%s" % (distro_n))
+ tpl_fn_name = cloud.get_template_filename("hosts.%s" %
+ (cloud.distro.name))
if not tpl_fn_name:
raise RuntimeError(("No hosts template could be"
- " found for distro %s") % (distro_n))
+ " found for distro %s") % (cloud.distro.name))
out_fn = cloud.paths.join(False, '/etc/hosts')
templater.render_to_file(tpl_fn_name, out_fn,
diff --git a/cloudinit/templater.py b/cloudinit/templater.py
index c4259fa0..77af1270 100644
--- a/cloudinit/templater.py
+++ b/cloudinit/templater.py
@@ -20,13 +20,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-from tempita import Template
+from Cheetah.Template import Template
from cloudinit import util
def render_from_file(fn, params):
- return render_string(util.load_file(fn), params, name=fn)
+ return render_string(util.load_file(fn), params)
def render_to_file(fn, outfn, params, mode=0644):
@@ -34,8 +34,7 @@ def render_to_file(fn, outfn, params, mode=0644):
util.write_file(outfn, contents, mode=mode)
-def render_string(content, params, name=None):
- tpl = Template(content, name=name)
+def render_string(content, params):
if not params:
- params = dict()
- return tpl.substitute(params)
+ params = {}
+ return Template(content, searchList=[params]).respond()