Skip to content
Snippets Groups Projects
Unverified Commit c0d1bb1a authored by Kenichi Omichi's avatar Kenichi Omichi Committed by GitHub
Browse files

Remove subnet from router on tf-elastx_cleanup (#8425)

The tf-elastx_cleanup test job was failed with error message:

Port xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx cannot be deleted
directly via the port API: has device owner network:router_interface.

That means necessary to remove a subnet from the router before
deleting the port.
This adds a method to removes a subnet from the router automatically.
parent ea44d645
No related branches found
No related tags found
No related merge requests found
......@@ -42,8 +42,26 @@ def main():
conn.network.security_groups())
print('Ports...')
map_if_old(conn.network.delete_port,
conn.network.ports())
try:
map_if_old(conn.network.delete_port,
conn.network.ports())
except openstack.exceptions.ConflictException as ex:
# Need to find subnet-id which should be removed from a router
for sn in conn.network.subnets():
try:
fn_if_old(conn.network.delete_subnet, sn)
except openstack.exceptions.ConflictException:
for r in conn.network.routers():
print("Deleting subnet %s from router %s", sn, r)
try:
conn.network.remove_interface_from_router(
r, subnet_id=sn.id)
except Exception as ex:
print("Failed to delete subnet from router as %s", ex)
# After removing unnecessary subnet from router, retry to delete ports
map_if_old(conn.network.delete_port,
conn.network.ports())
print('Subnets...')
map_if_old(conn.network.delete_subnet,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment