Merge lp:~gnuoy/charms/precise/squid-reverseproxy/fix-for-squid-3.2 into lp:charms/squid-reverseproxy

Proposed by Liam Young
Status: Merged
Merged at revision: 44
Proposed branch: lp:~gnuoy/charms/precise/squid-reverseproxy/fix-for-squid-3.2
Merge into: lp:charms/squid-reverseproxy
Diff against target: 50 lines (+13/-0)
2 files modified
hooks/hooks.py (+10/-0)
templates/main_config.template (+3/-0)
To merge this branch: bzr merge lp:~gnuoy/charms/precise/squid-reverseproxy/fix-for-squid-3.2
Reviewer Review Type Date Requested Status
Tom Haddon Approve
Review via email: mp+211457@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Liam Young (gnuoy) wrote :

Sorry, an 'i' sneaked into the link referenced in the commit comment. It should be http://wiki.squid-cache.org/Squid-3.2

Revision history for this message
Tom Haddon (mthaddon) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/hooks.py'
2--- hooks/hooks.py 2013-10-29 17:37:20 +0000
3+++ hooks/hooks.py 2014-03-18 09:13:44 +0000
4@@ -11,6 +11,7 @@
5 import yaml
6 import collections
7 import socket
8+import apt_pkg
9
10 from charmhelpers.core.hookenv import (
11 config as config_get,
12@@ -243,6 +244,14 @@
13 16 * int(config_data['target_objs_per_dir']) * int(
14 config_data['avg_obj_size_kb'])))))
15 config_data['cache_l2'] = config_data['cache_l1'] * 16
16+ apt_pkg.init()
17+ cache = apt_pkg.Cache()
18+ pkg = cache['squid3']
19+ # From 3.2 the manager, localhost, and to_localhost ACL definitions are now
20+ # built-in. So, detect the package version and remove the definitions from
21+ # the generated config
22+ need_localacl_defs = apt_pkg.version_compare(pkg.current_ver.ver_str,
23+ '3.2')
24 templ_vars = {
25 'config': config_data,
26 'sites': reverse_sites,
27@@ -250,6 +259,7 @@
28 'only_direct': only_direct,
29 'refresh_patterns': refresh_patterns,
30 'default_refresh_pattern': default_refresh_pattern,
31+ 'need_localacl_defs': need_localacl_defs,
32 }
33 template = template_env.get_template('main_config.template').\
34 render(templ_vars)
35
36=== modified file 'templates/main_config.template'
37--- templates/main_config.template 2013-10-29 17:37:20 +0000
38+++ templates/main_config.template 2014-03-18 09:13:44 +0000
39@@ -1,8 +1,11 @@
40 http_port {{ config.port }} {{ config.port_options }}
41
42+{% if need_localacl_defs < 0 -%}
43 acl manager proto cache_object
44 acl localhost src 127.0.0.1/32
45 acl to_localhost dst 127.0.0.0/8
46+{% endif -%}
47+
48 acl PURGE method PURGE
49 acl CONNECT method CONNECT
50 acl SSL_ports port 443

Subscribers

People subscribed via source and target branches

to all changes: