From 8db20558b90dff4b338085c74d0d66781e718e86 Mon Sep 17 00:00:00 2001 From: Kay Yan Date: Thu, 1 Aug 2024 03:46:46 +0000 Subject: [PATCH] fix elastx cleanup security groups --- scripts/openstack-cleanup/main.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/scripts/openstack-cleanup/main.py b/scripts/openstack-cleanup/main.py index 28820de02ed..21d3f328c90 100755 --- a/scripts/openstack-cleanup/main.py +++ b/scripts/openstack-cleanup/main.py @@ -37,17 +37,6 @@ def main(): map_if_old(conn.compute.delete_server, conn.compute.servers()) - print('Security groups...') - try: - map_if_old(conn.network.delete_security_group, - conn.network.security_groups()) - except openstack.exceptions.ConflictException as ex: - # Need to delete port when security groups is in used - map_if_old(conn.network.delete_port, - conn.network.ports()) - map_if_old(conn.network.delete_security_group, - conn.network.security_groups()) - print('Ports...') try: map_if_old(conn.network.delete_port, @@ -73,6 +62,17 @@ def main(): map_if_old(conn.network.delete_port, conn.network.ports()) + print('Security groups...') + try: + map_if_old(conn.network.delete_security_group, + conn.network.security_groups()) + except openstack.exceptions.ConflictException as ex: + # Need to delete port when security groups is in used + map_if_old(conn.network.delete_port, + conn.network.ports()) + map_if_old(conn.network.delete_security_group, + conn.network.security_groups()) + print('Subnets...') map_if_old(conn.network.delete_subnet, conn.network.subnets()) @@ -102,4 +102,4 @@ def fn_if_old(fn, item): if __name__ == '__main__': # execute only if run as a script - main() + main() \ No newline at end of file