Merge "Define dhcp_agents_per_network with min=1"
This commit is contained in:
commit
a887a026b4
|
@ -27,6 +27,7 @@ AGENTS_SCHEDULER_OPTS = [
|
|||
help=_('Automatically remove networks from offline DHCP '
|
||||
'agents.')),
|
||||
cfg.IntOpt('dhcp_agents_per_network', default=1,
|
||||
min=1,
|
||||
help=_('Number of DHCP agents scheduled to host a tenant '
|
||||
'network. If this number is greater than 1, the '
|
||||
'scheduler automatically assigns multiple DHCP agents '
|
||||
|
|
|
@ -73,19 +73,6 @@ class Manager(periodic_task.PeriodicTasks):
|
|||
pass
|
||||
|
||||
|
||||
def validate_post_plugin_load():
|
||||
"""Checks if the configuration variables are valid.
|
||||
|
||||
If the configuration is invalid then the method will return an error
|
||||
message. If all is OK then it will return None.
|
||||
"""
|
||||
if ('dhcp_agents_per_network' in cfg.CONF and
|
||||
cfg.CONF.dhcp_agents_per_network <= 0):
|
||||
msg = _("dhcp_agents_per_network must be >= 1. '%s' "
|
||||
"is invalid.") % cfg.CONF.dhcp_agents_per_network
|
||||
return msg
|
||||
|
||||
|
||||
def validate_pre_plugin_load():
|
||||
"""Checks if the configuration variables are valid.
|
||||
|
||||
|
@ -135,10 +122,6 @@ class NeutronManager(object):
|
|||
plugin = self._get_plugin_instance(CORE_PLUGINS_NAMESPACE,
|
||||
plugin_provider)
|
||||
directory.add_plugin(lib_const.CORE, plugin)
|
||||
msg = validate_post_plugin_load()
|
||||
if msg:
|
||||
LOG.critical(msg)
|
||||
raise Exception(msg)
|
||||
|
||||
# load services from the core plugin first
|
||||
self._load_services_from_core_plugin(plugin)
|
||||
|
|
|
@ -217,17 +217,10 @@ class NeutronManagerTestCase(base.BaseTestCase):
|
|||
svc_plugins = directory.get_plugins()
|
||||
self.assertIn(dummy_plugin.DUMMY_SERVICE_TYPE, svc_plugins)
|
||||
|
||||
def test_post_plugin_validation(self):
|
||||
cfg.CONF.import_opt('dhcp_agents_per_network',
|
||||
'neutron.db.agentschedulers_db')
|
||||
|
||||
self.assertIsNone(manager.validate_post_plugin_load())
|
||||
cfg.CONF.set_override('dhcp_agents_per_network', 2)
|
||||
self.assertIsNone(manager.validate_post_plugin_load())
|
||||
cfg.CONF.set_override('dhcp_agents_per_network', 0)
|
||||
self.assertIsNotNone(manager.validate_post_plugin_load())
|
||||
cfg.CONF.set_override('dhcp_agents_per_network', -1)
|
||||
self.assertIsNotNone(manager.validate_post_plugin_load())
|
||||
def test_dhcp_agents_per_network_min(self):
|
||||
# Ensures dhcp_agents_per_network must be at least 1.
|
||||
self.assertRaises(ValueError, cfg.CONF.set_override,
|
||||
'dhcp_agents_per_network', 0)
|
||||
|
||||
def test_pre_plugin_validation(self):
|
||||
self.assertIsNotNone(manager.validate_pre_plugin_load())
|
||||
|
|
Loading…
Reference in New Issue