Browse Source

NSX|V3: Fix devstack cleanup for tier0 ports

In case using the cleantup with a newutron_db, tier0 logical ports
were not deleted, becasue the tier0 routers could not be found in
the neutron DB.

Change-Id: I78e6641f2d94331a081bae218a99bbc2973f2540
changes/90/700290/2
asarfaty 2 years ago
committed by Adit Sarfaty
parent
commit
fc7bb022b3
  1. 20
      devstack/tools/nsxv3_cleanup.py

20
devstack/tools/nsxv3_cleanup.py

@ -312,20 +312,32 @@ class NSXClient(object):
Retrieve all the logical routers based on router type. If tier
is None, it will return all logical routers.
"""
lrouters = self.nsxlib.logical_router.list(
return self.nsxlib.logical_router.list(
router_type=tier)['results']
def get_tier1_logical_routers(self):
"""
Retrieve all tier1 logical routers, and return only neutron ones.
"""
lrouters = self.get_logical_routers(tier='TIER1')
if self.neutron_db:
db_routers = self.neutron_db.get_logical_routers()
lrouters = [lr for lr in lrouters
if lr['id'] in db_routers]
return lrouters
def get_tier0_logical_routers(self):
"""
Retrieve all tier0 logical routers.
"""
return self.get_logical_routers(tier='TIER0')
def get_os_logical_routers(self):
"""
Retrieve all logical routers created from Neutron NSXv3 plugin
"""
lrouters = self.get_logical_routers()
lrouters = self.get_tier1_logical_routers()
return self.get_os_resources(lrouters)
def get_logical_router_ports(self, lrouter):
@ -382,7 +394,9 @@ class NSXClient(object):
"""
Delete all TIER0 logical router ports created from OpenStack
"""
tier0_routers = self.get_logical_routers(tier='TIER0')
tier0_routers = self.get_tier0_logical_routers()
print("Number of TIER0 Logical Routers whos ports will be deleted: "
"%s" % len(tier0_routers))
for lr in tier0_routers:
self.cleanup_logical_router_ports(lr)

Loading…
Cancel
Save