Merge "Add validation of *-l3-agents-per-router config"
This commit is contained in:
commit
71e00c5c4e
|
@ -233,10 +233,16 @@ class NeutronCCContext(context.NeutronContext):
|
|||
ctxt['enable_dvr'] = self.neutron_dvr
|
||||
ctxt['l3_ha'] = self.neutron_l3ha
|
||||
if self.neutron_l3ha:
|
||||
ctxt['max_l3_agents_per_router'] = \
|
||||
config('max-l3-agents-per-router')
|
||||
ctxt['min_l3_agents_per_router'] = \
|
||||
config('min-l3-agents-per-router')
|
||||
max_agents = config('max-l3-agents-per-router')
|
||||
min_agents = config('min-l3-agents-per-router')
|
||||
if max_agents < min_agents:
|
||||
raise ValueError("max-l3-agents-per-router ({}) must be >= "
|
||||
"min-l3-agents-per-router "
|
||||
"({})".format(max_agents, min_agents))
|
||||
|
||||
ctxt['max_l3_agents_per_router'] = max_agents
|
||||
ctxt['min_l3_agents_per_router'] = min_agents
|
||||
|
||||
ctxt['dhcp_agents_per_network'] = config('dhcp-agents-per-network')
|
||||
ctxt['tenant_network_types'] = self.neutron_tenant_network_types
|
||||
ctxt['overlay_network_type'] = self.neutron_overlay_network_type
|
||||
|
|
|
@ -479,6 +479,20 @@ class NeutronCCContextTest(CharmTestCase):
|
|||
with patch.object(napi_ctxt, '_ensure_packages'):
|
||||
self.assertEquals(ctxt_data, napi_ctxt())
|
||||
|
||||
@patch.object(context.NeutronCCContext, 'network_manager')
|
||||
@patch.object(context.NeutronCCContext, 'plugin')
|
||||
@patch('__builtin__.__import__')
|
||||
def test_neutroncc_context_l3ha_l3_agents(self, _import, plugin, nm):
|
||||
plugin.return_value = None
|
||||
self.os_release.return_value = 'juno'
|
||||
self.test_config.set('enable-l3ha', True)
|
||||
self.test_config.set('l2-population', False)
|
||||
self.test_config.set('max-l3-agents-per-router', 2)
|
||||
self.test_config.set('min-l3-agents-per-router', 3)
|
||||
napi_ctxt = context.NeutronCCContext()
|
||||
with patch.object(napi_ctxt, '_ensure_packages'):
|
||||
self.assertRaises(ValueError, napi_ctxt)
|
||||
|
||||
@patch.object(context.NeutronCCContext, 'network_manager')
|
||||
@patch.object(context.NeutronCCContext, 'plugin')
|
||||
@patch('__builtin__.__import__')
|
||||
|
|
Loading…
Reference in New Issue