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.pull/8437/head
parent
ea44d64511
commit
c0d1bb1a5c
|
@ -42,6 +42,24 @@ def main():
|
|||
conn.network.security_groups())
|
||||
|
||||
print('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())
|
||||
|
||||
|
|
Loading…
Reference in New Issue