From e0dd32af0c22e4684c00b6f5e458b7322ec9e1aa Mon Sep 17 00:00:00 2001 From: linb Date: Sat, 19 Mar 2016 11:13:26 +0800 Subject: [PATCH] clean tier0 ports created from nsxv3 Clean all tier0 ports created from nsxv3 when doing nsxv3 cleanup script. Change-Id: I0960aa58045299054ef9dc4ad4ac589b2ec9bbe6 --- devstack/tools/nsxv3_cleanup.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/devstack/tools/nsxv3_cleanup.py b/devstack/tools/nsxv3_cleanup.py index 49c7a9a0b3..fc52fb20df 100755 --- a/devstack/tools/nsxv3_cleanup.py +++ b/devstack/tools/nsxv3_cleanup.py @@ -360,11 +360,18 @@ class NSXClient(object): response = self.get(endpoint=endpoint) return response.json()['results'] + def get_os_logical_router_ports(self, lrouter): + """ + Retrieve all logical router ports created from Neutron NSXv3 plugin + """ + lports = self.get_logical_router_ports(lrouter) + return self.get_os_resources(lports) + def cleanup_logical_router_ports(self, lrouter): """ Cleanup all logical ports on a logical router """ - lports = self.get_logical_router_ports(lrouter) + lports = self.get_os_logical_router_ports(lrouter) for lp in lports: endpoint = "/logical-router-ports/%s" % lp['id'] response = self.delete(endpoint=endpoint) @@ -395,6 +402,14 @@ class NSXClient(object): print("Failed to delete lrouter %s-%s, and response is %s" % (lr['display_name'], lr['id'])) + def cleanup_os_tier0_logical_ports(self): + """ + Delete all TIER0 logical router ports created from OpenStack + """ + tier0_routers = self.get_logical_routers(tier='TIER0') + for lr in tier0_routers: + self.cleanup_logical_router_ports(lr) + def cleanup_all(self): """ Cleanup steps: @@ -409,6 +424,7 @@ class NSXClient(object): self.cleanup_os_firewall_sections() self.cleanup_os_ns_groups() self.cleanup_os_logical_routers() + self.cleanup_os_tier0_logical_ports() self.cleanup_os_logical_ports() self.cleanup_os_logical_switches() self.cleanup_os_switching_profiles()