The below missing validation is added for L3 HA
max_l3_agents_per_router >= min_l3_agents_per_router
Closes-bug: #
1400311
Change-Id: I1d548b9a0a04c8855ada42206c2a333597c2c85b
if ('/' not in self.ha_cidr or net.network != net.ip):
raise l3_ha.HANetworkCIDRNotValid(cidr=self.ha_cidr)
- if cfg.CONF.min_l3_agents_per_router < constants.MINIMUM_AGENTS_FOR_HA:
+ max_agents = cfg.CONF.max_l3_agents_per_router
+ min_agents = cfg.CONF.min_l3_agents_per_router
+ if max_agents < min_agents:
+ raise l3_ha.HAMaximumAgentsNumberNotValid(
+ max_agents=max_agents, min_agents=min_agents)
+
+ if min_agents < constants.MINIMUM_AGENTS_FOR_HA:
raise l3_ha.HAMinimumAgentsNumberNotValid()
def __init__(self):
"required %(min_agents)s, available %(num_agents)s.")
+class HAMaximumAgentsNumberNotValid(exceptions.NeutronException):
+ message = _("max_l3_agents_per_router %(max_agents)s config parameter "
+ "is not valid. It has to be greater than or equal to "
+ "min_l3_agents_per_router %(min_agents)s.")
+
+
class HAMinimumAgentsNumberNotValid(exceptions.NeutronException):
message = (_("min_l3_agents_per_router config parameter is not valid. "
"It has to be equal to or more than %s for HA.") %
l3_ext_ha_mode.HANetworkCIDRNotValid,
self.plugin._verify_configuration)
- def test_verify_conifguration_min_l3_agents_per_router_below_minimum(self):
+ def test_verify_configuration_min_l3_agents_per_router_below_minimum(self):
cfg.CONF.set_override('min_l3_agents_per_router', 0)
self.assertRaises(
l3_ext_ha_mode.HAMinimumAgentsNumberNotValid,
self.plugin._verify_configuration)
+ def test_verify_configuration_max_l3_agents_below_min_l3_agents(self):
+ cfg.CONF.set_override('max_l3_agents_per_router', 3)
+ cfg.CONF.set_override('min_l3_agents_per_router', 4)
+ self.assertRaises(
+ l3_ext_ha_mode.HAMaximumAgentsNumberNotValid,
+ self.plugin._verify_configuration)
+
def test_ha_router_create(self):
router = self._create_router()
self.assertTrue(router['ha'])