From 5c14c59ac9c9d6462c0adf8c44d322d1f293915e Mon Sep 17 00:00:00 2001 From: asarfaty Date: Sun, 21 Feb 2021 12:23:43 +0200 Subject: [PATCH] NSX|P: add static routes deletion to devstack cleanup Change-Id: I75152f3fcd0853b5068c2db142f068e28ada0baa --- devstack/tools/nsxp_cleanup.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/devstack/tools/nsxp_cleanup.py b/devstack/tools/nsxp_cleanup.py index 04e4df4435..636def120c 100755 --- a/devstack/tools/nsxp_cleanup.py +++ b/devstack/tools/nsxp_cleanup.py @@ -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: