From b3d57daa2e57ffd2d5ccca83cdf1d291edbd60c7 Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Mon, 2 Nov 2015 10:37:02 +0000 Subject: [PATCH] [hopem,r=] Improve shared-db rel logging Closes-Bug: 1512293 --- hooks/percona_hooks.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hooks/percona_hooks.py b/hooks/percona_hooks.py index 783e595..a0e00b5 100755 --- a/hooks/percona_hooks.py +++ b/hooks/percona_hooks.py @@ -359,8 +359,12 @@ def get_db_host(client_hostname): vips = config('vip').split() if config('vip') else [] client_ip = get_host_ip(client_hostname) access_network = config('access-network') - if (access_network is not None and - is_address_in_network(access_network, client_ip)): + if access_network is not None: + if not is_address_in_network(access_network, client_ip): + log("Host '%s' not in access-network '%s' - ignoring" % + (client_ip, access_network), level=INFO) + return + if is_clustered(): for vip in vips: if is_address_in_network(access_network, vip): @@ -448,6 +452,8 @@ def shared_db_changed(relation_id=None, unit=None): # database access if remote unit has presented a # hostname or ip address thats within the configured # network cidr + log("Host '%s' not in access-network '%s' - ignoring" % + (normalized_address, access_network), level=INFO) return # NOTE: do this before querying access grants