def delete_router(self, context, id):
with context.session.begin(subtransactions=True):
+ # Ensure metadata access network is detached and destroyed
+ # This will also destroy relevant objects on NVP platform.
+ # NOTE(salvatore-orlando): A failure in this operation will
+ # cause the router delete operation to fail too.
+ self._handle_metadata_access_network(context, id, do_create=False)
super(NvpPluginV2, self).delete_router(context, id)
# If removal is successful in Quantum it should be so on
# the NVP platform too - otherwise the transaction should
results = nvplib.query_lswitch_lports(
cluster, '*', relations="LogicalPortAttachment",
filters={'tag': port_id, 'tag_scope': 'q_port_id'})
+ lrouter_port_id = None
if len(results):
lport = results[0]
attachment_data = lport['_relations'].get('LogicalPortAttachment')
# to leverage validation performed in the base class
if not lrouter_port_id:
LOG.warning(_("Unable to find NVP logical router port for "
- "Quantum port id:%(q_port_id)s (NVP id: "
- "%(nvp_port_id)s). Was this port "
- "ever paired with a logical router?"),
- {'q_port_id': port_id,
- 'nvp_port_id': lport['uuid']})
+ "Quantum port id:%s. Was this port ever paired "
+ "with a logical router?"), port_id)
return
# Ensure the connection to the 'metadata access network'
{'network': {'id': meta_net_id}},
'network.delete.end')
- def _handle_metadata_access_network(self, context, router_id):
+ def _handle_metadata_access_network(self, context, router_id,
+ do_create=True):
if not cfg.CONF.NVP.enable_metadata_access_network:
LOG.debug(_("Metadata access network is disabled"))
return
'device_owner': [l3_db.DEVICE_OWNER_ROUTER_INTF]}
with ctx_elevated.session.begin(subtransactions=True):
ports = self.get_ports(ctx_elevated, filters=device_filter)
+ # Filter out ports without an IP (those are 'stale' router ports)
+ ports = [port for port in ports if port['fixed_ips']]
try:
if ports:
- if not self._find_metadata_port(ctx_elevated, ports):
+ if (do_create and
+ not self._find_metadata_port(ctx_elevated, ports)):
self._create_metadata_access_network(context,
router_id)
elif len(ports) == 1:
- # The only port left if the metadata port
+ # The only port left is the metadata port
self._destroy_metadata_access_network(context,
router_id,
ports)