]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Merge tag '2014.1_b1' into debian/icehouse
authorThomas Goirand <thomas@goirand.fr>
Mon, 9 Dec 2013 15:29:36 +0000 (23:29 +0800)
committerThomas Goirand <thomas@goirand.fr>
Mon, 9 Dec 2013 15:29:36 +0000 (23:29 +0800)
Neutron icehouse-1 milestone (2014.1.b1)

1  2 
neutron/plugins/ml2/plugin.py
neutron/tests/unit/midonet/mock_lib.py

index af7d6772beb1c12324149909dde76a9f94fd7d4e,0368930408c62569e30a0a599d84ec415a02307e..8b60a63ee0772d47fdb3ea8fedb525d39e61abe2
@@@ -378,46 -379,56 +379,57 @@@ class Ml2Plugin(db_base_plugin_v2.Neutr
  
          LOG.debug(_("Deleting network %s"), id)
          session = context.session
 +        filter = {'network_id': [id]}
          while True:
-             with session.begin(subtransactions=True):
-                 # Get ports to auto-delete.
-                 ports = (self._get_ports_query(context, filters=filter).
-                          all())
-                 LOG.debug(_("Ports to auto-delete: %s"), ports)
-                 only_auto_del = all(p.device_owner
-                                     in db_base_plugin_v2.
-                                     AUTO_DELETE_PORT_OWNERS
-                                     for p in ports)
-                 if not only_auto_del:
-                     LOG.debug(_("Tenant-owned ports exist"))
-                     raise exc.NetworkInUse(net_id=id)
-                 # Get subnets to auto-delete.
-                 subnets = (session.query(models_v2.Subnet).
-                            filter_by(network_id=id).
-                            all())
-                 LOG.debug(_("Subnets to auto-delete: %s"), subnets)
-                 if not (ports or subnets):
-                     network = self.get_network(context, id)
-                     mech_context = driver_context.NetworkContext(self,
-                                                                  context,
-                                                                  network)
-                     self.mechanism_manager.delete_network_precommit(
-                         mech_context)
-                     LOG.debug(_("Deleting network record"))
-                     record = self._get_network(context, id)
-                     session.delete(record)
-                     for segment in mech_context.network_segments:
-                         self.type_manager.release_segment(session, segment)
-                     # The segment records are deleted via cascade from the
-                     # network record, so explicit removal is not necessary.
-                     LOG.debug(_("Committing transaction"))
-                     break
+             try:
+                 with session.begin(subtransactions=True):
+                     # Get ports to auto-delete.
+                     ports = (session.query(models_v2.Port).
+                              enable_eagerloads(False).
+                              filter_by(network_id=id).
+                              with_lockmode('update').all())
+                     LOG.debug(_("Ports to auto-delete: %s"), ports)
+                     only_auto_del = all(p.device_owner
+                                         in db_base_plugin_v2.
+                                         AUTO_DELETE_PORT_OWNERS
+                                         for p in ports)
+                     if not only_auto_del:
+                         LOG.debug(_("Tenant-owned ports exist"))
+                         raise exc.NetworkInUse(net_id=id)
+                     # Get subnets to auto-delete.
+                     subnets = (session.query(models_v2.Subnet).
+                                enable_eagerloads(False).
+                                filter_by(network_id=id).
+                                with_lockmode('update').all())
+                     LOG.debug(_("Subnets to auto-delete: %s"), subnets)
+                     if not (ports or subnets):
+                         network = self.get_network(context, id)
+                         mech_context = driver_context.NetworkContext(self,
+                                                                      context,
+                                                                      network)
+                         self.mechanism_manager.delete_network_precommit(
+                             mech_context)
+                         record = self._get_network(context, id)
+                         LOG.debug(_("Deleting network record %s"), record)
+                         session.delete(record)
+                         for segment in mech_context.network_segments:
+                             self.type_manager.release_segment(session, segment)
+                         # The segment records are deleted via cascade from the
+                         # network record, so explicit removal is not necessary.
+                         LOG.debug(_("Committing transaction"))
+                         break
+             except os_db.exception.DBError as e:
+                 if isinstance(e.inner_exception, sql_exc.IntegrityError):
+                     msg = _("A concurrent port creation has occurred")
+                     LOG.warning(msg)
+                     continue
+                 else:
+                     raise
  
              for port in ports:
                  try:
index dc1d5ed25f0891fe68de64c3c0cb7a2d529459af,9fdae9cd6b48d586bca8f66983825147635365b3..b3dbfc74521025be75ad68c3a8e9c51780310cc9
@@@ -125,12 -128,12 +128,15 @@@ class MidonetLibMockConfig()
      def __init__(self, inst):
          self.inst = inst
  
-     def _create_bridge(self, tenant_id, name):
-         return get_bridge_mock(tenant_id=tenant_id, name=name)
+     def _create_bridge(self, **kwargs):
+         return get_bridge_mock(**kwargs)
+     def _create_router(self, **kwargs):
+         return get_router_mock(**kwargs)
  
 +    def _create_router(self, tenant_id, name):
 +        return get_router_mock(tenant_id=tenant_id, name=name)
 +
      def _create_subnet(self, bridge, gateway_ip, subnet_prefix, subnet_len):
          return get_subnet_mock(bridge.get_id(), gateway_ip=gateway_ip,
                                 subnet_prefix=subnet_prefix,