Merge changes for new etcd branch.
This commit is contained in:
commit
340c5fb4a1
@ -237,27 +237,22 @@ class HAProxyContext(context.HAProxyContext):
|
|||||||
|
|
||||||
|
|
||||||
class EtcdContext(context.OSContextGenerator):
|
class EtcdContext(context.OSContextGenerator):
|
||||||
interfaces = ['etcd-peer']
|
interfaces = ['etcd-proxy']
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
peers = []
|
|
||||||
ctxt = {'cluster': ''}
|
ctxt = {'cluster': ''}
|
||||||
|
cluster_string = ''
|
||||||
|
|
||||||
if not config('neutron-plugin') == 'Calico':
|
if not config('neutron-plugin') == 'Calico':
|
||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
for rid in relation_ids('etcd-peer'):
|
for rid in relation_ids('etcd-proxy'):
|
||||||
for unit in related_units(rid):
|
for unit in related_units(rid):
|
||||||
rdata = relation_get(rid=rid, unit=unit)
|
rdata = relation_get(rid=rid, unit=unit)
|
||||||
peers.append({
|
cluster_string = rdata.get('cluster')
|
||||||
'ip': rdata.get('ip'),
|
if cluster_string:
|
||||||
'port': rdata.get('port'),
|
break
|
||||||
'name': rdata.get('name'),
|
|
||||||
})
|
|
||||||
|
|
||||||
cluster_string = ','.join(
|
|
||||||
'{name}=http://{ip}:{port}'.format(**p) for p in peers
|
|
||||||
)
|
|
||||||
ctxt['cluster'] = cluster_string
|
ctxt['cluster'] = cluster_string
|
||||||
|
|
||||||
return ctxt
|
return ctxt
|
||||||
|
@ -510,16 +510,18 @@ def update_nrpe_config():
|
|||||||
nrpe_setup.write()
|
nrpe_setup.write()
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('etcd-peer-relation-joined')
|
@hooks.hook('etcd-proxy-relation-joined')
|
||||||
@hooks.hook('etcd-peer-relation-changed')
|
@hooks.hook('etcd-proxy-relation-changed')
|
||||||
def etcd_peer_force_restart(relation_id=None):
|
def etcd_proxy_force_restart(relation_id=None):
|
||||||
# note(cory.benfield): Mostly etcd does not require active management,
|
# note(cory.benfield): Mostly etcd does not require active management,
|
||||||
# but occasionally it does require a full config nuking. This does not
|
# but occasionally it does require a full config nuking. This does not
|
||||||
# play well with the standard neutron-api config management, so we
|
# play well with the standard neutron-api config management, so we
|
||||||
# treat etcd like the special snowflake it insists on being.
|
# treat etcd like the special snowflake it insists on being.
|
||||||
CONFIGS.register('/etc/init/etcd.conf', [EtcdContext()])
|
CONFIGS.register('/etc/init/etcd.conf', [EtcdContext()])
|
||||||
CONFIGS.write('/etc/init/etcd.conf')
|
CONFIGS.write('/etc/init/etcd.conf')
|
||||||
force_etcd_restart()
|
|
||||||
|
if 'etcd-proxy' in CONFIGS.complete_contexts():
|
||||||
|
force_etcd_restart()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
@ -37,8 +37,8 @@ requires:
|
|||||||
zeromq-configuration:
|
zeromq-configuration:
|
||||||
interface: zeromq-configuration
|
interface: zeromq-configuration
|
||||||
scope: container
|
scope: container
|
||||||
etcd-peer:
|
etcd-proxy:
|
||||||
interface: http
|
interface: etcd-proxy
|
||||||
peers:
|
peers:
|
||||||
cluster:
|
cluster:
|
||||||
interface: neutron-api-ha
|
interface: neutron-api-ha
|
||||||
|
@ -455,13 +455,11 @@ class EtcdContextTest(CharmTestCase):
|
|||||||
def test_some_related_units(self):
|
def test_some_related_units(self):
|
||||||
self.related_units.return_value = ['unit1']
|
self.related_units.return_value = ['unit1']
|
||||||
self.relation_ids.return_value = ['rid2', 'rid3']
|
self.relation_ids.return_value = ['rid2', 'rid3']
|
||||||
self.test_relation.set({'ip': '172.18.18.18',
|
|
||||||
'port': 8888,
|
|
||||||
'name': 'testname'})
|
|
||||||
result = (
|
result = (
|
||||||
'testname=http://172.18.18.18:8888,'
|
'testname=http://172.18.18.18:8888,'
|
||||||
'testname=http://172.18.18.18:8888'
|
'testname=http://172.18.18.18:8888'
|
||||||
)
|
)
|
||||||
|
self.test_relation.set({'cluster': result})
|
||||||
|
|
||||||
ctxt = context.EtcdContext()()
|
ctxt = context.EtcdContext()()
|
||||||
expect = {'cluster': result}
|
expect = {'cluster': result}
|
||||||
|
@ -731,7 +731,6 @@ class NeutronAPIHooksTests(CharmTestCase):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def test_etcd_peer_joined(self):
|
def test_etcd_peer_joined(self):
|
||||||
self._call_hook('etcd-peer-relation-joined')
|
self._call_hook('etcd-proxy-relation-joined')
|
||||||
self.assertTrue(self.CONFIGS.register.called)
|
self.assertTrue(self.CONFIGS.register.called)
|
||||||
self.CONFIGS.write.assert_called_with('/etc/init/etcd.conf')
|
self.CONFIGS.write.assert_called_with('/etc/init/etcd.conf')
|
||||||
self.force_etcd_restart.assert_called_once_with()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user