Merge "NSX|V: ensure that the subinterface validations are atomic"

This commit is contained in:
Jenkins 2017-05-16 09:26:44 +00:00 committed by Gerrit Code Review
commit 387efd8657
2 changed files with 23 additions and 17 deletions

View File

@ -1998,10 +1998,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._create_dhcp_static_binding(context, ret_port) self._create_dhcp_static_binding(context, ret_port)
elif owner == constants.DEVICE_OWNER_DHCP: elif owner == constants.DEVICE_OWNER_DHCP:
# Update the ip of the dhcp port # Update the ip of the dhcp port
address_groups = self._create_network_dhcp_address_group( with locking.LockManager.get_lock(ret_port['network_id']):
context, ret_port['network_id']) address_groups = self._create_network_dhcp_address_group(
self._update_dhcp_edge_service( context, ret_port['network_id'])
context, ret_port['network_id'], address_groups) self._update_dhcp_edge_service(
context, ret_port['network_id'], address_groups)
elif (owner == constants.DEVICE_OWNER_ROUTER_GW or elif (owner == constants.DEVICE_OWNER_ROUTER_GW or
owner == constants.DEVICE_OWNER_ROUTER_INTF): owner == constants.DEVICE_OWNER_ROUTER_INTF):
# This is a router port - update the edge appliance # This is a router port - update the edge appliance
@ -2259,10 +2260,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self._delete_dhcp_edge_service(context, network_id) self._delete_dhcp_edge_service(context, network_id)
else: else:
# Update address group and delete the DHCP port only # Update address group and delete the DHCP port only
address_groups = self._create_network_dhcp_address_group( with locking.LockManager.get_lock(network_id):
context, network_id) addr_groups = self._create_network_dhcp_address_group(
self._update_dhcp_edge_service(context, network_id, context, network_id)
address_groups) self._update_dhcp_edge_service(context, network_id,
addr_groups)
def _is_overlapping_reserved_subnets(self, subnet): def _is_overlapping_reserved_subnets(self, subnet):
"""Return True if the subnet overlaps with reserved subnets. """Return True if the subnet overlaps with reserved subnets.
@ -2562,7 +2564,9 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self.create_port(context, {'port': port_dict}) self.create_port(context, {'port': port_dict})
# First time binding network with dhcp edge # First time binding network with dhcp edge
else: else:
self._update_dhcp_service_with_subnet(context, subnet) with locking.LockManager.get_lock(
subnet['subnet']['network_id']):
self._update_dhcp_service_with_subnet(context, subnet)
return return
else: else:
# delete dhcp port # delete dhcp port
@ -2586,9 +2590,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
network_id) network_id)
self._delete_dhcp_edge_service(context, network_id) self._delete_dhcp_edge_service(context, network_id)
return return
address_groups = self._create_network_dhcp_address_group(context, with locking.LockManager.get_lock(network_id):
network_id) address_groups = self._create_network_dhcp_address_group(
self._update_dhcp_edge_service(context, network_id, address_groups) context, network_id)
self._update_dhcp_edge_service(context, network_id,
address_groups)
def _get_conflict_network_ids_by_overlapping(self, context, subnets): def _get_conflict_network_ids_by_overlapping(self, context, subnets):
with locking.LockManager.get_lock('nsx-networking'): with locking.LockManager.get_lock('nsx-networking'):

View File

@ -1529,11 +1529,11 @@ class EdgeManager(object):
LOG.error('Database conflict could not be recovered ' LOG.error('Database conflict could not be recovered '
'for VDR %(vdr)s DHCP edge %(dhcp)s', 'for VDR %(vdr)s DHCP edge %(dhcp)s',
{'vdr': vdr_router_id, 'dhcp': dhcp_edge_id}) {'vdr': vdr_router_id, 'dhcp': dhcp_edge_id})
with locking.LockManager.get_lock(network_id):
address_groups = self.plugin._create_network_dhcp_address_group( address_groups = self.plugin._create_network_dhcp_address_group(
context, network_id) context, network_id)
self.update_dhcp_edge_service( self.update_dhcp_edge_service(
context, network_id, address_groups=address_groups) context, network_id, address_groups=address_groups)
self.set_sysctl_rp_filter_for_vdr_dhcp( self.set_sysctl_rp_filter_for_vdr_dhcp(
context, dhcp_edge_id, network_id) context, dhcp_edge_id, network_id)