Register agent schedulers options in one place

Currently agent schedulers options are defined in neutron.scheduler and
every plugin that supports scheduling should register them individually.
It is reasonable to define and register options in one place - agentschedulers_db.

Fixes NeutronManagerTestCase when running separately by importing missing config option

Fixes bug 1198904

Change-Id: Ia9c1ad3fb4b71796401ef5507f741f3cc024a4da
This commit is contained in:
Oleg Bondarev 2013-07-08 16:00:10 +04:00
parent 5434abbd4c
commit 1761fce9ea
9 changed files with 23 additions and 34 deletions

View File

@ -15,6 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
import sqlalchemy as sa
from sqlalchemy import orm
from sqlalchemy.orm import exc
@ -31,6 +32,25 @@ from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__)
AGENTS_SCHEDULER_OPTS = [
cfg.StrOpt('network_scheduler_driver',
default='neutron.scheduler.'
'dhcp_agent_scheduler.ChanceScheduler',
help=_('Driver to use for scheduling network to DHCP agent')),
cfg.StrOpt('router_scheduler_driver',
default='neutron.scheduler.l3_agent_scheduler.ChanceScheduler',
help=_('Driver to use for scheduling '
'router to a default L3 agent')),
cfg.BoolOpt('network_auto_schedule', default=True,
help=_('Allow auto scheduling networks to DHCP agent.')),
cfg.BoolOpt('router_auto_schedule', default=True,
help=_('Allow auto scheduling routers to L3 agent.')),
cfg.IntOpt('dhcp_agents_per_network', default=1,
help=_('Number of DHCP agents scheduled to host a network.')),
]
cfg.CONF.register_opts(AGENTS_SCHEDULER_OPTS)
class NetworkDhcpAgentBinding(model_base.BASEV2):
"""Represents binding between neutron networks and DHCP agents."""

View File

@ -50,7 +50,6 @@ from neutron.openstack.common import rpc
from neutron.openstack.common.rpc import proxy
from neutron.plugins.brocade.db import models as brocade_db
from neutron.plugins.brocade import vlanbm as vbm
from neutron import scheduler
LOG = logging.getLogger(__name__)
@ -69,7 +68,6 @@ PHYSICAL_INTERFACE_OPTS = [cfg.StrOpt('physical_interface', default='eth0')
cfg.CONF.register_opts(SWITCH_OPTS, "SWITCH")
cfg.CONF.register_opts(PHYSICAL_INTERFACE_OPTS, "PHYSICAL_INTERFACE")
cfg.CONF.register_opts(scheduler.AGENTS_SCHEDULER_OPTS)
class BridgeRpcCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin,

View File

@ -20,7 +20,6 @@
from oslo.config import cfg
from neutron.agent.common import config
from neutron import scheduler
DEFAULT_VLAN_RANGES = []
DEFAULT_INTERFACE_MAPPINGS = []
@ -55,6 +54,5 @@ agent_opts = [
cfg.CONF.register_opts(vlan_opts, "VLANS")
cfg.CONF.register_opts(bridge_opts, "LINUX_BRIDGE")
cfg.CONF.register_opts(agent_opts, "AGENT")
cfg.CONF.register_opts(scheduler.AGENTS_SCHEDULER_OPTS)
config.register_agent_state_opts_helper(cfg.CONF)
config.register_root_helper(cfg.CONF)

View File

@ -15,8 +15,6 @@
from oslo.config import cfg
from neutron import scheduler
ml2_opts = [
cfg.ListOpt('type_drivers',
@ -36,4 +34,3 @@ ml2_opts = [
cfg.CONF.register_opts(ml2_opts, "ml2")
cfg.CONF.register_opts(scheduler.AGENTS_SCHEDULER_OPTS)

View File

@ -19,7 +19,6 @@ from oslo.config import cfg
from neutron.agent.common import config
from neutron.openstack.common import rpc # noqa
from neutron import scheduler
ovs_opts = [
@ -56,7 +55,6 @@ cfg.CONF.register_opts(agent_opts, "AGENT")
cfg.CONF.register_opts(ofc_opts, "OFC")
config.register_agent_state_opts_helper(cfg.CONF)
config.register_root_helper(cfg.CONF)
cfg.CONF.register_opts(scheduler.AGENTS_SCHEDULER_OPTS)
# shortcuts
CONF = cfg.CONF

View File

@ -16,8 +16,6 @@
from oslo.config import cfg
from neutron import scheduler
nvp_opts = [
cfg.IntOpt('max_lp_per_bridged_ls', default=64,
help=_("Maximum number of ports of a logical switch on a "
@ -97,7 +95,6 @@ cluster_opts = [
cfg.CONF.register_opts(connection_opts)
cfg.CONF.register_opts(cluster_opts)
cfg.CONF.register_opts(nvp_opts, "NVP")
cfg.CONF.register_opts(scheduler.AGENTS_SCHEDULER_OPTS)
# NOTE(armando-migliaccio): keep the following code until we support
# NVP configuration files in older format (Grizzly or older).
# ### BEGIN

View File

@ -18,7 +18,6 @@ from oslo.config import cfg
from neutron.agent.common import config
from neutron.plugins.openvswitch.common import constants
from neutron import scheduler
DEFAULT_BRIDGE_MAPPINGS = []
@ -71,4 +70,3 @@ cfg.CONF.register_opts(ovs_opts, "OVS")
cfg.CONF.register_opts(agent_opts, "AGENT")
config.register_agent_state_opts_helper(cfg.CONF)
config.register_root_helper(cfg.CONF)
cfg.CONF.register_opts(scheduler.AGENTS_SCHEDULER_OPTS)

View File

@ -14,23 +14,3 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo.config import cfg
AGENTS_SCHEDULER_OPTS = [
cfg.StrOpt('network_scheduler_driver',
default='neutron.scheduler.'
'dhcp_agent_scheduler.ChanceScheduler',
help=_('Driver to use for scheduling network to DHCP agent')),
cfg.StrOpt('router_scheduler_driver',
default='neutron.scheduler.l3_agent_scheduler.ChanceScheduler',
help=_('Driver to use for scheduling '
'router to a default L3 agent')),
cfg.BoolOpt('network_auto_schedule', default=True,
help=_('Allow auto scheduling networks to DHCP agent.')),
cfg.BoolOpt('router_auto_schedule', default=True,
help=_('Allow auto scheduling routers to L3 agent.')),
cfg.IntOpt('dhcp_agents_per_network', default=1,
help=_('Number of DHCP agents scheduled to host a network.')),
]

View File

@ -106,6 +106,9 @@ class NeutronManagerTestCase(base.BaseTestCase):
self.assertIn(constants.DUMMY, svc_plugins.keys())
def test_post_plugin_validation(self):
cfg.CONF.import_opt('dhcp_agents_per_network',
'neutron.db.agentschedulers_db')
self.assertIsNone(validate_post_plugin_load())
cfg.CONF.set_override('dhcp_agents_per_network', 2)
self.assertIsNone(validate_post_plugin_load())