Merge lp:~gnuoy/charm-helpers/nrpe-proxy into lp:charm-helpers

Proposed by Liam Young
Status: Merged
Merged at revision: 361
Proposed branch: lp:~gnuoy/charm-helpers/nrpe-proxy
Merge into: lp:charm-helpers
Diff against target: 52 lines (+17/-5)
2 files modified
charmhelpers/contrib/charmsupport/nrpe.py (+3/-1)
tests/contrib/charmsupport/test_nrpe.py (+14/-4)
To merge this branch: bzr merge lp:~gnuoy/charm-helpers/nrpe-proxy
Reviewer Review Type Date Requested Status
James Page Approve
Review via email: mp+256626@code.launchpad.net
To post a comment you must log in.
Revision history for this message
James Page (james-page) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'charmhelpers/contrib/charmsupport/nrpe.py'
--- charmhelpers/contrib/charmsupport/nrpe.py 2015-02-19 07:49:41 +0000
+++ charmhelpers/contrib/charmsupport/nrpe.py 2015-04-17 08:38:54 +0000
@@ -247,7 +247,9 @@
247247
248 service('restart', 'nagios-nrpe-server')248 service('restart', 'nagios-nrpe-server')
249249
250 for rid in relation_ids("local-monitors"):250 monitor_ids = relation_ids("local-monitors") + \
251 relation_ids("nrpe-external-master")
252 for rid in monitor_ids:
251 relation_set(relation_id=rid, monitors=yaml.dump(monitors))253 relation_set(relation_id=rid, monitors=yaml.dump(monitors))
252254
253255
254256
=== modified file 'tests/contrib/charmsupport/test_nrpe.py'
--- tests/contrib/charmsupport/test_nrpe.py 2015-02-19 08:41:54 +0000
+++ tests/contrib/charmsupport/test_nrpe.py 2015-04-17 08:38:54 +0000
@@ -117,7 +117,14 @@
117 self.patched['config'].return_value = {'nagios_context': 'a',117 self.patched['config'].return_value = {'nagios_context': 'a',
118 'nagios_servicegroups': ''}118 'nagios_servicegroups': ''}
119 self.patched['exists'].return_value = True119 self.patched['exists'].return_value = True
120 self.patched['relation_ids'].return_value = ['local-monitors:1']120
121 def _rels(rname):
122 relations = {
123 'local-monitors': 'local-monitors:1',
124 'nrpe-external-master': 'nrpe-external-master:2',
125 }
126 return [relations[rname]]
127 self.patched['relation_ids'].side_effect = _rels
121128
122 checker = nrpe.NRPE()129 checker = nrpe.NRPE()
123 checker.add_check(shortname="myservice",130 checker.add_check(shortname="myservice",
@@ -159,11 +166,14 @@
159 {'command': 'check_myservice'}}166 {'command': 'check_myservice'}}
160 monitors = yaml.dump(167 monitors = yaml.dump(
161 {"monitors": {"remote": {"nrpe": nrpe_monitors}}})168 {"monitors": {"remote": {"nrpe": nrpe_monitors}}})
162 self.patched['relation_set'].assert_called_once_with(169 relation_set_calls = [
163 relation_id="local-monitors:1", monitors=monitors)170 call(monitors=monitors, relation_id="local-monitors:1"),
171 call(monitors=monitors, relation_id="nrpe-external-master:2"),
172 ]
173 self.patched['relation_set'].assert_has_calls(relation_set_calls, any_order=True)
164 self.check_call_counts(config=1, getpwnam=1, getgrnam=1,174 self.check_call_counts(config=1, getpwnam=1, getgrnam=1,
165 exists=3, open=2, listdir=1,175 exists=3, open=2, listdir=1,
166 relation_ids=1, relation_set=1)176 relation_ids=2, relation_set=2)
167177
168178
169class NRPECheckTestCase(NRPEBaseTestCase):179class NRPECheckTestCase(NRPEBaseTestCase):

Subscribers

People subscribed via source and target branches