validate L3 HA min/max _l3_agents_per_router

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
This commit is contained in:
venkata anil 2014-12-09 14:11:49 +00:00
parent ef5d4f8bee
commit 7da314434e
3 changed files with 21 additions and 2 deletions

View File

@ -131,7 +131,13 @@ class L3_HA_NAT_db_mixin(l3_dvr_db.L3_NAT_with_dvr_db_mixin):
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):

View File

@ -55,6 +55,12 @@ class HANotEnoughAvailableAgents(exceptions.NeutronException):
"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.") %

View File

@ -114,12 +114,19 @@ class L3HATestCase(L3HATestFramework):
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'])