Support etcd-peer-relation
This commit is contained in:
parent
459ccf5db5
commit
af1b04bcd2
1
hooks/etcd-peer-relation-broken
Symbolic link
1
hooks/etcd-peer-relation-broken
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_api_hooks.py
|
1
hooks/etcd-peer-relation-changed
Symbolic link
1
hooks/etcd-peer-relation-changed
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_api_hooks.py
|
1
hooks/etcd-peer-relation-departed
Symbolic link
1
hooks/etcd-peer-relation-departed
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_api_hooks.py
|
1
hooks/etcd-peer-relation-joined
Symbolic link
1
hooks/etcd-peer-relation-joined
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_api_hooks.py
|
@ -143,3 +143,28 @@ class HAProxyContext(context.HAProxyContext):
|
||||
# for haproxy.conf
|
||||
ctxt['service_ports'] = port_mapping
|
||||
return ctxt
|
||||
|
||||
|
||||
class EtcdContext(context.OSContextGenerator):
|
||||
interfaces = ['etcd-peer']
|
||||
|
||||
def __call__(self):
|
||||
ctxt = {
|
||||
'peers': [],
|
||||
'cluster_token': '',
|
||||
}
|
||||
|
||||
if not config('neutron-plugin') == 'Calico':
|
||||
return ctxt
|
||||
|
||||
for rid in relation_ids('etcd-peer'):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
ctxt['cluster_token'] = rdata.get('initial_cluster_token')
|
||||
ctxt['peers'].append({
|
||||
'ip': rdata.get('ip'),
|
||||
'port': rdata.get('port'),
|
||||
'name': rdata.get('name'),
|
||||
})
|
||||
|
||||
return ctxt
|
||||
|
@ -44,11 +44,13 @@ from neutron_api_utils import (
|
||||
restart_map,
|
||||
services,
|
||||
setup_ipv6,
|
||||
additional_install_locations
|
||||
additional_install_locations,
|
||||
force_etcd_restart,
|
||||
)
|
||||
from neutron_api_context import (
|
||||
get_l2population,
|
||||
get_overlay_network_type,
|
||||
EtcdContext,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
@ -403,6 +405,18 @@ def calico_network_api_joined(rid=None):
|
||||
relation_set(relation_id=rid, **relation_data)
|
||||
|
||||
|
||||
@hooks.hook('etcd-peer-relation-joined')
|
||||
@hooks.hook('etcd-peer-relation-changed')
|
||||
def etcd_peer_force_restart(relation_id=None):
|
||||
# note(cory.benfield): Mostly etcd does not require active management,
|
||||
# but occasionally it does require a full config nuking. This does not
|
||||
# play well with the standard neutron-api config management, so we
|
||||
# treat etcd like the special snowflake it insists on being.
|
||||
CONFIGS.register('/etc/init/etcd.conf', [EtcdContext()])
|
||||
CONFIGS.write('/etc/init/etcd.conf')
|
||||
force_etcd_restart()
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
hooks.execute(sys.argv)
|
||||
|
@ -1,6 +1,8 @@
|
||||
from collections import OrderedDict
|
||||
from copy import deepcopy
|
||||
import os
|
||||
import shutil
|
||||
import glob
|
||||
from base64 import b64encode
|
||||
from charmhelpers.contrib.openstack import context, templating
|
||||
from charmhelpers.contrib.openstack.neutron import (
|
||||
@ -26,7 +28,9 @@ from charmhelpers.fetch import (
|
||||
)
|
||||
|
||||
from charmhelpers.core.host import (
|
||||
lsb_release
|
||||
lsb_release,
|
||||
service_stop,
|
||||
service_start,
|
||||
)
|
||||
|
||||
import neutron_api_context
|
||||
@ -125,6 +129,18 @@ def additional_install_locations(plugin):
|
||||
apt_upgrade()
|
||||
|
||||
|
||||
def force_etcd_restart():
|
||||
'''
|
||||
If etcd has been reconfigured we need to force it to fully restart.
|
||||
This is necessary because etcd has some config flags that it ignores
|
||||
after the first time it starts, so we need to make it forget them.
|
||||
'''
|
||||
service_stop('etcd')
|
||||
for directory in glob.glob('/var/lib/etcd/*'):
|
||||
shutil.rmtree(directory)
|
||||
service_start('etcd')
|
||||
|
||||
|
||||
def determine_packages(source=None):
|
||||
# currently all packages match service names
|
||||
packages = [] + BASE_PACKAGES
|
||||
|
@ -22,8 +22,6 @@ provides:
|
||||
interface: neutron-api
|
||||
neutron-plugin-api:
|
||||
interface: neutron-plugin-api
|
||||
calico-network-api:
|
||||
interface: calico-network-api
|
||||
requires:
|
||||
shared-db:
|
||||
interface: mysql-shared
|
||||
@ -36,6 +34,8 @@ requires:
|
||||
ha:
|
||||
interface: hacluster
|
||||
scope: container
|
||||
etcd-peer:
|
||||
interface: http
|
||||
peers:
|
||||
cluster:
|
||||
interface: neutron-api-ha
|
||||
|
Loading…
x
Reference in New Issue
Block a user