From 65924c4f5542535587d4f58ef97ddf8967772b5c Mon Sep 17 00:00:00 2001 From: Rafi Khardalian Date: Sun, 17 Aug 2014 14:52:59 -0700 Subject: [PATCH] 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 --- rally/benchmark/context/users.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rally/benchmark/context/users.py b/rally/benchmark/context/users.py index 306248c18b..97b7439005 100644 --- a/rally/benchmark/context/users.py +++ b/rally/benchmark/context/users.py @@ -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"])