Merge "Fix the async between network and edge"

This commit is contained in:
Jenkins 2015-03-05 08:21:15 +00:00 committed by Gerrit Code Review
commit 23ce6bd927

View File

@ -680,19 +680,20 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
# Update the DHCP edge for metadata and clean the vnic in DHCP edge # Update the DHCP edge for metadata and clean the vnic in DHCP edge
# if there is only no other existing port besides DHCP port # if there is only no other existing port besides DHCP port
filters = {'network_id': [id], 'enable_dhcp': [True]} filters = {'network_id': [id]}
subnet_ids = self.get_subnets(context, filters=filters, fields=['id']) ports = self.get_ports(context, filters=filters)
dhcp_port_count = 0 auto_del = all(p['device_owner'] in [constants.DEVICE_OWNER_DHCP]
for subnet_id in subnet_ids: for p in ports)
filters = {'fixed_ips': {'subnet_id': [subnet_id['id']]}} if auto_del:
dhcp_port_count += self.get_ports_count(context, filters=filters) filters = {'network_id': [id], 'enable_dhcp': [True]}
if (dhcp_port_count == len(subnet_ids)) and dhcp_port_count > 0: sids = self.get_subnets(context, filters=filters, fields=['id'])
try: if len(sids) > 0:
self._cleanup_dhcp_edge_before_deletion(context, id) try:
self._delete_dhcp_edge_service(context, id) self._cleanup_dhcp_edge_before_deletion(context, id)
except Exception: self._delete_dhcp_edge_service(context, id)
with excutils.save_and_reraise_exception(): except Exception:
LOG.exception(_('Failed to delete network')) with excutils.save_and_reraise_exception():
LOG.exception(_('Failed to delete network'))
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
self._process_l3_delete(context, id) self._process_l3_delete(context, id)
@ -952,7 +953,9 @@ class NsxVPluginV2(agents_db.AgentDbMixin,
if l3_port_check: if l3_port_check:
self.prevent_l3_port_deletion(context, id) self.prevent_l3_port_deletion(context, id)
neutron_db_port = self.get_port(context, id) neutron_db_port = self.get_port(context, id)
if neutron_db_port['device_owner'] in [constants.DEVICE_OWNER_DHCP]:
msg = (_('Can not delete DHCP port %s') % neutron_db_port['id'])
raise n_exc.BadRequest(resource='port', msg=msg)
# If this port is attached to a device, remove the corresponding vnic # If this port is attached to a device, remove the corresponding vnic
# from all NSXv Security-Groups and the spoofguard policy # from all NSXv Security-Groups and the spoofguard policy
port_index = neutron_db_port.get(ext_vnic_idx.VNIC_INDEX) port_index = neutron_db_port.get(ext_vnic_idx.VNIC_INDEX)