Resync helpers, drop surplus vip config
This commit is contained in:
14
config.yaml
14
config.yaml
@@ -147,15 +147,11 @@ options:
|
||||
description: Hash to use across all swift-proxy servers - don't loose
|
||||
vip:
|
||||
type: string
|
||||
description: "Virtual IP to use to front swift-proxy in ha configuration"
|
||||
vip_iface:
|
||||
type: string
|
||||
default: eth0
|
||||
description: "Network Interface where to place the Virtual IP"
|
||||
vip_cidr:
|
||||
type: int
|
||||
default: 24
|
||||
description: "Netmask that will be used for the Virtual IP"
|
||||
description: |
|
||||
Virtual IP(s) to use to front API services in HA configuration.
|
||||
.
|
||||
If multiple networks are being used, a VIP should be provided for each
|
||||
network, separated by spaces.
|
||||
ha-bindiface:
|
||||
type: string
|
||||
default: eth0
|
||||
|
||||
@@ -146,12 +146,12 @@ def get_hacluster_config():
|
||||
Obtains all relevant configuration from charm configuration required
|
||||
for initiating a relation to hacluster:
|
||||
|
||||
ha-bindiface, ha-mcastport, vip, vip_iface, vip_cidr
|
||||
ha-bindiface, ha-mcastport, vip
|
||||
|
||||
returns: dict: A dict containing settings keyed by setting name.
|
||||
raises: HAIncompleteConfig if settings are missing.
|
||||
'''
|
||||
settings = ['ha-bindiface', 'ha-mcastport', 'vip', 'vip_iface', 'vip_cidr']
|
||||
settings = ['ha-bindiface', 'ha-mcastport', 'vip']
|
||||
conf = {}
|
||||
for setting in settings:
|
||||
conf[setting] = config_get(setting)
|
||||
|
||||
@@ -25,6 +25,7 @@ from charmhelpers.core.hookenv import (
|
||||
unit_get,
|
||||
unit_private_ip,
|
||||
ERROR,
|
||||
INFO
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
@@ -714,7 +715,7 @@ class SubordinateConfigContext(OSContextGenerator):
|
||||
self.interface = interface
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {}
|
||||
ctxt = {'sections': {}}
|
||||
for rid in relation_ids(self.interface):
|
||||
for unit in related_units(rid):
|
||||
sub_config = relation_get('subordinate_configuration',
|
||||
@@ -740,10 +741,14 @@ class SubordinateConfigContext(OSContextGenerator):
|
||||
|
||||
sub_config = sub_config[self.config_file]
|
||||
for k, v in sub_config.iteritems():
|
||||
ctxt[k] = v
|
||||
if k == 'sections':
|
||||
for section, config_dict in v.iteritems():
|
||||
log("adding section '%s'" % (section))
|
||||
ctxt[k][section] = config_dict
|
||||
else:
|
||||
ctxt[k] = v
|
||||
|
||||
if not ctxt:
|
||||
ctxt['sections'] = {}
|
||||
log("%d section(s) found" % (len(ctxt['sections'])), level=INFO)
|
||||
|
||||
return ctxt
|
||||
|
||||
|
||||
@@ -52,6 +52,10 @@ from charmhelpers.contrib.openstack.ip import (
|
||||
canonical_url,
|
||||
PUBLIC, INTERNAL, ADMIN
|
||||
)
|
||||
from charmhelpers.contrib.network.ip import (
|
||||
get_iface_for_address,
|
||||
get_netmask_for_address
|
||||
)
|
||||
|
||||
extra_pkgs = [
|
||||
"haproxy",
|
||||
@@ -232,8 +236,6 @@ def ha_relation_joined():
|
||||
corosync_bindiface = config('ha-bindiface')
|
||||
corosync_mcastport = config('ha-mcastport')
|
||||
vip = config('vip')
|
||||
vip_cidr = config('vip_cidr')
|
||||
vip_iface = config('vip_iface')
|
||||
if not vip:
|
||||
log('Unable to configure hacluster as vip not provided',
|
||||
level=ERROR)
|
||||
@@ -241,14 +243,29 @@ def ha_relation_joined():
|
||||
|
||||
# Obtain resources
|
||||
resources = {
|
||||
'res_swift_vip': 'ocf:heartbeat:IPaddr2',
|
||||
'res_swift_haproxy': 'lsb:haproxy'
|
||||
}
|
||||
resource_params = {
|
||||
'res_swift_vip': 'params ip="%s" cidr_netmask="%s" nic="%s"' %
|
||||
(vip, vip_cidr, vip_iface),
|
||||
'res_swift_haproxy': 'op monitor interval="5s"'
|
||||
}
|
||||
|
||||
vip_group = []
|
||||
for vip in vip.split():
|
||||
iface = get_iface_for_address(vip)
|
||||
if iface is not None:
|
||||
vip_key = 'res_swift_{}_vip'.format(iface)
|
||||
resources[vip_key] = 'ocf:heartbeat:IPaddr2'
|
||||
resource_params[vip_key] = (
|
||||
'params ip="{vip}" cidr_netmask="{netmask}"'
|
||||
' nic="{iface}"'.format(vip=vip,
|
||||
iface=iface,
|
||||
netmask=get_netmask_for_address(vip))
|
||||
)
|
||||
vip_group.append(vip_key)
|
||||
|
||||
if len(vip_group) > 1:
|
||||
relation_set(groups={'grp_swift_vips': ' '.join(vip_group)})
|
||||
|
||||
init_services = {
|
||||
'res_swift_haproxy': 'haproxy'
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ BASE_PACKAGES = [
|
||||
# > Folsom specific packages
|
||||
FOLSOM_PACKAGES = BASE_PACKAGES + ['swift-plugin-s3']
|
||||
|
||||
SWIFT_HA_RES = 'res_swift_vip'
|
||||
SWIFT_HA_RES = 'grp_swift_vips'
|
||||
|
||||
TEMPLATES = 'templates/'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user