]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Register agent schedulers options in one place
authorOleg Bondarev <obondarev@mirantis.com>
Mon, 8 Jul 2013 12:00:10 +0000 (16:00 +0400)
committerOleg Bondarev <obondarev@mirantis.com>
Tue, 9 Jul 2013 09:24:26 +0000 (13:24 +0400)
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

neutron/db/agentschedulers_db.py
neutron/plugins/brocade/NeutronPlugin.py
neutron/plugins/linuxbridge/common/config.py
neutron/plugins/ml2/config.py
neutron/plugins/nec/common/config.py
neutron/plugins/nicira/common/config.py
neutron/plugins/openvswitch/common/config.py
neutron/scheduler/__init__.py
neutron/tests/unit/test_neutron_manager.py

index 964b1d20af5937a53966a8a269312ba933537742..5eaa7a2969295dfc7f3c47b767cdf0787fee12db 100644 (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."""
index 137fb979eef714af656de1c6d088acc3af9da034..f90f9865362dd032aa9b6794bbf50cbfd75529dc 100644 (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,
index dc35f765031b42bf65504b1af6155c0a6c9406e1..6a12f037e6cf15320236b118821de0edc0c3a7bd 100644 (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)
index 867fd8fcf93bb14c6e4b1c6f4d940e66a7009512..90033e3d44ec368e06c2cc5abff258c6f5efd480 100644 (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)
index fb5ad2b8ca236e8ca945e699ebc81cc9007ea8c1..669887f5913bc1f9dbfcb8b9c6be8026c022ee9a 100644 (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
index 17017f74a695767c07c2a3db42d55e7b2601c341..6d2d74f3b63219722c6cdd1e31ea2856c12fe568 100644 (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
index 90578aeb35850897504312d5c3ab57237fe11181..f4bd2c2e91c561e38771613d92e2f7a5bd17eef2 100644 (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)
index b2660c90ff1e7ade205aa0e77a72b4e0c038a418..7506a29144cce0bb64c57589bd045fa05313d274 100644 (file)
 #    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.')),
-]
index c4b91f6627483383fc2a2d22ef9675cecefd8046..16033e3ca62fb0a0a8b22bbf85649ec0c607dd48 100644 (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())