Add neutron-api-plugin relation and use it to dictate neutron settings liek l2_population

This commit is contained in:
Liam Young 2014-09-30 14:12:10 +00:00
parent 1619547f7c
commit 4f9988196a
9 changed files with 52 additions and 9 deletions

View File

@ -102,10 +102,3 @@ options:
.
This network will be used for tenant network traffic in overlay
networks.
l2-population:
type: boolean
default: True
description: |
Populate the forwarding tables of virtual switches (LinuxBridge or OVS),
to decrease broadcast traffics inside the physical networks fabric while
using overlays networks (VXLan, GRE).

View File

@ -0,0 +1 @@
quantum_hooks.py

View File

@ -0,0 +1 @@
quantum_hooks.py

View File

@ -0,0 +1 @@
quantum_hooks.py

View File

@ -0,0 +1 @@
quantum_hooks.py

View File

@ -100,6 +100,27 @@ def core_plugin():
return CORE_PLUGIN[networking_name()][plugin]
def _neutron_api_settings():
'''
Inspects current neutron-plugin-api relation for neutron settings. Return
defaults if it is not present
'''
neutron_settings = {
'l2_population': True,
}
for rid in relation_ids('neutron-plugin-api'):
for unit in related_units(rid):
rdata = relation_get(rid=rid, unit=unit)
if 'l2-population' not in rdata:
continue
neutron_settings = {
'l2_population': rdata['l2-population'],
}
return neutron_settings
return neutron_settings
class NetworkServiceContext(OSContextGenerator):
interfaces = ['quantum-network-service']
@ -181,6 +202,7 @@ class ExternalPortContext(OSContextGenerator):
class QuantumGatewayContext(OSContextGenerator):
def __call__(self):
neutron_api_settings = _neutron_api_settings()
ctxt = {
'shared_secret': get_shared_secret(),
'local_ip':
@ -191,7 +213,7 @@ class QuantumGatewayContext(OSContextGenerator):
'debug': config('debug'),
'verbose': config('verbose'),
'instance_mtu': config('instance-mtu'),
'l2_population': config('l2-population'),
'l2_population': neutron_api_settings['l2_population'],
}
return ctxt

View File

@ -162,7 +162,8 @@ def amqp_departed():
'pgsql-db-relation-changed',
'amqp-relation-changed',
'cluster-relation-changed',
'cluster-relation-joined')
'cluster-relation-joined',
'neutron-plugin-api-relation-changed')
@restart_on_change(restart_map())
def db_amqp_changed():
CONFIGS.write_all()

View File

@ -27,6 +27,8 @@ requires:
interface: rabbitmq
amqp-nova:
interface: rabbitmq
neutron-plugin-api:
interface: neutron-plugin-api
peers:
cluster:
interface: quantum-gateway-ha

View File

@ -353,3 +353,24 @@ class TestMisc(CharmTestCase):
self.config.return_value = 'ovs'
self.assertEquals(quantum_contexts.core_plugin(),
quantum_contexts.NEUTRON_ML2_PLUGIN)
def test_neutron_api_settings(self):
self.relation_ids.return_value = ['foo']
self.related_units.return_value = ['bar']
self.test_relation.set({'l2-population': True})
self.relation_get.side_effect = self.test_relation.get
self.assertEquals(quantum_contexts._neutron_api_settings(),
{'l2_population': True})
def test_neutron_api_settings2(self):
self.relation_ids.return_value = ['foo']
self.related_units.return_value = ['bar']
self.test_relation.set({'l2-population': False})
self.relation_get.side_effect = self.test_relation.get
self.assertEquals(quantum_contexts._neutron_api_settings(),
{'l2_population': False})
def test_neutron_api_settings_no_apiplugin(self):
self.relation_ids.return_value = []
self.assertEquals(quantum_contexts._neutron_api_settings(),
{'l2_population': True})