From 5bc885ddc06d4b7034152e67a36a59a5d5d2d003 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Tue, 1 Sep 2015 13:49:51 -0700 Subject: [PATCH] NSX-mh: perform appropriate pre-delete checks This patch ensures that pre-delete checks are executed in the appropriate way for both DVR and 'traditional' routers, by invoking the _ensure_router_not_in_use method defined in neutron.db.l3_db.L3_nat_dbonly_mixin Also, verify metadata network before removing router to ensure metada access network's router port is removed if not yet deleted. Applied from commit: 5a07069824d468bc9b49cf72c8d5092d5a8a523f Change-Id: I96933c4523bdd90fbc2647f4860533f8d53802e4 Closes-Bug: #1479309 --- neutron/plugins/vmware/plugins/base.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/neutron/plugins/vmware/plugins/base.py b/neutron/plugins/vmware/plugins/base.py index 169ba2895ea..c3bce62dcb4 100644 --- a/neutron/plugins/vmware/plugins/base.py +++ b/neutron/plugins/vmware/plugins/base.py @@ -1551,26 +1551,11 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, # transaction, and it should be restored on rollback self.handle_router_metadata_access( context, router_id, interface=None) - # Pre-delete checks # NOTE(salv-orlando): These checks will be repeated anyway when # calling the superclass. This is wasteful, but is the simplest # way of ensuring a consistent removal of the router both in # the neutron Database and in the NSX backend. - # TODO(salv-orlando): split pre-delete checks and actual - # deletion in superclass. - - # Ensure that the router is not used - fips = self.get_floatingips_count( - context.elevated(), filters={'router_id': [router_id]}) - if fips: - raise l3.RouterInUse(router_id=router_id) - - device_filter = {'device_id': [router_id], - 'device_owner': [l3_db.DEVICE_OWNER_ROUTER_INTF]} - ports = self._core_plugin.get_ports_count(context.elevated(), - filters=device_filter) - if ports: - raise l3.RouterInUse(router_id=router_id) + self._ensure_router_not_in_use(context, router_id) nsx_router_id = nsx_utils.get_nsx_router_id( context.session, self.cluster, router_id)