Merge "Add neutron-control interface"
This commit is contained in:
commit
130c778842
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ bin
|
||||
tags
|
||||
*.sw[nop]
|
||||
*.pyc
|
||||
.unit-state.db
|
||||
|
1
hooks/neutron-control-relation-broken
Symbolic link
1
hooks/neutron-control-relation-broken
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_ovs_hooks.py
|
1
hooks/neutron-control-relation-changed
Symbolic link
1
hooks/neutron-control-relation-changed
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_ovs_hooks.py
|
1
hooks/neutron-control-relation-departed
Symbolic link
1
hooks/neutron-control-relation-departed
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_ovs_hooks.py
|
1
hooks/neutron-control-relation-joined
Symbolic link
1
hooks/neutron-control-relation-joined
Symbolic link
@ -0,0 +1 @@
|
||||
neutron_ovs_hooks.py
|
@ -268,16 +268,29 @@ class SharedSecretContext(OSContextGenerator):
|
||||
|
||||
class RemoteRestartContext(OSContextGenerator):
|
||||
|
||||
def __init__(self, interfaces=None):
|
||||
self.interfaces = interfaces or ['neutron-plugin']
|
||||
|
||||
def __call__(self):
|
||||
for rid in relation_ids('neutron-plugin'):
|
||||
rids = []
|
||||
for interface in self.interfaces:
|
||||
rids.extend(relation_ids(interface))
|
||||
ctxt = {}
|
||||
for rid in rids:
|
||||
for unit in related_units(rid):
|
||||
restart_uuid = relation_get(
|
||||
attribute='restart-trigger',
|
||||
remote_data = relation_get(
|
||||
rid=rid,
|
||||
unit=unit)
|
||||
if restart_uuid:
|
||||
return {'restart_trigger': restart_uuid}
|
||||
return {}
|
||||
for k, v in remote_data.items():
|
||||
if k.startswith('restart-trigger'):
|
||||
restart_key = k.replace('-', '_')
|
||||
try:
|
||||
ctxt[restart_key].append(v)
|
||||
except KeyError:
|
||||
ctxt[restart_key] = [v]
|
||||
for restart_key in ctxt.keys():
|
||||
ctxt[restart_key] = '-'.join(sorted(ctxt[restart_key]))
|
||||
return ctxt
|
||||
|
||||
|
||||
class APIIdentityServiceContext(context.IdentityServiceContext):
|
||||
|
@ -143,6 +143,12 @@ def zeromq_configuration_relation_changed():
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
||||
@hooks.hook('neutron-control-relation-changed')
|
||||
@restart_on_change(restart_map(), stopstart=True)
|
||||
def restart_check():
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
hooks.execute(sys.argv)
|
||||
|
@ -137,7 +137,8 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
(NEUTRON_CONF, {
|
||||
'services': ['neutron-plugin-openvswitch-agent'],
|
||||
'contexts': [neutron_ovs_context.OVSPluginContext(),
|
||||
neutron_ovs_context.RemoteRestartContext(),
|
||||
neutron_ovs_context.RemoteRestartContext(
|
||||
['neutron-plugin', 'neutron-control']),
|
||||
context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR),
|
||||
context.ZeroMQContext(),
|
||||
context.NotificationDriverContext()],
|
||||
|
@ -22,6 +22,8 @@ provides:
|
||||
neutron-plugin:
|
||||
interface: neutron-plugin
|
||||
scope: container
|
||||
neutron-control:
|
||||
interface: service-control
|
||||
requires:
|
||||
amqp:
|
||||
interface: rabbitmq
|
||||
@ -30,4 +32,3 @@ requires:
|
||||
zeromq-configuration:
|
||||
interface: zeromq-configuration
|
||||
scope: container
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
# {{ restart_trigger_dhcp }}
|
||||
###############################################################################
|
||||
|
||||
[DEFAULT]
|
||||
state_path = /var/lib/neutron
|
||||
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
|
||||
|
@ -4,6 +4,7 @@
|
||||
###############################################################################
|
||||
# Metadata service seems to cache neutron api url from keystone so trigger
|
||||
# restart if it changes: {{ quantum_url }}
|
||||
# {{ restart_trigger_metadata }}
|
||||
|
||||
[DEFAULT]
|
||||
auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v2.0
|
||||
|
@ -1,7 +1,9 @@
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
# {{ restart_trigger_l3agent }}
|
||||
###############################################################################
|
||||
|
||||
[DEFAULT]
|
||||
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
|
||||
agent_mode = {{ agent_mode }}
|
||||
|
@ -4,6 +4,7 @@
|
||||
###############################################################################
|
||||
# Metadata service seems to cache neutron api url from keystone so trigger
|
||||
# restart if it changes: {{ quantum_url }}
|
||||
# {{ restart_trigger_metadata }}
|
||||
|
||||
[DEFAULT]
|
||||
auth_url = {{ service_protocol }}://{{ service_host }}:{{ service_port }}/v2.0
|
||||
|
@ -1,9 +1,10 @@
|
||||
# icehouse
|
||||
# kilo
|
||||
###############################################################################
|
||||
# [ WARNING ]
|
||||
# Configuration file maintained by Juju. Local changes may be overwritten.
|
||||
# Config managed by neutron-openvswitch charm
|
||||
# Service restart triggered by principle using key: {{ restart_trigger }}
|
||||
# Service restart triggered by remote application: {{ restart_trigger }}
|
||||
# {{ restart_trigger_neutron }}
|
||||
###############################################################################
|
||||
[DEFAULT]
|
||||
verbose = {{ verbose }}
|
||||
|
@ -491,14 +491,54 @@ class TestRemoteRestartContext(CharmTestCase):
|
||||
def test_restart_trigger_present(self):
|
||||
self.relation_ids.return_value = ['rid1']
|
||||
self.related_units.return_value = ['nova-compute/0']
|
||||
self.relation_get.return_value = '8f73-f3adb96a90d8'
|
||||
self.relation_get.return_value = {
|
||||
'restart-trigger': '8f73-f3adb96a90d8',
|
||||
}
|
||||
self.assertEquals(
|
||||
context.RemoteRestartContext()(),
|
||||
{'restart_trigger': '8f73-f3adb96a90d8'}
|
||||
)
|
||||
self.relation_ids.assert_called_with('neutron-plugin')
|
||||
|
||||
def test_restart_trigger_present_alt_relation(self):
|
||||
self.relation_ids.return_value = ['rid1']
|
||||
self.related_units.return_value = ['nova-compute/0']
|
||||
self.relation_get.return_value = {
|
||||
'restart-trigger': '8f73-f3adb96a90d8',
|
||||
}
|
||||
self.assertEquals(
|
||||
context.RemoteRestartContext(['neutron-control'])(),
|
||||
{'restart_trigger': '8f73-f3adb96a90d8'}
|
||||
)
|
||||
self.relation_ids.assert_called_with('neutron-control')
|
||||
|
||||
def test_restart_trigger_present_multi_relation(self):
|
||||
self.relation_ids.return_value = ['rid1']
|
||||
self.related_units.return_value = ['nova-compute/0']
|
||||
ids = [
|
||||
{'restart-trigger': '8f73'},
|
||||
{'restart-trigger': '2ac3'}]
|
||||
self.relation_get.side_effect = lambda rid, unit: ids.pop()
|
||||
self.assertEquals(
|
||||
context.RemoteRestartContext(
|
||||
['neutron-plugin', 'neutron-control'])(),
|
||||
{'restart_trigger': '2ac3-8f73'}
|
||||
)
|
||||
self.relation_ids.assert_called_with('neutron-control')
|
||||
|
||||
def test_restart_trigger_absent(self):
|
||||
self.relation_ids.return_value = ['rid1']
|
||||
self.related_units.return_value = ['nova-compute/0']
|
||||
self.relation_get.return_value = None
|
||||
self.relation_get.return_value = {}
|
||||
self.assertEquals(context.RemoteRestartContext()(), {})
|
||||
|
||||
def test_restart_trigger_service(self):
|
||||
self.relation_ids.return_value = ['rid1']
|
||||
self.related_units.return_value = ['nova-compute/0']
|
||||
self.relation_get.return_value = {
|
||||
'restart-trigger-neutron': 'neutron-uuid',
|
||||
}
|
||||
self.assertEquals(
|
||||
context.RemoteRestartContext()(),
|
||||
{'restart_trigger_neutron': 'neutron-uuid'}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user