Merge "NSXv: concurrent subnet creation bugfix"

This commit is contained in:
Jenkins 2016-11-13 07:21:47 +00:00 committed by Gerrit Code Review
commit 82a12dec8a

View File

@ -1927,18 +1927,19 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
err_msg = _("The requested subnet contains reserved IP's") err_msg = _("The requested subnet contains reserved IP's")
raise n_exc.InvalidInput(error_message=err_msg) raise n_exc.InvalidInput(error_message=err_msg)
with locking.LockManager.get_lock('nsx-edge-pool'): with locking.LockManager.get_lock(subnet['subnet']['network_id']):
s = super(NsxVPluginV2, self).create_subnet(context, subnet) with locking.LockManager.get_lock('nsx-edge-pool'):
if s['enable_dhcp']: s = super(NsxVPluginV2, self).create_subnet(context, subnet)
try: if s['enable_dhcp']:
self._process_subnet_ext_attr_create( try:
session=context.session, self._process_subnet_ext_attr_create(
subnet_db=s, session=context.session,
subnet_req=data) subnet_db=s,
self._update_dhcp_service_with_subnet(context, s) subnet_req=data)
except Exception: self._update_dhcp_service_with_subnet(context, s)
with excutils.save_and_reraise_exception(): except Exception:
self.delete_subnet(context, s['id']) with excutils.save_and_reraise_exception():
self.delete_subnet(context, s['id'])
return s return s
def _process_subnet_ext_attr_create(self, session, subnet_db, def _process_subnet_ext_attr_create(self, session, subnet_db,