Merge "use payloads for PORT BEFORE_DELETE callbacks"
This commit is contained in:
commit
e3613af0a1
@ -496,12 +496,13 @@ def _update_port_in_external_dns_service(resource, event, trigger, **kwargs):
|
||||
updated_ips)
|
||||
|
||||
|
||||
def _delete_port_in_external_dns_service(resource, event, trigger, **kwargs):
|
||||
def _delete_port_in_external_dns_service(resource, event,
|
||||
trigger, payload=None):
|
||||
dns_driver = _get_dns_driver()
|
||||
if not dns_driver:
|
||||
return
|
||||
context = kwargs['context']
|
||||
port_id = kwargs['port_id']
|
||||
context = payload.context
|
||||
port_id = payload.resource_id
|
||||
dns_data_db = obj_reg.load_class('PortDNS').get_object(
|
||||
context, port_id=port_id)
|
||||
if not dns_data_db:
|
||||
|
@ -297,15 +297,16 @@ class NsxTVDPlugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin,
|
||||
resources.PORT, events.BEFORE_DELETE)
|
||||
|
||||
@staticmethod
|
||||
def _prevent_l3_port_delete_callback(resource, event, trigger, **kwargs):
|
||||
def _prevent_l3_port_delete_callback(resource, event,
|
||||
trigger, payload=None):
|
||||
"""Register a callback to replace the default one
|
||||
|
||||
This callback will prevent port deleting only if the port plugin
|
||||
is not NSX-T (in NSX-T plugin it was already handled)
|
||||
"""
|
||||
context = kwargs['context']
|
||||
port_id = kwargs['port_id']
|
||||
port_check = kwargs['port_check']
|
||||
context = payload.context
|
||||
port_id = payload.resource_id
|
||||
port_check = payload.metadata['port_check']
|
||||
l3plugin = directory.get_plugin(plugin_constants.L3)
|
||||
if l3plugin and port_check:
|
||||
# if not nsx-t - call super code
|
||||
|
@ -2562,13 +2562,11 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
|
||||
def delete_port(self, context, id, l3_port_check=True,
|
||||
nw_gw_port_check=True, force_delete_dhcp=False,
|
||||
allow_delete_internal=False):
|
||||
kwargs = {
|
||||
'context': context,
|
||||
'port_check': l3_port_check,
|
||||
'port_id': id,
|
||||
}
|
||||
# Send delete port notification to any interested service plugin
|
||||
registry.notify(resources.PORT, events.BEFORE_DELETE, self, **kwargs)
|
||||
registry.publish(resources.PORT, events.BEFORE_DELETE, self,
|
||||
payload=events.DBEventPayload(
|
||||
context, resource_id=id,
|
||||
metadata={'port_check': l3_port_check}))
|
||||
|
||||
neutron_db_port = self.get_port(context, id)
|
||||
device_id = neutron_db_port['device_id']
|
||||
|
@ -1667,14 +1667,12 @@ class NsxV3Plugin(nsx_plugin_common.NsxPluginV3Base,
|
||||
def _pre_delete_port_check(self, context, port_id, l2gw_port_check):
|
||||
"""Perform checks prior to deleting a port."""
|
||||
try:
|
||||
kwargs = {
|
||||
'context': context,
|
||||
'port_check': l2gw_port_check,
|
||||
'port_id': port_id,
|
||||
}
|
||||
# Send delete port notification to any interested service plugin
|
||||
registry.notify(
|
||||
resources.PORT, events.BEFORE_DELETE, self, **kwargs)
|
||||
registry.publish(
|
||||
resources.PORT, events.BEFORE_DELETE, self,
|
||||
payload=events.DBEventPayload(
|
||||
context, resource_id=port_id,
|
||||
metadata={'port_check': l2gw_port_check}))
|
||||
except callback_exc.CallbackFailure as e:
|
||||
if len(e.errors) == 1:
|
||||
raise e.errors[0].error
|
||||
|
@ -132,10 +132,11 @@ class NsxV3Driver(l2gateway_db.L2GatewayMixin):
|
||||
def_l2gw_exists = True
|
||||
return l2_gateway
|
||||
|
||||
def _prevent_l2gw_port_delete(self, resource, event, trigger, **kwargs):
|
||||
context = kwargs.get('context')
|
||||
port_id = kwargs.get('port_id')
|
||||
port_check = kwargs.get('port_check')
|
||||
def _prevent_l2gw_port_delete(self, resource, event,
|
||||
trigger, payload=None):
|
||||
context = payload.context
|
||||
port_id = payload.resource_id
|
||||
port_check = payload.metadata['port_check']
|
||||
if port_check:
|
||||
self.prevent_l2gw_port_deletion(context, port_id)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user