34
34
# on TCP connections - otherwise data corruption will occur.
37
def handle(_name, cfg, cloud, log, _args):
37
def handle(_name, cfg, _cloud, log, _args):
39
39
apt_pipe_value = util.get_cfg_option_str(cfg, "apt_pipelining", False)
40
40
apt_pipe_value_s = str(apt_pipe_value).lower().strip()
42
42
if apt_pipe_value_s == "false":
43
write_apt_snippet(cloud, "0", log, DEFAULT_FILE)
43
write_apt_snippet("0", log, DEFAULT_FILE)
44
44
elif apt_pipe_value_s in ("none", "unchanged", "os"):
46
46
elif apt_pipe_value_s in [str(b) for b in xrange(0, 6)]:
47
write_apt_snippet(cloud, apt_pipe_value_s, log, DEFAULT_FILE)
47
write_apt_snippet(apt_pipe_value_s, log, DEFAULT_FILE)
49
49
log.warn("Invalid option for apt_pipeling: %s", apt_pipe_value)
52
def write_apt_snippet(cloud, setting, log, f_name):
52
def write_apt_snippet(setting, log, f_name):
53
53
"""Writes f_name with apt pipeline depth 'setting'."""
55
55
file_contents = APT_PIPE_TPL % (setting)
57
util.write_file(cloud.paths.join(False, f_name), file_contents)
56
util.write_file(f_name, file_contents)
59
57
log.debug("Wrote %s with apt pipeline depth setting %s", f_name, setting)