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.
This commit is contained in:
parent
ea44d64511
commit
c0d1bb1a5c
1 changed files with 20 additions and 2 deletions
|
@ -42,8 +42,26 @@ def main():
|
||||||
conn.network.security_groups())
|
conn.network.security_groups())
|
||||||
|
|
||||||
print('Ports...')
|
print('Ports...')
|
||||||
map_if_old(conn.network.delete_port,
|
try:
|
||||||
conn.network.ports())
|
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...')
|
print('Subnets...')
|
||||||
map_if_old(conn.network.delete_subnet,
|
map_if_old(conn.network.delete_subnet,
|
||||||
|
|
Loading…
Reference in a new issue