diff --git a/charmhelpers/contrib/charmsupport/nrpe.py b/charmhelpers/contrib/charmsupport/nrpe.py index 10d86ac..f59fdd6 100644 --- a/charmhelpers/contrib/charmsupport/nrpe.py +++ b/charmhelpers/contrib/charmsupport/nrpe.py @@ -305,7 +305,7 @@ class NRPE(object): # update-status hooks are configured to firing every 5 minutes by # default. When nagios-nrpe-server is restarted, the nagios server - # reports checks failing causing unneccessary alerts. Let's not restart + # reports checks failing causing unnecessary alerts. Let's not restart # on update-status hooks. if not hook_name() == 'update-status': service('restart', 'nagios-nrpe-server') diff --git a/charmhelpers/contrib/openstack/ha/utils.py b/charmhelpers/contrib/openstack/ha/utils.py index 01c0010..718c6d6 100644 --- a/charmhelpers/contrib/openstack/ha/utils.py +++ b/charmhelpers/contrib/openstack/ha/utils.py @@ -250,6 +250,27 @@ def update_hacluster_dns_ha(service, relation_data, raise DNSHAException(msg) +def get_vip_settings(vip): + """Calculate which nic is on the correct network for the given vip. + + If nic or netmask discovery fail then fallback to using charm supplied + config. If fallback is used this is indicated via the fallback variable. + + @param vip: VIP to lookup nic and cidr for. + @returns (str, str, bool): eg (iface, netmask, fallback) + """ + iface = get_iface_for_address(vip) + netmask = get_netmask_for_address(vip) + fallback = False + if iface is None: + iface = config('vip_iface') + fallback = True + if netmask is None: + netmask = config('vip_cidr') + fallback = True + return iface, netmask, fallback + + def update_hacluster_vip(service, relation_data): """ Configure VIP resources based on provided configuration @@ -267,17 +288,9 @@ def update_hacluster_vip(service, relation_data): res_vip = 'ocf:heartbeat:IPaddr2' vip_params = 'ip' - iface = get_iface_for_address(vip) - netmask = get_netmask_for_address(vip) - - fallback_params = False - if iface is None: - iface = config('vip_iface') - fallback_params = True - if netmask is None: - netmask = config('vip_cidr') - fallback_params = True + iface, netmask, fallback = get_vip_settings(vip) + vip_monitoring = 'op monitor depth="0" timeout="20s" interval="10s"' if iface is not None: # NOTE(jamespage): Delete old VIP resources # Old style naming encoding iface in name @@ -296,14 +309,15 @@ def update_hacluster_vip(service, relation_data): # NOTE(jamespage): # Use option provided vip params if these where used # instead of auto-detected values - if fallback_params: + if fallback: relation_data['resource_params'][vip_key] = ( 'params {ip}="{vip}" cidr_netmask="{netmask}" ' - 'nic="{iface}"'.format(ip=vip_params, - vip=vip, - iface=iface, - netmask=netmask) - ) + 'nic="{iface}" {vip_monitoring}'.format( + ip=vip_params, + vip=vip, + iface=iface, + netmask=netmask, + vip_monitoring=vip_monitoring)) else: # NOTE(jamespage): # let heartbeat figure out which interface and @@ -311,8 +325,10 @@ def update_hacluster_vip(service, relation_data): # when network interface naming is not # consistent across units. relation_data['resource_params'][vip_key] = ( - 'params {ip}="{vip}"'.format(ip=vip_params, - vip=vip)) + 'params {ip}="{vip}" {vip_monitoring}'.format( + ip=vip_params, + vip=vip, + vip_monitoring=vip_monitoring)) vip_group.append(vip_key)