summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-12-16 16:37:01 -0500
committerScott Moser <smoser@ubuntu.com>2011-12-16 16:37:01 -0500
commitcdbbd670524a5d99113026e4caaebe79c886e89c (patch)
tree61c3e0196b4d31549e40d92eb744ab631b06493f
parent9d13bb03c7615291b5a37b3f7afb18f3621df41b (diff)
downloadvyos-cloud-init-cdbbd670524a5d99113026e4caaebe79c886e89c.tar.gz
vyos-cloud-init-cdbbd670524a5d99113026e4caaebe79c886e89c.zip
add apt_proxy support
-rw-r--r--cloudinit/CloudConfig/cc_apt_update_upgrade.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/cloudinit/CloudConfig/cc_apt_update_upgrade.py b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
index 8d98b3a8..1e057b31 100644
--- a/cloudinit/CloudConfig/cc_apt_update_upgrade.py
+++ b/cloudinit/CloudConfig/cc_apt_update_upgrade.py
@@ -39,6 +39,20 @@ def handle(name,cfg,cloud,log,args):
"archive.ubuntu.com/ubuntu")
rename_apt_lists(old_mir, mirror)
+
+ # set up proxy
+ proxy = cfg.get("apt_proxy", None)
+ proxy_filename = "/etc/apt/apt.conf.d/95cloud-init-proxy"
+ if proxy:
+ try:
+ contents = "Acquire::HTTP::Proxy:: \"%s\";\n"
+ with open(proxy_filename,"w") as fp:
+ fp.write(contents % proxy)
+ except Exception as e:
+ log.warn("Failed to write proxy to %s" % proxy_filename)
+ elif os.path.isfile(proxy_filename):
+ os.unlink(proxy_filename)
+
# process 'apt_sources'
if cfg.has_key('apt_sources'):
errors = add_sources(cfg['apt_sources'],