~smoser/ec2-init/ec2-init.devel

« back to all changes in this revision

Viewing changes to ec2init/util.py

  • Committer: Scott Moser
  • Date: 2010-01-26 21:40:10 UTC
  • Revision ID: smoser@ubuntu.com-20100126214010-6jkp07u571wfeun1
move writing sources.list to CloudConfig. add 'apt_preserve_sources_list'

Move the writing of sources.list to CloudConfig.  This way we have
access to the cloud-config user data.  Then, allow the user
to specify the archive mirror using 'apt_mirror' key. 

Now, if specified in cloud-config, that is used, otherwise, we 
get one from the DataSource.

One other change here is adding 'apt_preserve_sources_list'.  If set to
true, then overwriting of the sources.list with the selected mirror
will not be done.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
import os
3
3
import errno
4
4
import subprocess
 
5
from Cheetah.Template import Template
5
6
 
6
7
def read_conf(fname):
7
8
        stream = file(fname)
69
70
    if sp.returncode is not 0:
70
71
        raise subprocess.CalledProcessError(sp.returncode,args)
71
72
    return(out,err)
 
73
 
 
74
def render_to_file(template, outfile, searchList):
 
75
    t = Template(file='/etc/ec2-init/templates/%s.tmpl' % template, searchList=[searchList])
 
76
    f = open(outfile, 'w')
 
77
    f.write(t.respond())
 
78
    f.close()
 
79