summaryrefslogtreecommitdiff
path: root/ec2init/CloudConfig.py
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2010-01-26 16:40:10 -0500
committerScott Moser <smoser@ubuntu.com>2010-01-26 16:40:10 -0500
commit63ba097865e1d038d82a7fa1d6efd282784677f5 (patch)
tree1616db14a425c16c1b52d8cda6442b6eef52c536 /ec2init/CloudConfig.py
parentaf394388ff0985b4b407ed4faeb105395655d102 (diff)
downloadvyos-cloud-init-63ba097865e1d038d82a7fa1d6efd282784677f5.tar.gz
vyos-cloud-init-63ba097865e1d038d82a7fa1d6efd282784677f5.zip
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.
Diffstat (limited to 'ec2init/CloudConfig.py')
-rw-r--r--ec2init/CloudConfig.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/ec2init/CloudConfig.py b/ec2init/CloudConfig.py
index 6c661260..51618943 100644
--- a/ec2init/CloudConfig.py
+++ b/ec2init/CloudConfig.py
@@ -99,6 +99,13 @@ class CloudConfig():
update = util.get_cfg_option_bool(self.cfg, 'apt_update', False)
upgrade = util.get_cfg_option_bool(self.cfg, 'apt_upgrade', False)
+ if not util.get_cfg_option_bool(self.cfg, \
+ 'apt_preserve_sources_list', False):
+ if self.cfg.has_key("apt_mirror"):
+ mirror = self.cfg["apt_mirror"]
+ else:
+ mirror = self.cloud.get_mirror()
+ generate_sources_list(mirror)
# process 'apt_sources'
if self.cfg.has_key('apt_sources'):
@@ -277,3 +284,11 @@ def add_sources(srclist):
elst.append([source, "failed write to file %s" % ent['filename']])
return(elst)
+
+
+def generate_sources_list(mirror):
+ stdout, stderr = subprocess.Popen(['lsb_release', '-cs'], stdout=subprocess.PIPE).communicate()
+ codename = stdout.strip()
+
+ util.render_to_file('sources.list', '/etc/apt/sources.list', \
+ { 'mirror' : mirror, 'codename' : codename })