Fix libvirt plugin project/tenant name dimension

Enabling the libvirt plugin to add tenant_name as a dimension is
resulting in "Unable to get tenant list from keystone: Unknown
Attribute: tenants" when using keystone v3. This is due the v3
keystone client uses projects.list() instead of tenants.list().

This change fixes that by checking which client version is being
used and making the function call accordingly.

Change-Id: Icfe88b6a1a7ef193fd998db5a72a7a076d23ffe5
This commit is contained in:
Flávio Ramalho 2017-07-31 15:03:18 +02:00
parent 9ff337881b
commit 8a9de631cf
1 changed files with 4 additions and 1 deletions

View File

@ -42,7 +42,10 @@ def get_tenant_list(config, log):
try:
log.debug("Retrieving Keystone tenant list")
client = keystone.get_client(**config)
tenants = client.tenants.list()
if 'v2' in client.__module__:
tenants = client.tenants.list()
else:
tenants = client.projects.list()
except Exception as e:
msg = "Unable to get tenant list from keystone: {0}"
log.error(msg.format(e))