[NSX-P] Improve port deletion handling
During port deletion on the backend, we remove profile bindings and then the actual port. If for any reason a binding is not found, the process should still proceed to delete remaining resources up to the segment port. This change fixes this behaviour, as the code was instead returning as soon an object was not found. Change-Id: I529ce34db323f900129865befc6bd64e1ff4f5ff
This commit is contained in:
parent
5b2151d976
commit
c941dba414
@ -2294,21 +2294,34 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
|
|||||||
return port_data
|
return port_data
|
||||||
|
|
||||||
def _delete_port_on_backend(self, context, net_id, port_id):
|
def _delete_port_on_backend(self, context, net_id, port_id):
|
||||||
|
# Ignore resources not found on the backend, but still
|
||||||
|
# try and delete all of them!
|
||||||
try:
|
try:
|
||||||
segment_id = self._get_network_nsx_segment_id(context, net_id)
|
segment_id = self._get_network_nsx_segment_id(context, net_id)
|
||||||
self.nsxpolicy.segment_port_security_profiles.delete(
|
try:
|
||||||
segment_id, port_id)
|
self.nsxpolicy.segment_port_security_profiles.delete(
|
||||||
self.nsxpolicy.segment_port_discovery_profiles.delete(
|
|
||||||
segment_id, port_id)
|
|
||||||
if directory.get_plugin(plugin_const.QOS):
|
|
||||||
self.nsxpolicy.segment_port_qos_profiles.delete(
|
|
||||||
segment_id, port_id)
|
segment_id, port_id)
|
||||||
self.nsxpolicy.segment_port.delete(segment_id, port_id)
|
except nsx_lib_exc.ResourceNotFound:
|
||||||
except nsx_lib_exc.ResourceNotFound:
|
LOG.debug("Skipping deletion of port security profile for "
|
||||||
# If the resource was not found on the backend do not worry about
|
"port %s: Not Found", port_id)
|
||||||
# it. The conditions has already been logged, so there is no need
|
try:
|
||||||
# to do further logging
|
self.nsxpolicy.segment_port_discovery_profiles.delete(
|
||||||
pass
|
segment_id, port_id)
|
||||||
|
except nsx_lib_exc.ResourceNotFound:
|
||||||
|
LOG.debug("Skipping deletion of port discovery profile for "
|
||||||
|
"port %s: Not Found", port_id)
|
||||||
|
try:
|
||||||
|
if directory.get_plugin(plugin_const.QOS):
|
||||||
|
self.nsxpolicy.segment_port_qos_profiles.delete(
|
||||||
|
segment_id, port_id)
|
||||||
|
except nsx_lib_exc.ResourceNotFound:
|
||||||
|
LOG.debug("Skipping deletion of port QoS profile for "
|
||||||
|
"port %s: Not Found", port_id)
|
||||||
|
try:
|
||||||
|
self.nsxpolicy.segment_port.delete(segment_id, port_id)
|
||||||
|
except nsx_lib_exc.ResourceNotFound:
|
||||||
|
LOG.debug("Skipping deletion of sement port for "
|
||||||
|
"port %s: Not Found", port_id)
|
||||||
except nsx_lib_exc.ManagerError as e:
|
except nsx_lib_exc.ManagerError as e:
|
||||||
# If there is a failure in deleting the resource.
|
# If there is a failure in deleting the resource.
|
||||||
# In this case the neutron port was not deleted yet.
|
# In this case the neutron port was not deleted yet.
|
||||||
|
Loading…
Reference in New Issue
Block a user