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):
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
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):