From: Sourabh Patwardhan Date: Thu, 14 Aug 2014 00:31:45 +0000 (-0700) Subject: Networks are not scheduled to DHCP agents for Cisco N1KV plugin X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=0fcedae747f257e2424b669ec65f32b76f12155a;p=openstack-build%2Fneutron-build.git Networks are not scheduled to DHCP agents for Cisco N1KV plugin With the config option 'network_auto_schedule = False' in neutron.conf, networks do not get scheduled to available DHCP agents. The fix is to explicitly schedule the network as part of the subnet creation flow. Change-Id: Id1f94a5844111a916f984d6dd7bda2cb4e11e1ee Closes-Bug: #1356609 --- diff --git a/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py b/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py index 7933d5d97..b59a5439d 100644 --- a/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py +++ b/neutron/plugins/cisco/n1kv/n1kv_neutron_plugin.py @@ -1310,6 +1310,10 @@ class N1kvNeutronPluginV2(db_base_plugin_v2.NeutronDbPluginV2, self).delete_subnet(context, sub['id']) else: LOG.debug(_("Created subnet: %s"), sub['id']) + if not q_conf.CONF.network_auto_schedule: + # Schedule network to a DHCP agent + net = self.get_network(context, sub['network_id']) + self.schedule_network(context, net) return sub def update_subnet(self, context, id, subnet): diff --git a/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py b/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py index 201016385..c4be3f3a1 100644 --- a/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py +++ b/neutron/tests/unit/cisco/n1kv/test_n1kv_plugin.py @@ -28,6 +28,7 @@ from neutron.extensions import portbindings from neutron import manager from neutron.plugins.cisco.common import cisco_constants as c_const from neutron.plugins.cisco.common import cisco_exceptions as c_exc +from neutron.plugins.cisco.common import config as c_conf from neutron.plugins.cisco.db import n1kv_db_v2 from neutron.plugins.cisco.db import n1kv_models_v2 from neutron.plugins.cisco.db import network_db_v2 as cdb @@ -1073,6 +1074,17 @@ class TestN1kvSubnets(test_plugin.TestSubnetsV2, self.assertEqual(req.get_response(self.api).status_int, webob.exc.HTTPNoContent.code) + def test_schedule_network_with_subnet_create(self): + """Test invocation of explicit scheduling for networks.""" + with mock.patch.object(n1kv_neutron_plugin.N1kvNeutronPluginV2, + 'schedule_network') as mock_method: + # Test with network auto-scheduling disabled + c_conf.CONF.set_override('network_auto_schedule', False) + # Subnet creation should trigger scheduling for networks + with self.subnet(): + pass + self.assertEqual(1, mock_method.call_count) + class TestN1kvL3Test(test_l3_plugin.L3NatExtensionTestCase):