Add in unicast support
This commit is contained in:
parent
31e80ef87c
commit
c9c6735a7e
|
@ -85,3 +85,8 @@ options:
|
||||||
order for this charm to function correctly, the privacy extension must be
|
order for this charm to function correctly, the privacy extension must be
|
||||||
disabled and a non-temporary address must be configured/available on
|
disabled and a non-temporary address must be configured/available on
|
||||||
your network interface.
|
your network interface.
|
||||||
|
corosync_transport:
|
||||||
|
type: string
|
||||||
|
default: "udp"
|
||||||
|
description: |
|
||||||
|
Two supported modes are udp (multicast) or udpu (unicast)
|
||||||
|
|
|
@ -29,6 +29,7 @@ from charmhelpers.core.hookenv import (
|
||||||
config,
|
config,
|
||||||
Hooks, UnregisteredHookError,
|
Hooks, UnregisteredHookError,
|
||||||
local_unit,
|
local_unit,
|
||||||
|
unit_private_ip,
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.core.host import (
|
from charmhelpers.core.host import (
|
||||||
|
@ -48,6 +49,7 @@ from charmhelpers.fetch import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from charmhelpers.contrib.hahelpers.cluster import (
|
from charmhelpers.contrib.hahelpers.cluster import (
|
||||||
|
peer_ips,
|
||||||
peer_units,
|
peer_units,
|
||||||
oldest_peer
|
oldest_peer
|
||||||
)
|
)
|
||||||
|
@ -78,6 +80,18 @@ def install():
|
||||||
shutil.copy('ocf/ceph/rbd', '/usr/lib/ocf/resource.d/ceph/rbd')
|
shutil.copy('ocf/ceph/rbd', '/usr/lib/ocf/resource.d/ceph/rbd')
|
||||||
|
|
||||||
|
|
||||||
|
def get_ha_nodes():
|
||||||
|
ha_units = peer_ips(peer_relation='hanode')
|
||||||
|
ha_units[local_unit()] = unit_private_ip()
|
||||||
|
ha_nodes = {}
|
||||||
|
# Corosync nodeid 0 is reserved so increase all the nodeids to avoid it
|
||||||
|
off_set = 1000
|
||||||
|
for unit in ha_units:
|
||||||
|
unit_no = off_set + int(unit.split('/')[1])
|
||||||
|
ha_nodes[unit_no] = ha_units[unit]
|
||||||
|
return ha_nodes
|
||||||
|
|
||||||
|
|
||||||
def get_corosync_conf():
|
def get_corosync_conf():
|
||||||
if config('prefer-ipv6'):
|
if config('prefer-ipv6'):
|
||||||
ip_version = 'ipv6'
|
ip_version = 'ipv6'
|
||||||
|
@ -85,7 +99,6 @@ def get_corosync_conf():
|
||||||
else:
|
else:
|
||||||
ip_version = 'ipv4'
|
ip_version = 'ipv4'
|
||||||
bindnetaddr = hacluster.get_network_address
|
bindnetaddr = hacluster.get_network_address
|
||||||
|
|
||||||
# NOTE(jamespage) use local charm configuration over any provided by
|
# NOTE(jamespage) use local charm configuration over any provided by
|
||||||
# principle charm
|
# principle charm
|
||||||
conf = {
|
conf = {
|
||||||
|
@ -94,6 +107,8 @@ def get_corosync_conf():
|
||||||
'corosync_mcastport': config('corosync_mcastport'),
|
'corosync_mcastport': config('corosync_mcastport'),
|
||||||
'corosync_mcastaddr': config('corosync_mcastaddr'),
|
'corosync_mcastaddr': config('corosync_mcastaddr'),
|
||||||
'ip_version': ip_version,
|
'ip_version': ip_version,
|
||||||
|
'ha_nodes': get_ha_nodes(),
|
||||||
|
'transport': config('corosync_transport'),
|
||||||
}
|
}
|
||||||
if None not in conf.itervalues():
|
if None not in conf.itervalues():
|
||||||
return conf
|
return conf
|
||||||
|
@ -109,6 +124,8 @@ def get_corosync_conf():
|
||||||
unit, relid),
|
unit, relid),
|
||||||
'corosync_mcastaddr': config('corosync_mcastaddr'),
|
'corosync_mcastaddr': config('corosync_mcastaddr'),
|
||||||
'ip_version': ip_version,
|
'ip_version': ip_version,
|
||||||
|
'ha_nodes': get_ha_nodes(),
|
||||||
|
'transport': config('corosync_transport'),
|
||||||
}
|
}
|
||||||
|
|
||||||
if config('prefer-ipv6'):
|
if config('prefer-ipv6'):
|
||||||
|
@ -161,7 +178,12 @@ def config_changed():
|
||||||
log('CRITICAL',
|
log('CRITICAL',
|
||||||
'No Corosync key supplied, cannot proceed')
|
'No Corosync key supplied, cannot proceed')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
supported_transports = ['udp', 'udpu']
|
||||||
|
if config('corosync_transport') not in supported_transports:
|
||||||
|
raise ValueError('The corosync_transport type %s is not supported.'
|
||||||
|
'Supported types are: %s' %
|
||||||
|
(config('corosync_transport'),
|
||||||
|
str(supported_transports)))
|
||||||
hacluster.enable_lsb_services('pacemaker')
|
hacluster.enable_lsb_services('pacemaker')
|
||||||
|
|
||||||
if configure_corosync():
|
if configure_corosync():
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Config file generated by the ha charm.
|
# Config file generated by the ha charm.
|
||||||
|
# udp.template
|
||||||
totem {
|
totem {
|
||||||
version: 2
|
version: 2
|
||||||
|
|
||||||
|
@ -47,9 +47,12 @@ totem {
|
||||||
# The following values need to be set based on your environment
|
# The following values need to be set based on your environment
|
||||||
ringnumber: 0
|
ringnumber: 0
|
||||||
bindnetaddr: {{ corosync_bindnetaddr }}
|
bindnetaddr: {{ corosync_bindnetaddr }}
|
||||||
|
{% if transport == "udp" %}
|
||||||
mcastaddr: {{ corosync_mcastaddr }}
|
mcastaddr: {{ corosync_mcastaddr }}
|
||||||
|
{% endif %}
|
||||||
mcastport: {{ corosync_mcastport }}
|
mcastport: {{ corosync_mcastport }}
|
||||||
}
|
}
|
||||||
|
transport: {{ transport }}
|
||||||
}
|
}
|
||||||
|
|
||||||
quorum {
|
quorum {
|
||||||
|
@ -59,6 +62,17 @@ quorum {
|
||||||
expected_votes: 2
|
expected_votes: 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{% if transport == "udp" %}
|
||||||
|
nodelist {
|
||||||
|
{% for nodeid, ip in ha_nodes.iteritems() %}
|
||||||
|
node {
|
||||||
|
ring0_addr: {{ ip }}
|
||||||
|
nodeid: {{ nodeid }}
|
||||||
|
}
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
logging {
|
logging {
|
||||||
fileline: off
|
fileline: off
|
||||||
to_stderr: yes
|
to_stderr: yes
|
||||||
|
|
Loading…
Reference in New Issue