Rally cleanup script fix
This patch introduces the following changes. 1. rally_cleanup.py has been moved to the utils directory. 2. The rally_cleanup.py script was getting stuck in an infinite loop as some functions were modified to clean up only rally objects while other functions were not modified. This patch modifies the first function that is called in traceback to clean up only rally objects, to avoid such issues. Change-Id: Ie0b5972b62b9dd591506f735191724f1b30c5038
This commit is contained in:
parent
47eacfe85e
commit
ab300f91f6
25
rally_cleanup.py → utils/rally_cleanup.py
Normal file → Executable file
25
rally_cleanup.py → utils/rally_cleanup.py
Normal file → Executable file
@ -51,12 +51,10 @@ MAX_ATTEMPTS = 7
|
|||||||
MAX_CHECK = 6
|
MAX_CHECK = 6
|
||||||
|
|
||||||
# default config file for browbeat
|
# default config file for browbeat
|
||||||
_config_file = 'browbeat-config.yaml'
|
_config_file = '../browbeat-config.yaml'
|
||||||
|
|
||||||
def delete_server(resource):
|
def delete_server(resource):
|
||||||
server = nova_client.servers.get(resource.id)
|
server = nova_client.servers.get(resource.id)
|
||||||
if "rally" not in server.name:
|
|
||||||
return resource
|
|
||||||
print("pid {} deleting server id {} name {}".format(
|
print("pid {} deleting server id {} name {}".format(
|
||||||
os.getpid(), resource.id, server.name))
|
os.getpid(), resource.id, server.name))
|
||||||
nova_client.servers.delete(server)
|
nova_client.servers.delete(server)
|
||||||
@ -73,8 +71,6 @@ def delete_server(resource):
|
|||||||
|
|
||||||
def delete_network(resource):
|
def delete_network(resource):
|
||||||
network = neutron_client.show_network(resource.id)["network"]
|
network = neutron_client.show_network(resource.id)["network"]
|
||||||
if "rally" not in network["name"]:
|
|
||||||
return resource
|
|
||||||
print("pid {} deleting network id {} name {}".format(
|
print("pid {} deleting network id {} name {}".format(
|
||||||
os.getpid(), resource.id, network["name"]))
|
os.getpid(), resource.id, network["name"]))
|
||||||
# delete network
|
# delete network
|
||||||
@ -126,8 +122,6 @@ def delete_floatingip(resource):
|
|||||||
|
|
||||||
def delete_router(resource):
|
def delete_router(resource):
|
||||||
router = neutron_client.show_router(resource.id)["router"]
|
router = neutron_client.show_router(resource.id)["router"]
|
||||||
if "rally" not in router["name"]:
|
|
||||||
return resource
|
|
||||||
print("pid {} deleting router id {} name {}".format(
|
print("pid {} deleting router id {} name {}".format(
|
||||||
os.getpid(), resource.id, router["name"]))
|
os.getpid(), resource.id, router["name"]))
|
||||||
try:
|
try:
|
||||||
@ -150,7 +144,7 @@ def delete_router(resource):
|
|||||||
|
|
||||||
def delete_router_ports(resource):
|
def delete_router_ports(resource):
|
||||||
port = neutron_client.show_port(resource.id)["port"]
|
port = neutron_client.show_port(resource.id)["port"]
|
||||||
if (port["device_owner"] not in ROUTER_INTERFACE_OWNERS or "rally" not in port["name"]):
|
if (port["device_owner"] not in ROUTER_INTERFACE_OWNERS):
|
||||||
return resource
|
return resource
|
||||||
print("pid {} deleting router {} port id {}".format(
|
print("pid {} deleting router {} port id {}".format(
|
||||||
os.getpid(), port["device_id"], resource.id))
|
os.getpid(), port["device_id"], resource.id))
|
||||||
@ -206,7 +200,8 @@ def cleanup_with_concurrency(cleanup_fun, resources):
|
|||||||
|
|
||||||
def cleanup_nova_vms():
|
def cleanup_nova_vms():
|
||||||
while True:
|
while True:
|
||||||
servers = nova_client.servers.list(detailed=True, search_opts={"all_tenants": 1}, limit=100)
|
servers = [server for server in nova_client.servers.list(detailed=True,
|
||||||
|
search_opts={"all_tenants": 1}, limit=100) if "rally" in server.name]
|
||||||
if (len(servers) == 0):
|
if (len(servers) == 0):
|
||||||
break
|
break
|
||||||
print("Deleting {} servers".format(len(servers)))
|
print("Deleting {} servers".format(len(servers)))
|
||||||
@ -221,7 +216,7 @@ def cleanup_neutron_networks():
|
|||||||
if (len(networks) == 0):
|
if (len(networks) == 0):
|
||||||
break
|
break
|
||||||
ids = [Resource(network["id"]) for network in networks
|
ids = [Resource(network["id"]) for network in networks
|
||||||
if network["name"] not in NETWORK_EXCLUDE]
|
if network["name"] not in NETWORK_EXCLUDE and "rally" in network["name"]]
|
||||||
if (len(ids) == 0):
|
if (len(ids) == 0):
|
||||||
break
|
break
|
||||||
print("Deleting {} networks".format(len(ids)))
|
print("Deleting {} networks".format(len(ids)))
|
||||||
@ -241,7 +236,8 @@ def cleanup_neutron_security_groups():
|
|||||||
# we shouldn't cleanup default security group created by admin
|
# we shouldn't cleanup default security group created by admin
|
||||||
default_sg = get_admin_security_group()
|
default_sg = get_admin_security_group()
|
||||||
while True:
|
while True:
|
||||||
sgs = neutron_client.list_security_groups()["security_groups"]
|
sgs = [sg for sg in neutron_client.list_security_groups()["security_groups"]
|
||||||
|
if "rally" in sg["name"]]
|
||||||
if (len(sgs) == 0):
|
if (len(sgs) == 0):
|
||||||
break
|
break
|
||||||
ids = [Resource(sg["id"]) for sg in sgs
|
ids = [Resource(sg["id"]) for sg in sgs
|
||||||
@ -268,7 +264,9 @@ def cleanup_neutron_floatingips():
|
|||||||
|
|
||||||
def _cleanup_neutron_router_ports():
|
def _cleanup_neutron_router_ports():
|
||||||
while True:
|
while True:
|
||||||
ports = neutron_client.list_ports(device_owner='network:router_interface')["ports"]
|
ports = [port for port in neutron_client.list_ports(
|
||||||
|
device_owner='network:router_interface')["ports"]
|
||||||
|
if "rally" in port["name"]]
|
||||||
if (len(ports) == 0):
|
if (len(ports) == 0):
|
||||||
break
|
break
|
||||||
print("Deleting {} router ports".format(len(ports)))
|
print("Deleting {} router ports".format(len(ports)))
|
||||||
@ -281,7 +279,8 @@ def _cleanup_neutron_router_ports():
|
|||||||
def cleanup_neutron_routers():
|
def cleanup_neutron_routers():
|
||||||
_cleanup_neutron_router_ports()
|
_cleanup_neutron_router_ports()
|
||||||
while True:
|
while True:
|
||||||
routers = neutron_client.list_routers()["routers"]
|
routers = [router for router in neutron_client.list_routers()["routers"]
|
||||||
|
if "rally" in router["name"]]
|
||||||
if (len(routers) == 0):
|
if (len(routers) == 0):
|
||||||
break
|
break
|
||||||
print("Deleting {} routers".format(len(routers)))
|
print("Deleting {} routers".format(len(routers)))
|
Loading…
Reference in New Issue
Block a user