Merge lp:~blr/charms/precise/squid-forwardproxy/trunk into lp:~canonical-launchpad-branches/charms/precise/squid-forwardproxy/trunk

Proposed by Kit Randel
Status: Merged
Merged at revision: 31
Proposed branch: lp:~blr/charms/precise/squid-forwardproxy/trunk
Merge into: lp:~canonical-launchpad-branches/charms/precise/squid-forwardproxy/trunk
Diff against target: 79 lines (+22/-4)
2 files modified
config.yaml (+7/-0)
hooks/hooks.py (+15/-4)
To merge this branch: bzr merge lp:~blr/charms/precise/squid-forwardproxy/trunk
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+271224@code.launchpad.net

Commit message

* Add 'run' config option, allowing explicit starting or stopping of the squid service.
* Rename deprecated (invalid?) juju-log log-level 'FATAL' to 'CRITICAL'.

To post a comment you must log in.
38. By Kit Randel

Add logging message for service start/stop/reload/restart requests.

39. By Kit Randel

Rename deprecated (invalid?) juju-log log-level 'FATAL' to 'CRITICAL'.

40. By Kit Randel

Ensure service can start in config_changed hook if not in running state.

41. By Kit Randel

Ensure port is opened and make update_service_port behaviour clearer.

Revision history for this message
William Grant (wgrant) :
review: Approve (code)
42. By Kit Randel

Use sentence case for log messages.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'config.yaml'
2--- config.yaml 2015-08-14 00:45:46 +0000
3+++ config.yaml 2015-09-17 02:56:18 +0000
4@@ -47,6 +47,13 @@
5 type: int
6 default: 8192
7 description: Maximum size of an object to be cached (KB).
8+ run:
9+ type: boolean
10+ default: true
11+ description: >
12+ Run state of squid service. A value of false will stop the service currently running, or prevent
13+ the service starting on installation. This is potentially useful for awaiting deployment
14+ of a sub-ordinate helper service.
15 snmp_community:
16 type: string
17 default: ''
18
19=== modified file 'hooks/hooks.py'
20--- hooks/hooks.py 2015-09-01 02:07:43 +0000
21+++ hooks/hooks.py 2015-09-17 02:56:18 +0000
22@@ -326,6 +326,7 @@
23 else:
24 return(False)
25 elif action in ('start', 'stop', 'reload', 'restart'):
26+ utils.juju_log('INFO', 'Requesting %s of squid3 service.' % action)
27 retVal = subprocess.call([action, 'squid3'])
28 if retVal == 0:
29 return(True)
30@@ -339,7 +340,7 @@
31 nagios_uid = pwd.getpwnam('nagios').pw_uid
32 nagios_gid = grp.getgrnam('nagios').gr_gid
33 except:
34- utils.juju_log('FATAL', "Nagios user not setup, exiting")
35+ utils.juju_log('CRITICAL', 'Nagios user not setup, exiting')
36 return
37 utils.install_unattended('libwww-perl')
38 shutil.copy2('%s/files/nrpe-external-master/check_squid' % (os.environ['CHARM_DIR']), '/usr/local/lib/nagios/plugins/')
39@@ -353,7 +354,7 @@
40 os.mkdir(nagios_logdir)
41 os.chown(nagios_logdir, nagios_uid, nagios_gid)
42 if not os.path.exists(nagios_exportdir):
43- utils.juju_log('FATAL', 'Exiting as %s is not accessible' % (nagios_exportdir))
44+ utils.juju_log('CRITICAL', 'Exiting as %s is not accessible' % (nagios_exportdir))
45 return
46 for f in os.listdir(nagios_exportdir):
47 if re.search('.*check_squidfp.cfg', f):
48@@ -391,19 +392,29 @@
49
50
51 def config_changed():
52+ config_data = config_get()
53+ if not config_data['run']:
54+ return(service_squid3('stop'))
55+
56 current_service_ports = get_service_ports()
57 construct_squid3_config()
58 update_nrpe_checks()
59
60- if service_squid3("check"):
61+ if service_squid3('check'):
62 updated_service_ports = get_service_ports()
63 update_service_ports(current_service_ports, updated_service_ports)
64- service_squid3("reload")
65+ if service_squid3('status'):
66+ service_squid3('reload')
67+ else:
68+ service_squid3('start')
69 else:
70 sys.exit(1)
71
72
73 def start_hook():
74+ config_data = config_get()
75+ if not config_data['run']:
76+ return
77 if service_squid3("status"):
78 return(service_squid3("restart"))
79 else:

Subscribers

People subscribed via source and target branches

to all changes: