Merge ~aurelien-lourot/charm-nrpe/+git/nrpe-charm:bug/1827703 into ~nrpe-charmers/charm-nrpe:master

Proposed by Aurelien Lourot
Status: Merged
Approved by: Jeremy Lounder
Approved revision: 4ce5f269f47e8471d2d7b59b9e74b2c8667885aa
Merged at revision: 51c1bff2264a20756619b359b9228ab978d482e3
Proposed branch: ~aurelien-lourot/charm-nrpe/+git/nrpe-charm:bug/1827703
Merge into: ~nrpe-charmers/charm-nrpe:master
Diff against target: 33 lines (+12/-3)
1 file modified
hooks/nrpe_helpers.py (+12/-3)
Reviewer Review Type Date Requested Status
Jeremy Lounder (community) Approve
Giuseppe Petralia Approve
Review via email: mp+378268@code.launchpad.net

Commit message

Allow connections from Nagios' egress-subnets instead of from its ingress-address

If egress-subnets isn't available it will fall back to ingress-adress and finally private-address.

Closes-Bug: #1827703

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Giuseppe Petralia (peppepetra) wrote :

Looks good to me. Thanks!

review: Approve
Revision history for this message
Jeremy Lounder (jldev) :
review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision 51c1bff2264a20756619b359b9228ab978d482e3

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/nrpe_helpers.py b/hooks/nrpe_helpers.py
2index abd6398..5900f4c 100644
3--- a/hooks/nrpe_helpers.py
4+++ b/hooks/nrpe_helpers.py
5@@ -151,7 +151,13 @@ class MonitorsRelation(helpers.RelationContext):
6 all_monitors.add_monitors(mon)
7 return all_monitors
8
9- def ingress_address(self, relation_data):
10+ def egress_subnets(self, relation_data):
11+ """ This behaves the same as charmhelpers.core.hookenv.egress_subnets().
12+ If it can't determine the egress subnets it will fall back to
13+ ingress-address or finally private-address.
14+ """
15+ if 'egress-subnets' in relation_data:
16+ return relation_data['egress-subnets']
17 if 'ingress-address' in relation_data:
18 return relation_data['ingress-address']
19 return relation_data['private-address']
20@@ -160,8 +166,11 @@ class MonitorsRelation(helpers.RelationContext):
21 super(MonitorsRelation, self).get_data()
22 if not hookenv.relation_ids(self.name):
23 return
24- addresses = [self.ingress_address(info) for info in self['monitors']]
25- self['monitor_allowed_hosts'] = ','.join(addresses)
26+ # self['monitors'] comes from the superclass helpers.RelationContext
27+ # and contains relation data for each 'monitors' relation (to/from
28+ # Nagios).
29+ subnets = [self.egress_subnets(info) for info in self['monitors']]
30+ self['monitor_allowed_hosts'] = ','.join(subnets)
31
32 def provide_data(self):
33 address = get_local_ingress_address('monitors')

Subscribers

People subscribed via source and target branches