Merge lp:~smoser/ubuntu/lucid/cloud-init/lp942961-apt-pipeline into lp:ubuntu/lucid-updates/cloud-init

Proposed by Scott Moser on 2012-03-14
Status: Merged
Merge reported by: Scott Moser
Merged at revision: not available
Proposed branch: lp:~smoser/ubuntu/lucid/cloud-init/lp942961-apt-pipeline
Merge into: lp:ubuntu/lucid-updates/cloud-init
Diff against target: 88 lines (+52/-0)
3 files modified
cloudinit/CloudConfig.py (+29/-0)
debian/changelog (+9/-0)
debian/cloud-init.postinst (+14/-0)
To merge this branch: bzr merge lp:~smoser/ubuntu/lucid/cloud-init/lp942961-apt-pipeline
Reviewer Review Type Date Requested Status
Ubuntu Development Team 2012-03-14 Pending
Review via email: mp+97493@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cloudinit/CloudConfig.py'
2--- cloudinit/CloudConfig.py 2010-12-02 09:42:17 +0000
3+++ cloudinit/CloudConfig.py 2012-03-14 19:22:19 +0000
4@@ -41,6 +41,7 @@
5 self.cloud = cloudinit.CloudInit()
6 self.cfg = self.get_config_obj(cfgfile)
7 self.cloud.get_data_source()
8+ self.add_handler('apt-pipelining', self.h_apt_pipelining)
9 self.add_handler('apt-update-upgrade', self.h_apt_update_upgrade)
10 self.add_handler('config-ssh')
11 self.add_handler('disable-ec2-metadata',
12@@ -435,6 +436,34 @@
13 warn("Failed to run debconf-set-selections for grub-dpkg")
14 warn(traceback.format_exc())
15
16+ def h_apt_pipelining(self, name, args):
17+ # handle configuration of apt pipelining
18+
19+ apt_pipe_value = util.get_cfg_option_str(self.cfg,
20+ "apt_pipelining", False)
21+ apt_pipe_value = str(apt_pipe_value).lower()
22+
23+ if apt_pipe_value == "false":
24+ write_apt_snippet("0")
25+
26+ elif apt_pipe_value in ("none", "unchanged", "os"):
27+ return
28+
29+ elif apt_pipe_value in str(range(0, 6)):
30+ write_apt_snippet(apt_pipe_value)
31+
32+ else:
33+ warn("Invalid option for apt_pipeling: %s" % apt_pipe_value)
34+
35+
36+def write_apt_snippet(setting, f_name="/etc/apt/apt.conf.d/90cloud-init-pipelining"):
37+ """ Writes f_name with apt pipeline depth 'setting' """
38+
39+ acquire_pipeline_depth = 'Acquire::http::Pipeline-Depth "%s";\n'
40+ file_contents = ("//Written by cloud-init per 'apt_pipelining'\n"
41+ + (acquire_pipeline_depth % setting))
42+
43+ util.write_file(f_name, file_contents)
44
45 def apply_credentials(keys, user, disable_root):
46 keys = set(keys)
47
48=== modified file 'debian/changelog'
49--- debian/changelog 2010-12-02 09:42:17 +0000
50+++ debian/changelog 2012-03-14 19:22:19 +0000
51@@ -1,3 +1,12 @@
52+cloud-init (0.5.10-0ubuntu1.7) UNRELEASED; urgency=low
53+
54+ * add ability to configure Acquire::http::Pipeline-Depth via
55+ cloud-config setting 'apt_pipelining' (LP: #942061)
56+ * debian/cloud-init.postinst: address population of apt_pipeline
57+ setting on installation.
58+
59+ -- Scott Moser <smoser@ubuntu.com> Wed, 14 Mar 2012 14:45:45 -0400
60+
61 cloud-init (0.5.10-0ubuntu1.5) lucid-proposed; urgency=low
62
63 * make grub-config code run on instance first boot so user is not
64
65=== modified file 'debian/cloud-init.postinst'
66--- debian/cloud-init.postinst 2010-02-05 15:48:21 +0000
67+++ debian/cloud-init.postinst 2012-03-14 19:22:19 +0000
68@@ -6,6 +6,20 @@
69 # disable ureadahead (LP: #499520)
70 dpkg-divert --package cloud-init --rename --divert \
71 /etc/init/ureadahead.conf.disabled --add /etc/init/ureadahead.conf
72+
73+ # we want to affect apt_pipelining on install, not wait for
74+ # cloud-init to run it on next boot.
75+ pipeline_f="/etc/apt/apt.conf.d/90cloud-init-pipelining"
76+ if [ -f /var/lib/cloud/data/cache/obj.pkl ]; then
77+ cloud-init-cfg apt-pipelining once-per-instance >/dev/null 2>&1 ||
78+ echo "Warning: failed to setup apt-pipelining" 1>&2
79+ elif [ ! -f "$pipeline_f" ]; then
80+ # there was no cloud available, so populate it ourselves.
81+ cat > "$pipeline_f" <<EOF
82+//Written by cloud-init per 'apt_pipelining'
83+Acquire::http::Pipeline-Depth "0";
84+EOF
85+ fi
86 fi
87
88 #DEBHELPER#

Subscribers

People subscribed via source and target branches

to all changes: