Disassociate Nova networks during cleanup

Closes-bug: #1350517

Add a dirty hack to deal with cleaning up associated Nova networks
after a Rally run. This was originally being done via the cleanup
classes but after discussing with Boris, it was determined this was
the least-bad way to approach the problem.

Change-Id: Ic52bb0d156dc2adebc9bca2daec660f81d16b31c
This commit is contained in:
Rafi Khardalian 2014-08-17 14:52:59 -07:00
parent 103d7cc346
commit 65924c4f55

View File

@ -146,6 +146,21 @@ class UserGenerator(base.Context):
admin_endpoint, tenants = args
client = keystone.wrap(osclients.Clients(admin_endpoint).keystone())
# NOTE(rmk): Ugly hack to deal with the fact that Nova Network
# networks can only be disassociated in an admin context. Discussed
# with boris-42 before taking this approach [LP-Bug #1350517].
nova_admin = osclients.Clients(admin_endpoint).nova()
for network in nova_admin.networks.list():
network_tenant_id = nova_admin.networks.get(network).project_id
for tenant in tenants:
if tenant["id"] == network_tenant_id:
try:
nova_admin.networks.disassociate(network)
except Exception as ex:
LOG.warning("Failed disassociate net: %(tenant_id)s. "
"Exception: %(ex)s" %
{"tenant_id": tenant["id"], "ex": ex})
for tenant in tenants:
try:
client.delete_project(tenant["id"])