NSX|P: add static routes deletion to devstack cleanup

Change-Id: I75152f3fcd0853b5068c2db142f068e28ada0baa
This commit is contained in:
asarfaty 2021-02-21 12:23:43 +02:00 committed by Adit Sarfaty
parent a3ef5afb84
commit 5c14c59ac9
1 changed files with 12 additions and 1 deletions

View File

@ -157,6 +157,16 @@ class NSXClient(object):
except exceptions.ManagerError as e:
print("Failed to delete nat rule %s: %s" % (rule['id'], e))
def cleanup_tier1_static_routes(self, tier1_uuid):
routes = self.nsxpolicy.tier1_static_route.list(tier1_uuid)
for route in routes:
try:
self.nsxpolicy.tier1_static_route.delete(tier1_uuid,
route['id'])
except exceptions.ManagerError as e:
print("Failed to delete static route %s: %s" %
(route['id'], e))
def cleanup_tier1_routers(self):
"""Delete all OS created NSX Policy routers"""
routers = self.get_os_nsx_tier1_routers()
@ -164,8 +174,9 @@ class NSXClient(object):
for rtr in routers:
# remove all fwaas resources
self.cleanup_fwaas_router_resources(rtr['id'])
# remove all nat rules from this router before deletion
# remove all nat rules and static routes before deletion
self.cleanup_tier1_nat_rules(rtr['id'])
self.cleanup_tier1_static_routes(rtr['id'])
try:
self.nsxpolicy.tier1.delete_locale_service(rtr['id'])
except exceptions.ManagerError: