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
=== modified file 'config.yaml'
--- config.yaml 2015-08-14 00:45:46 +0000
+++ config.yaml 2015-09-17 02:56:18 +0000
@@ -47,6 +47,13 @@
47 type: int47 type: int
48 default: 819248 default: 8192
49 description: Maximum size of an object to be cached (KB).49 description: Maximum size of an object to be cached (KB).
50 run:
51 type: boolean
52 default: true
53 description: >
54 Run state of squid service. A value of false will stop the service currently running, or prevent
55 the service starting on installation. This is potentially useful for awaiting deployment
56 of a sub-ordinate helper service.
50 snmp_community:57 snmp_community:
51 type: string58 type: string
52 default: ''59 default: ''
5360
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2015-09-01 02:07:43 +0000
+++ hooks/hooks.py 2015-09-17 02:56:18 +0000
@@ -326,6 +326,7 @@
326 else:326 else:
327 return(False)327 return(False)
328 elif action in ('start', 'stop', 'reload', 'restart'):328 elif action in ('start', 'stop', 'reload', 'restart'):
329 utils.juju_log('INFO', 'Requesting %s of squid3 service.' % action)
329 retVal = subprocess.call([action, 'squid3'])330 retVal = subprocess.call([action, 'squid3'])
330 if retVal == 0:331 if retVal == 0:
331 return(True)332 return(True)
@@ -339,7 +340,7 @@
339 nagios_uid = pwd.getpwnam('nagios').pw_uid340 nagios_uid = pwd.getpwnam('nagios').pw_uid
340 nagios_gid = grp.getgrnam('nagios').gr_gid341 nagios_gid = grp.getgrnam('nagios').gr_gid
341 except:342 except:
342 utils.juju_log('FATAL', "Nagios user not setup, exiting")343 utils.juju_log('CRITICAL', 'Nagios user not setup, exiting')
343 return344 return
344 utils.install_unattended('libwww-perl')345 utils.install_unattended('libwww-perl')
345 shutil.copy2('%s/files/nrpe-external-master/check_squid' % (os.environ['CHARM_DIR']), '/usr/local/lib/nagios/plugins/')346 shutil.copy2('%s/files/nrpe-external-master/check_squid' % (os.environ['CHARM_DIR']), '/usr/local/lib/nagios/plugins/')
@@ -353,7 +354,7 @@
353 os.mkdir(nagios_logdir)354 os.mkdir(nagios_logdir)
354 os.chown(nagios_logdir, nagios_uid, nagios_gid)355 os.chown(nagios_logdir, nagios_uid, nagios_gid)
355 if not os.path.exists(nagios_exportdir):356 if not os.path.exists(nagios_exportdir):
356 utils.juju_log('FATAL', 'Exiting as %s is not accessible' % (nagios_exportdir))357 utils.juju_log('CRITICAL', 'Exiting as %s is not accessible' % (nagios_exportdir))
357 return358 return
358 for f in os.listdir(nagios_exportdir):359 for f in os.listdir(nagios_exportdir):
359 if re.search('.*check_squidfp.cfg', f):360 if re.search('.*check_squidfp.cfg', f):
@@ -391,19 +392,29 @@
391392
392393
393def config_changed():394def config_changed():
395 config_data = config_get()
396 if not config_data['run']:
397 return(service_squid3('stop'))
398
394 current_service_ports = get_service_ports()399 current_service_ports = get_service_ports()
395 construct_squid3_config()400 construct_squid3_config()
396 update_nrpe_checks()401 update_nrpe_checks()
397402
398 if service_squid3("check"):403 if service_squid3('check'):
399 updated_service_ports = get_service_ports()404 updated_service_ports = get_service_ports()
400 update_service_ports(current_service_ports, updated_service_ports)405 update_service_ports(current_service_ports, updated_service_ports)
401 service_squid3("reload")406 if service_squid3('status'):
407 service_squid3('reload')
408 else:
409 service_squid3('start')
402 else:410 else:
403 sys.exit(1)411 sys.exit(1)
404412
405413
406def start_hook():414def start_hook():
415 config_data = config_get()
416 if not config_data['run']:
417 return
407 if service_squid3("status"):418 if service_squid3("status"):
408 return(service_squid3("restart"))419 return(service_squid3("restart"))
409 else:420 else:

Subscribers

People subscribed via source and target branches

to all changes: