[james-page,r=gnuoy] Add fallback configuration options for vip cidr and iface for non-standard deployments

This commit is contained in:
James Page 2015-01-13 15:18:43 +00:00
commit c6352dd07e
3 changed files with 50 additions and 2 deletions

View File

@ -75,6 +75,18 @@ options:
.
If multiple networks are being used, a VIP should be provided for each
network, separated by spaces.
vip_iface:
type: string
default: eth0
description: |
Default network interface to use for HA vip when it cannot be automatically
determined.
vip_cidr:
type: int
default: 24
description: |
Default CIDR netmask to use for HA vip when it cannot be automatically
determined.
ha-bindiface:
type: string
default: eth0

View File

@ -328,7 +328,11 @@ def ha_joined():
res_neutron_vip = 'ocf:heartbeat:IPaddr2'
vip_params = 'ip'
iface = get_iface_for_address(vip)
iface = (get_iface_for_address(vip) or
config('vip_iface'))
netmask = (get_netmask_for_address(vip) or
config('vip_cidr'))
if iface is not None:
vip_key = 'res_neutron_{}_vip'.format(iface)
resources[vip_key] = res_neutron_vip
@ -337,7 +341,7 @@ def ha_joined():
'nic="{iface}"'.format(ip=vip_params,
vip=vip,
iface=iface,
netmask=get_netmask_for_address(vip))
netmask=netmask)
)
vip_group.append(vip_key)

View File

@ -323,6 +323,38 @@ class NeutronAPIHooksTests(CharmTestCase):
**_relation_data
)
@patch.object(hooks, 'get_hacluster_config')
def test_ha_joined_no_bound_ip(self, _get_ha_config):
_ha_config = {
'vip': '10.0.0.1',
'ha-bindiface': 'eth1',
'ha-mcastport': '5405',
}
vip_params = 'params ip="10.0.0.1" cidr_netmask="21" nic="eth120"'
_get_ha_config.return_value = _ha_config
self.test_config.set('vip_iface', 'eth120')
self.test_config.set('vip_cidr', '21')
self.get_iface_for_address.return_value = None
self.get_netmask_for_address.return_value = None
_relation_data = {
'init_services': {'res_neutron_haproxy': 'haproxy'},
'corosync_bindiface': _ha_config['ha-bindiface'],
'corosync_mcastport': _ha_config['ha-mcastport'],
'resources': {
'res_neutron_eth120_vip': 'ocf:heartbeat:IPaddr2',
'res_neutron_haproxy': 'lsb:haproxy'
},
'resource_params': {
'res_neutron_eth120_vip': vip_params,
'res_neutron_haproxy': 'op monitor interval="5s"'
},
'clones': {'cl_nova_haproxy': 'res_neutron_haproxy'}
}
self._call_hook('ha-relation-joined')
self.relation_set.assert_called_with(
**_relation_data
)
@patch.object(hooks, 'get_hacluster_config')
def test_ha_joined_with_ipv6(self, _get_ha_config):
self.test_config.set('prefer-ipv6', 'True')